@react-three/fiber 9.8.0 → 9.8.2

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,7 +1,9 @@
1
1
  import * as THREE from 'three';
2
- import * as React from 'react';
2
+ import type * as React from 'react';
3
3
  import { Instance } from "./reconciler.js";
4
4
  import type { Dpr, RootStore, Size } from "./store.js";
5
+ export type { Act, Bridge, SetBlock, UnblockProps } from "./utils/react.js";
6
+ export { act, useIsomorphicLayoutEffect, useMutableCallback, useGate, useBridge, Block, ErrorBoundary, } from "./utils/react.js";
5
7
  export type NonFunctionKeys<P> = {
6
8
  [K in keyof P]-?: P[K] extends Function ? never : K;
7
9
  }[keyof P];
@@ -16,196 +18,13 @@ export type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Re
16
18
  * Returns the instance's initial (outmost) root.
17
19
  */
18
20
  export declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
19
- export type Act = <T = any>(cb: () => Promise<T>) => Promise<T>;
20
- /**
21
- * Safely flush async effects when testing, simulating a legacy root.
22
- * @deprecated Import from React instead. import { act } from 'react'
23
- */
24
- export declare const act: Act;
25
21
  export type Camera = (THREE.OrthographicCamera | THREE.PerspectiveCamera) & {
26
22
  manual?: boolean;
27
23
  };
28
24
  export declare const isOrthographicCamera: (def: Camera) => def is THREE.OrthographicCamera;
29
25
  export declare const isRef: (obj: any) => obj is React.RefObject<unknown>;
30
26
  export declare const isColorRepresentation: (value: unknown) => value is THREE.ColorRepresentation;
31
- /**
32
- * An SSR-friendly useLayoutEffect.
33
- *
34
- * React currently throws a warning when using useLayoutEffect on the server.
35
- * To get around it, we can conditionally useEffect on the server (no-op) and
36
- * useLayoutEffect elsewhere.
37
- *
38
- * @see https://github.com/facebook/react/issues/14927
39
- */
40
- export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
41
- export declare function useMutableCallback<T>(fn: T): React.RefObject<T>;
42
27
  export declare const noop: () => void;
