@react-three/fiber 9.0.0-alpha.6 → 9.0.0-alpha.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.16.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 03ab82fe: fix(applyProps): null check indeterminate instances
8
+
3
9
  ## 8.16.5
4
10
 
5
11
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
+ import { type Properties } from "./utils.js";
2
3
  import type { RootState, RootStore } from "./store.js";
3
- import type { Properties } from "../three-types.js";
4
4
  export interface Intersection extends THREE.Intersection {
5
5
  /** The event source (the object which registered the handler) */
6
6
  eventObject: THREE.Object3D;
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import * as React from 'react';
3
- import { RootState, RenderCallback, UpdateCallback, StageTypes, RootStore } from "./store.js";
3
+ import { RootState, RenderCallback, RootStore } from "./store.js";
4
4
  import { ObjectMap } from "./utils.js";
5
5
  import type { Instance } from "./reconciler.js";
6
6
  /**
@@ -26,11 +26,6 @@ export declare function useThree<T = RootState>(selector?: (state: RootState) =>
26
26
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
27
27
  */
28
28
  export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
29
- /**
30
- * Executes a callback in a given update stage.
31
- * Uses the stage instance to identify which stage to target in the lifecycle.
32
- */
33
- export declare function useUpdate(callback: UpdateCallback, stage?: StageTypes): void;
34
29
  /**
35
30
  * Returns a node graph of an object with named nodes & materials.
36
31
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
@@ -7,9 +7,7 @@ export type { AttachFnType, AttachType, ConstructorRepresentation, Catalogue, Ar
7
7
  export { extend, reconciler } from "./reconciler.js";
8
8
  export type { ReconcilerRoot, GLProps, CameraProps, RenderProps, InjectState } from "./renderer.js";
9
9
  export { _roots, render, createRoot, unmountComponentAtNode, createPortal } from "./renderer.js";
10
- export type { UpdateSubscription } from "./stages.js";
11
- export { Stage, FixedStage, Stages } from "./stages.js";
12
- export type { Subscription, Dpr, Size, Viewport, RenderCallback, UpdateCallback, LegacyAlways, FrameloopMode, FrameloopRender, FrameloopLegacy, Frameloop, Performance, Renderer, StageTypes, XRManager, RootState, RootStore, } from "./store.js";
10
+ export type { Subscription, Dpr, Size, Viewport, RenderCallback, Frameloop, Performance, Renderer, XRManager, RootState, RootStore, } from "./store.js";
13
11
  export { context } from "./store.js";
14
12
  export type { ObjectMap, Camera, Disposable, Act } from "./utils.js";
15
13
  export { applyProps, getRootState, dispose, act, buildGraph } from "./utils.js";
@@ -4,6 +4,9 @@ import Reconciler from 'react-reconciler';
4
4
  import type { RootStore } from "./store.js";
5
5
  import { type EventHandlers } from "./events.js";
6
6
  import type { ThreeElement } from "../three-types.js";
7
+ declare module 'react-reconciler/constants' {
8
+ const NoEventPriority = 0;
9
+ }
7
10
  export interface Root {
8
11
  fiber: Reconciler.FiberRoot;
9
12
  store: RootStore;
@@ -21,6 +24,7 @@ export interface InstanceProps<T = any, P = any> {
21
24
  visible?: boolean;
22
25
  dispose?: null;
23
26
  attach?: AttachType<T>;
27
+ onUpdate?: (self: T) => void;
24
28
  }
25
29
  export interface Instance<O = any> {
26
30
  root: RootStore;
@@ -36,8 +40,8 @@ export interface Instance<O = any> {
36
40
  attach?: AttachType<O>;
37
41
  previousAttach?: any;
38
42
  isHidden: boolean;
39
- autoRemovedBeforeAppend?: boolean;
40
43
  }
41
44
  export declare const catalogue: Catalogue;
42
- export declare const extend: <T extends Catalogue | ConstructorRepresentation<any>>(objects: T) => T extends ConstructorRepresentation<any> ? React.ExoticComponent<import("../three-types.js").Mutable<import("../three-types.js").Overwrite<Partial<import("../three-types.js").Overwrite<import("../three-types.js").WithMathProps<InstanceType<T>>, import("../three-types.js").ReactProps<InstanceType<T>> & import("../three-types.js").EventProps<InstanceType<T>>>>, Omit<InstanceProps<InstanceType<T>, T>, "object">>>> : void;
45
+ export declare function extend<T extends ConstructorRepresentation>(objects: T): React.ExoticComponent<ThreeElement<T>>;
46
+ export declare function extend<T extends Catalogue>(objects: T): void;
43
47
  export declare const reconciler: Reconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, any>;
@@ -1,11 +1,10 @@
1
1
  import * as THREE from 'three';
2
2
  import * as React from 'react';
3
- import type { Properties, ThreeElement } from "../three-types.js";
3
+ import type { ThreeElement } from "../three-types.js";
4
4
  import { Renderer, RootState, Size, Dpr, Performance, Frameloop, RootStore } from "./store.js";
5
5
  import { Root } from "./reconciler.js";
6
6
  import { EventManager, ComputeFunction } from "./events.js";
7
- import { Camera } from "./utils.js";
8
- import { Stage } from "./stages.js";
7
+ import { type Properties, Camera } from "./utils.js";
9
8
  interface OffscreenCanvas extends EventTarget {
10
9
  }
11
10
  export declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
@@ -60,9 +59,6 @@ export interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas
60
59
  onCreated?: (state: RootState) => void;
61
60
  /** Response for pointer clicks that have missed any target */
62
61
  onPointerMissed?: (event: MouseEvent) => void;
63
- /** Create a custom lifecycle of stages */
64
- stages?: Stage[];
65
- render?: 'auto' | 'manual';
66
62
  }
