@react-three/fiber 8.0.0-beta.2 → 8.0.0-beta.5

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.
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three';
2
- import type { UseStore } from 'zustand';
2
+ import type { UseBoundStore } from 'zustand';
3
3
  import type { RootState } from './store';
4
4
  export interface Intersection extends THREE.Intersection {
5
5
  eventObject: THREE.Object3D;
@@ -58,7 +58,7 @@ export interface PointerCaptureTarget {
58
58
  target: Element;
59
59
  }
60
60
  export declare function getEventPriority(): any;
61
- export declare function removeInteractivity(store: UseStore<RootState>, object: THREE.Object3D): void;
62
- export declare function createEvents(store: UseStore<RootState>): {
61
+ export declare function removeInteractivity(store: UseBoundStore<RootState>, object: THREE.Object3D): void;
62
+ export declare function createEvents(store: UseBoundStore<RootState>): {
63
63
  handlePointer: (name: string) => (event: DomEvent) => void;
64
64
  };
@@ -1,5 +1,6 @@
1
1
  import * as THREE from 'three';
2
- import { StateSelector, EqualityChecker } from 'zustand';
2
+ import * as React from 'react';
3
+ import { StateSelector, EqualityChecker, UseBoundStore } from 'zustand';
3
4
  import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
4
5
  import { RootState, RenderCallback } from './store';
5
6
  import { ObjectMap } from './utils';
@@ -10,8 +11,11 @@ export declare type Extensions = (loader: THREE.Loader) => void;
10
11
  export declare type LoaderResult<T> = T extends any[] ? Loader<T[number]> : Loader<T>;
11
12
  export declare type ConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
12
13
  export declare type BranchingReturn<T, Parent, Coerced> = ConditionalType<T, Parent, Coerced, T>;
13
- export declare function useStore(): import("zustand").UseStore<RootState, import("zustand").StoreApi<RootState>>;
14
+ export declare function useStore(): UseBoundStore<RootState, import("zustand").StoreApi<RootState>>;
14
15
  export declare function useThree<T = RootState>(selector?: StateSelector<RootState, T>, equalityFn?: EqualityChecker<T>): T;
16
+ export declare function useInject(state: Partial<RootState>): [React.FC<{
17
+ children: React.ReactNode;
18
+ }>, UseBoundStore<RootState, import("zustand").StoreApi<RootState>>];
15
19
  export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
16
20
  export declare function useGraph(object: THREE.Object3D): ObjectMap;
17
21
  export declare function useLoader<T, U extends string | string[]>(Proto: new () => LoaderResult<T>, input: U, extensions?: Extensions, onProgress?: (event: ProgressEvent<EventTarget>) => void): U extends any[] ? BranchingReturn<T, GLTF, GLTF & ObjectMap>[] : BranchingReturn<T, GLTF, GLTF & ObjectMap>;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react-reconciler" />
2
2
  import * as THREE from 'three';
3
3
  import * as React from 'react';
4
- import { UseStore } from 'zustand';
4
+ import { UseBoundStore } from 'zustand';
5
5
  import { Renderer, StoreProps, context, RootState, Size } from './store';
6
6
  import { extend, Root } from './renderer';
7
7
  import { addEffect, addAfterEffect, addTail } from './loop';
@@ -16,19 +16,19 @@ declare type Properties<T> = Pick<T, {
16
16
  declare type GLProps = Renderer | ((canvas: HTMLCanvasElement) => Renderer) | Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
17
17
  export declare type RenderProps<TCanvas extends Element> = Omit<StoreProps, 'gl' | 'events' | 'size'> & {
18
18
  gl?: GLProps;
19
- events?: (store: UseStore<RootState>) => EventManager<TCanvas>;
19
+ events?: (store: UseBoundStore<RootState>) => EventManager<TCanvas>;
20
20
  size?: Size;
21
21
  onCreated?: (state: RootState) => void;
22
22
  };
23
23
  export declare type ReconcilerRoot<TCanvas extends Element> = {
24
24
  configure: (config?: RenderProps<TCanvas>) => ReconcilerRoot<TCanvas>;
25
- render: (element: React.ReactNode) => UseStore<RootState>;
25
+ render: (element: React.ReactNode) => UseBoundStore<RootState>;
26
26
  unmount: () => void;
27
27
  };
28
28
  declare function createRoot<TCanvas extends Element>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
29
- declare function render<TCanvas extends Element>(element: React.ReactNode, canvas: TCanvas, config?: RenderProps<TCanvas>): UseStore<RootState>;
29
+ declare function render<TCanvas extends Element>(element: React.ReactNode, canvas: TCanvas, config?: RenderProps<TCanvas>): UseBoundStore<RootState>;
30
30
  declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
31
+ declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: Partial<RootState>): React.ReactNode;
31
32
  declare const act: any;
32
- declare function createPortal(children: React.ReactNode, container: THREE.Object3D): React.ReactNode;
33
33
  export * from './hooks';
34
34
  export { context, render, createRoot, unmountComponentAtNode, createPortal, reconciler, applyProps, dispose, invalidate, advance, extend, addEffect, addAfterEffect, addTail, act, roots as _roots, };
@@ -1,28 +1,29 @@
1
1
  import * as THREE from 'three';
2
- import { UseStore } from 'zustand';
2
+ import { UseBoundStore } from 'zustand';
3
3
  import Reconciler from 'react-reconciler';
4
4
  import { prepare, applyProps } from './utils';
5
5
  import { RootState } from './store';
6
6
  import { EventHandlers } from './events';
7
7
  export declare type Root = {
8
8
  fiber: Reconciler.FiberRoot;
9
- store: UseStore<RootState>;
9
+ store: UseBoundStore<RootState>;
10
10
  };
11
11
  export declare type LocalState = {
12
- root: UseStore<RootState>;
12
+ type: string;
13
+ root: UseBoundStore<RootState>;
13
14
  objects: Instance[];
14
15
  parent: Instance | null;
15
16
  primitive?: boolean;
16
17
  eventCount: number;
17
18
  handlers: Partial<EventHandlers>;
18
19
  attach?: AttachType;
19
- previousAttach?: any;
20
+ previousAttach: any;
20
21
  memoizedProps: {
21
22
  [key: string]: any;
22
23
  };
23
24
  };
24
- export declare type AttachFnType = (parent: Instance, self: Instance) => void;
25
- export declare type AttachType = string | [attach: string | AttachFnType, detach: string | AttachFnType];
25
+ export declare type AttachFnType = (parent: Instance, self: Instance) => () => void;
26
+ export declare type AttachType = string | AttachFnType;
26
27
  export declare type BaseInstance = Omit<THREE.Object3D, 'children' | 'attach' | 'add' | 'remove' | 'raycast'> & {
27
28
  __r3f: LocalState;
28
29
  children: Instance[];
@@ -1,7 +1,7 @@
1
1
  import * as THREE from 'three';
2
2
  import * as React from 'react';
3
3
  import * as ReactThreeFiber from '../three-types';
4
- import { GetState, SetState, UseStore } from 'zustand';
4
+ import { GetState, SetState, UseBoundStore } from 'zustand';
5
5
  import { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from './events';
6
6
  export interface Intersection extends THREE.Intersection {
7
7
  eventObject: THREE.Object3D;
@@ -110,6 +110,6 @@ export declare type StoreProps = {
110
110
  };
111
111
  onPointerMissed?: (event: MouseEvent) => void;
112
112
  };
113
- declare const context: React.Context<UseStore<RootState, import("zustand").StoreApi<RootState>>>;
114
- declare const createStore: (invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void) => UseStore<RootState>;
113
+ declare const context: React.Context<UseBoundStore<RootState, import("zustand").StoreApi<RootState>>>;
114
+ declare const createStore: (invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void) => UseBoundStore<RootState>;
115
115
  export { createStore, context };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { View, ViewProps, ViewStyle } from 'react-native';
3
- import { UseStore } from 'zustand';
3
+ import { UseBoundStore } from 'zustand';
4
4
  import { RenderProps } from '../core';
5
5
  import { RootState } from '../core/store';
6
6
  import { EventManager } from '../core/events';
@@ -8,6 +8,6 @@ export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'ev
8
8
  children: React.ReactNode;
9
9
  fallback?: React.ReactNode;
10
10
  style?: ViewStyle;
11
- events?: (store: UseStore<RootState>) => EventManager<any>;
11
+ events?: (store: UseBoundStore<RootState>) => EventManager<any>;
12
12
  }
13
13
  export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<View>>;
@@ -1,5 +1,5 @@
1
- import { UseStore } from 'zustand';
1
+ import { UseBoundStore } from 'zustand';
2
2
  import { RootState } from '../core/store';
3
3
  import { EventManager } from '../core/events';
4
4
  import { View } from 'react-native';
5
- export declare function createTouchEvents(store: UseStore<RootState>): EventManager<View>;
5
+ export declare function createTouchEvents(store: UseBoundStore<RootState>): EventManager<View>;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { Options as ResizeOptions } from 'react-use-measure';
3
- import { UseStore } from 'zustand';
3
+ import { UseBoundStore } from 'zustand';
4
4
  import { RenderProps } from '../core';
5
5
  import { RootState } from '../core/store';
6
6
  import { EventManager } from '../core/events';
@@ -8,6 +8,6 @@ export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'ev
8
8
  children: React.ReactNode;
9
9
  fallback?: React.ReactNode;
10
10
  resize?: ResizeOptions;
11
- events?: (store: UseStore<RootState>) => EventManager<any>;
11
+ events?: (store: UseBoundStore<RootState>) => EventManager<any>;
12
12
  }
13
13
  export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
@@ -1,4 +1,4 @@
1
- import { UseStore } from 'zustand';
1
+ import { UseBoundStore } from 'zustand';
2
2
  import { RootState } from '../core/store';
3
3
  import { EventManager } from '../core/events';
4
- export declare function createPointerEvents(store: UseStore<RootState>): EventManager<HTMLElement>;
4
+ export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;