43
- /** Waits for a promise in a null subtree, re-rendering the caller once it settles either way. */
44
- export declare function useGate(): [gate: React.ReactNode, waitFor: (promise: PromiseLike<unknown>) => void];
45
- export type Bridge = React.FC<{
46
- children?: React.ReactNode;
47
- }>;
48
- /**
49
- * Bridges renderer Context and StrictMode from a primary renderer.
50
- */
51
- export declare function useBridge(): Bridge;
52
- export type SetBlock = false | Promise<null> | null;
53
- export type UnblockProps = {
54
- set: React.Dispatch<React.SetStateAction<SetBlock>>;
55
- children: React.ReactNode;
56
- };
57
- export declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
58
- export declare const ErrorBoundary: {
59
- new (props: {
60
- set: React.Dispatch<Error | undefined>;
61
- children: React.ReactNode;
62
- }): {
63
- state: {
64
- error: boolean;
65
- };
66
- componentDidCatch(err: Error): void;
67
- render(): React.ReactNode;
68
- context: unknown;
69
- setState<K extends "error">(state: {
70
- error: boolean;
71
- } | ((prevState: Readonly<{
72
- error: boolean;
73
- }>, props: Readonly<{
74
- set: React.Dispatch<Error | undefined>;
75
- children: React.ReactNode;
76
- }>) => {
77
- error: boolean;
78
- } | Pick<{
79
- error: boolean;
80
- }, K> | null) | Pick<{
81
- error: boolean;
82
- }, K> | null, callback?: (() => void) | undefined): void;
83
- forceUpdate(callback?: (() => void) | undefined): void;
84
- readonly props: Readonly<{
85
- set: React.Dispatch<Error | undefined>;
86
- children: React.ReactNode;
87
- }>;
88
- componentDidMount?(): void;
89
- shouldComponentUpdate?(nextProps: Readonly<{
90
- set: React.Dispatch<Error | undefined>;
91
- children: React.ReactNode;
92
- }>, nextState: Readonly<{
93
- error: boolean;
94
- }>, nextContext: any): boolean;
95
- componentWillUnmount?(): void;
96
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
97
- set: React.Dispatch<Error | undefined>;
98
- children: React.ReactNode;
99
- }>, prevState: Readonly<{
100
- error: boolean;
101
- }>): any;
102
- componentDidUpdate?(prevProps: Readonly<{
103
- set: React.Dispatch<Error | undefined>;
104
- children: React.ReactNode;
105
- }>, prevState: Readonly<{
106
- error: boolean;
107
- }>, snapshot?: any): void;
108
- componentWillMount?(): void;
109
- UNSAFE_componentWillMount?(): void;
110
- componentWillReceiveProps?(nextProps: Readonly<{
111
- set: React.Dispatch<Error | undefined>;
112
- children: React.ReactNode;
113
- }>, nextContext: any): void;
114
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
115
- set: React.Dispatch<Error | undefined>;
116
- children: React.ReactNode;
117
- }>, nextContext: any): void;
118
- componentWillUpdate?(nextProps: Readonly<{
119
- set: React.Dispatch<Error | undefined>;
120
- children: React.ReactNode;
121
- }>, nextState: Readonly<{
122
- error: boolean;
123
- }>, nextContext: any): void;
124
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
125
- set: React.Dispatch<Error | undefined>;
126
- children: React.ReactNode;
127
- }>, nextState: Readonly<{
128
- error: boolean;
129
- }>, nextContext: any): void;
130
- };
131
- new (props: {
132
- set: React.Dispatch<Error | undefined>;
133
- children: React.ReactNode;
134
- }, context: any): {
135
- state: {
136
- error: boolean;
137
- };
138
- componentDidCatch(err: Error): void;
139
- render(): React.ReactNode;
140
- context: unknown;
141
- setState<K extends "error">(state: {
142
- error: boolean;
143
- } | ((prevState: Readonly<{
144
- error: boolean;
145
- }>, props: Readonly<{
146
- set: React.Dispatch<Error | undefined>;
147
- children: React.ReactNode;
148
- }>) => {
149
- error: boolean;
150
- } | Pick<{
151
- error: boolean;
152
- }, K> | null) | Pick<{
153
- error: boolean;
154
- }, K> | null, callback?: (() => void) | undefined): void;
155
- forceUpdate(callback?: (() => void) | undefined): void;
156
- readonly props: Readonly<{
157
- set: React.Dispatch<Error | undefined>;
158
- children: React.ReactNode;
159
- }>;
160
- componentDidMount?(): void;
161
- shouldComponentUpdate?(nextProps: Readonly<{
162
- set: React.Dispatch<Error | undefined>;
163
- children: React.ReactNode;
164
- }>, nextState: Readonly<{
165
- error: boolean;
166
- }>, nextContext: any): boolean;
167
- componentWillUnmount?(): void;
168
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
169
- set: React.Dispatch<Error | undefined>;
170
- children: React.ReactNode;
171
- }>, prevState: Readonly<{
172
- error: boolean;
173
- }>): any;
174
- componentDidUpdate?(prevProps: Readonly<{
175
- set: React.Dispatch<Error | undefined>;
176
- children: React.ReactNode;
177
- }>, prevState: Readonly<{
178
- error: boolean;
179
- }>, snapshot?: any): void;
180
- componentWillMount?(): void;
181
- UNSAFE_componentWillMount?(): void;
182
- componentWillReceiveProps?(nextProps: Readonly<{
183
- set: React.Dispatch<Error | undefined>;
184
- children: React.ReactNode;
185
- }>, nextContext: any): void;
186
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
187
- set: React.Dispatch<Error | undefined>;
188
- children: React.ReactNode;
189
- }>, nextContext: any): void;
190
- componentWillUpdate?(nextProps: Readonly<{
191
- set: React.Dispatch<Error | undefined>;
192
- children: React.ReactNode;
193
- }>, nextState: Readonly<{
194
- error: boolean;
195
- }>, nextContext: any): void;
196
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
197
- set: React.Dispatch<Error | undefined>;
198
- children: React.ReactNode;
199
- }>, nextState: Readonly<{
200
- error: boolean;
201
- }>, nextContext: any): void;
202
- };
203
- getDerivedStateFromError: () => {
204
- error: boolean;
205
- };
206
- contextType?: React.Context<any> | undefined;
207
- propTypes?: any;
208
- };
209
28
  export interface ObjectMap {
210
29
  nodes: {
211
30
  [name: string]: THREE.Object3D;
@@ -218,6 +37,12 @@ export interface ObjectMap {
218
37
  };
219
38
  }
220
39
  export declare function calculateDpr(dpr: Dpr): number;
40
+ /**
41
+ * Calls `onChange` whenever window.devicePixelRatio changes: moving to another display or zooming.
42
+ * Neither resizes the canvas, so resize observers won't see it. A resolution query only matches the
43
+ * current ratio, so it is re-created after every change. Returns the unsubscribe function.
44
+ */
45
+ export declare function watchDpr(onChange: () => void): () => void;
221
46
  /**
222
47
  * Returns instance root state
223
48
  */
@@ -34,7 +34,7 @@ export interface ReactProps<P> {
34
34
  export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>>;
35
35
  export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
36
36
  export type ThreeToJSXElements<T extends Record<string, any>> = {
37
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never;
37
+ [K in keyof T & string as T[K] extends ConstructorRepresentation ? Uncapitalize<K> : never]: ThreeElement<T[K]>;
38
38
  };
39
39
  type ThreeExports = typeof THREE;
40
40
  type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>;