67
63
  export interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
68
64
  configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
@@ -5,7 +5,6 @@ import { type StoreApi } from 'zustand';
5
5
  import { type UseBoundStoreWithEqualityFn } from 'zustand/traditional';
6
6
  import type { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from "./events.js";
7
7
  import { type Camera } from "./utils.js";
8
- import type { FixedStage, Stage } from "./stages.js";
9
8
  export interface Intersection extends THREE.Intersection {
10
9
  eventObject: THREE.Object3D;
11
10
  }
@@ -21,6 +20,7 @@ export interface Size {
21
20
  top: number;
22
21
  left: number;
23
22
  }
23
+ export type Frameloop = 'always' | 'demand' | 'never';
24
24
  export interface Viewport extends Size {
25
25
  /** The initial pixel ratio */
26
26
  initialDpr: number;
@@ -34,16 +34,6 @@ export interface Viewport extends Size {
34
34
  aspect: number;
35
35
  }
36
36
  export type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void;
37
- export type UpdateCallback = RenderCallback;
38
- export type LegacyAlways = 'always';
39
- export type FrameloopMode = LegacyAlways | 'auto' | 'demand' | 'never';
40
- export type FrameloopRender = 'auto' | 'manual';
41
- export type FrameloopLegacy = 'always' | 'demand' | 'never';
42
- export type Frameloop = FrameloopLegacy | {
43
- mode?: FrameloopMode;
44
- render?: FrameloopRender;
45
- maxDelta?: number;
46
- };
47
37
  export interface Performance {
48
38
  /** Current performance normal, between min and max */
49
39
  current: number;
@@ -60,7 +50,6 @@ export interface Renderer {
60
50
  render: (scene: THREE.Scene, camera: THREE.Camera) => any;
61
51
  }
62
52
  export declare const isRenderer: (def: any) => boolean;
63
- export type StageTypes = Stage | FixedStage;
64
53
  export interface InternalState {
65
54
  interaction: THREE.Object3D[];
66
55
  hovered: Map<string, ThreeEvent<DomEvent>>;
@@ -72,12 +61,6 @@ export interface InternalState {
72
61
  active: boolean;
73
62
  priority: number;
74
63
  frames: number;
75
- /** The ordered stages defining the lifecycle. */
76
- stages: StageTypes[];
77
- /** Render function flags */
78
- render: 'auto' | 'manual';
79
- /** The max delta time between two frames. */
80
- maxDelta: number;
81
64
  subscribe: (callback: React.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void;
82
65
  }
83
66
  export interface XRManager {
@@ -114,9 +97,8 @@ export interface RootState {
114
97
  linear: boolean;
115
98
  /** Shortcut to gl.toneMapping = NoTonemapping */
116
99
  flat: boolean;
117
- /** Update frame loop flags */
118
- frameloop: FrameloopLegacy;
119
- /** Adaptive performance interface */
100
+ /** Render loop flags */
101
+ frameloop: Frameloop;
120
102
  performance: Performance;
121
103
  /** Reactive pixel-size of the canvas */
122
104
  size: Size;
@@ -3,6 +3,14 @@ import * as React from 'react';
3
3
  import { Instance } from "./reconciler.js";
4
4
  import type { Fiber } from 'react-reconciler';
5
5
  import type { Dpr, Renderer, RootStore, Size } from "./store.js";
6
+ export type NonFunctionKeys<P> = {
7
+ [K in keyof P]-?: P[K] extends Function ? never : K;
8
+ }[keyof P];
9
+ export type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
10
+ export type Properties<T> = Pick<T, NonFunctionKeys<T>>;
11
+ export type Mutable<P> = {
12
+ [K in keyof P]: P[K] | Readonly<P[K]>;
13
+ };
6
14
  /**
7
15
  * Returns the instance's initial (outmost) root.
8
16
  */
@@ -10,7 +18,7 @@ export declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
10
18
  /**
11
19
  * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
12
20
  */
13
- export declare const hasColorSpace: <T extends object | Renderer | THREE.Texture, P = T extends Renderer ? {
21
+ export declare const hasColorSpace: <T extends object | THREE.Texture | Renderer, P = T extends Renderer ? {
14
22
  outputColorSpace: string;
15
23
  } : {
16
24
  colorSpace: string;
@@ -1,20 +1,16 @@
1
1
  import type * as THREE from 'three';
2
2
  import type { Args, EventHandlers, InstanceProps, ConstructorRepresentation } from "./core/index.js";
3
- type NonFunctionKeys<P> = {
4
- [K in keyof P]-?: P[K] extends Function ? never : K;
5
- }[keyof P];
6
- export type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
7
- export type Properties<T> = Pick<T, NonFunctionKeys<T>>;
8
- export type Mutable<P> = {
9
- [K in keyof P]: P[K] | Readonly<P[K]>;
10
- };
3
+ import type { Overwrite, Mutable } from "./core/utils.js";
11
4
  export interface MathRepresentation {
12
- set(...args: number[]): any;
5
+ set(...args: any[]): any;
13
6
  }
14
7
  export interface VectorRepresentation extends MathRepresentation {
15
- setScalar(s: number): any;
8
+ setScalar(value: number): any;
16
9
  }
17
- export type MathType<T extends MathRepresentation | THREE.Euler> = T extends THREE.Color ? Args<typeof THREE.Color> | THREE.ColorRepresentation : T extends VectorRepresentation | THREE.Layers | THREE.Euler ? T | Parameters<T['set']> | number : T | Parameters<T['set']>;
10
+ export type MathType<T extends MathRepresentation> = T extends THREE.Color ? Args<typeof THREE.Color> | THREE.ColorRepresentation : T extends VectorRepresentation | THREE.Layers | THREE.Euler ? T | Parameters<T['set']> | number : T | Parameters<T['set']>;
11
+ export type MathProps<P> = {
12
+ [K in keyof P as P[K] extends MathRepresentation ? K : never]: P[K] extends MathRepresentation ? MathType<P[K]> : never;
13
+ };
18
14
  export type Vector2 = MathType<THREE.Vector2>;
19
15
  export type Vector3 = MathType<THREE.Vector3>;
20
16
  export type Vector4 = MathType<THREE.Vector4>;
@@ -24,9 +20,6 @@ export type Quaternion = MathType<THREE.Quaternion>;
24
20
  export type Euler = MathType<THREE.Euler>;
25
21
  export type Matrix3 = MathType<THREE.Matrix3>;
26
22
  export type Matrix4 = MathType<THREE.Matrix4>;
27
- export type WithMathProps<P> = {
28
- [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K];
29
- };
30
23
  export interface RaycastableRepresentation {
31
24
  raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
32
25
  }
@@ -36,7 +29,7 @@ export interface ReactProps<P> {
36
29
  ref?: React.Ref<P>;
37
30
  key?: React.Key;
38
31
  }
39
- export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<WithMathProps<P>, ReactProps<P> & EventProps<P>>>;
32
+ export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>>;
40
33
  export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
41
34
  type ThreeExports = typeof THREE;
42
35
  type ThreeElementsImpl = {