@react-three/fiber 9.8.1 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 9.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Include native build output explicitly in published packages so workspace ignore rules cannot omit the React Native entry points.
8
+ - 77406776ae0ee61a4ca73e92082929f9a54359ab: Keep pointer capture working when an object's `args` change during a drag (#3985), and request a frame when an object is removed with `frameloop="demand"` so it disappears immediately (#3976).
9
+ - d74622ea8ed717f7212d7e19d65ff3e325508389: Fix `createPortal` memory leaks: parent subscriptions are cleaned up when a portal unmounts or is hidden by Activity (#3676), and event setters no longer retain earlier portal states (#3751). Portal state survives Activity hide/show, and parent changes made before subscribing or while hidden are applied when the subscription starts. Ports the leak fixes from v10.
10
+ - db8fdf21fa46e3b40d2791e0ea7a684d878ae404: Only register three.js constructors as JSX intrinsic elements. Non-constructor exports such as constants and `MathUtils` were previously registered with `never` props, which collapsed the props of any `React.ElementType` to `never` once `@react-three/fiber` was imported.
11
+ - bffddfaafbf9a5e1f749cb6612d6b1f0189b26a9: fix: follow devicePixelRatio changes when the canvas moves to another display or the page is zoomed.
12
+
13
+ Neither resizes the canvas, so nothing re-rendered it and the `dpr` prop stayed resolved against the old ratio: blurry on a denser display, four times the pixels on a coarser one. Roots now watch the ratio and re-resolve the prop the same way a re-render does. A fixed `dpr` is unaffected and never touches `matchMedia`, changes during an XR session apply once it ends, and environments without a working `matchMedia`, such as test setups with a partial mock, behave as before.
14
+
3
15
  ## 9.8.1
4
16
 
5
17
  ### Patch Changes
@@ -69,8 +69,6 @@ export interface AppliedConfiguration {
69
69
  /** The camera prop that set the current camera */
70
70
  camera?: Configuration['camera'];
71
71
  }
72
- /** The renderer to configure, or a promise for one from an async factory */
73
- export declare function createRenderer(canvas: Canvas, gl?: GLProps): Renderer | PromiseLike<Renderer>;
74
72
  /**
75
73
  * Applies the inputs that changed since the last configuration applied in full, to a root whose
76
74
  * renderer is installed. A runtime change, such as setFrameloop or an edit to gl.shadowMap, lasts
@@ -81,4 +79,13 @@ export declare function applyRootConfiguration({ store, configuration }: {
81
79
  store: RootStore;
82
80
  configuration: AppliedConfiguration;
83
81
  }, canvas: Canvas, props: Configuration): void;
82
+ /**
83
+ * Moving to another display or zooming changes window.devicePixelRatio without resizing the canvas,
84
+ * so nothing configures the root again. Resolves the ratio the way configuration does, from the last
85
+ * applied dpr. Returns the function that stops following.
86
+ */
87
+ export declare function followDpr(root: {
88
+ store: RootStore;
89
+ configuration: AppliedConfiguration;
90
+ }): () => void;
84
91
  export {};
@@ -0,0 +1,12 @@
1
+ /** Constructor registration and lookup for JSX elements. */
2
+ import type * as React from 'react';
3
+ import type { ThreeElement } from "../three-types.js";
4
+ export type ConstructorRepresentation<T = any> = new (...args: any[]) => T;
5
+ export interface Catalogue {
6
+ [name: string]: ConstructorRepresentation;
7
+ }
8
+ export declare const toPascalCase: (type: string) => string;
9
+ export declare function hasConstructor(name: string): boolean;
10
+ export declare function resolveConstructor(name: string): ConstructorRepresentation | undefined;
11
+ export declare function extend<T extends ConstructorRepresentation>(objects: T): React.ExoticComponent<ThreeElement<T>>;
12
+ export declare function extend<T extends Catalogue>(objects: T): void;
@@ -2,7 +2,8 @@ import * as THREE from 'three';
2
2
  import * as React from 'react';
3
3
  import { RootState, RenderCallback, RootStore } from "./store.js";
4
4
  import { ObjectMap } from "./utils.js";
5
- import type { Instance, ConstructorRepresentation } from "./reconciler.js";
5
+ import type { Instance } from "./reconciler.js";
6
+ import type { ConstructorRepresentation } from "./extend.js";
6
7
  /**
7
8
  * Exposes an object's {@link Instance}.
8
9
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
@@ -3,8 +3,10 @@ export { createEvents } from "./events.js";
3
3
  export * from "./hooks.js";
4
4
  export type { GlobalRenderCallback, GlobalEffectType } from "./loop.js";
5
5
  export { flushGlobalEffects, addEffect, addAfterEffect, addTail, invalidate, advance } from "./loop.js";
6
- export type { AttachFnType, AttachType, ConstructorRepresentation, Catalogue, Args, InstanceProps, Instance, } from "./reconciler.js";
7
- export { extend, reconciler, flushSync } from "./reconciler.js";
6
+ export type { AttachFnType, AttachType, Args, InstanceProps, Instance } from "./reconciler.js";
7
+ export type { ConstructorRepresentation, Catalogue } from "./extend.js";
8
+ export { extend } from "./extend.js";
9
+ export { reconciler, flushSync } from "./reconciler.js";
8
10
  export type { GLProps, CameraProps, RenderProps } from "./configuration.js";
9
11
  export type { ReconcilerRoot } from "./root.js";
10
12
  export { _roots, createRoot, unmountComponentAtNode } from "./root.js";
@@ -14,4 +16,4 @@ export type { Subscription, Dpr, Size, Viewport, RenderCallback, Frameloop, Perf
14
16
  export { context } from "./store.js";
15
17
  export type { ObjectMap, Camera, Disposable, Act } from "./utils.js";
16
18
  export { applyProps, getRootState, dispose, act, buildGraph } from "./utils.js";
17
- export type { TrackedPromise } from "./promise.js";
19
+ export type { TrackedPromise } from "./utils/promise.js";
@@ -1,16 +1,13 @@
1
1
  import * as THREE from 'three';
2
- import * as React from 'react';
3
2
  import Reconciler from '../../react-reconciler/index.js';
4
3
  import { IsAllOptional } from "./utils.js";
5
4
  import type { RootStore } from "./store.js";
6
5
  import { type EventHandlers } from "./events.js";
7
- import type { ThreeElement } from "../three-types.js";
6
+ import { type ConstructorRepresentation } from "./extend.js";
7
+ export { extend } from "./extend.js";
8
+ export type { ConstructorRepresentation, Catalogue } from "./extend.js";
8
9
  export type AttachFnType<O = any> = (parent: any, self: O) => () => void;
9
10
  export type AttachType<O = any> = string | AttachFnType<O>;
10
- export type ConstructorRepresentation<T = any> = new (...args: any[]) => T;
11
- export interface Catalogue {
12
- [name: string]: ConstructorRepresentation;
13
- }
14
11
  export type Args<T> = T extends ConstructorRepresentation ? T extends typeof THREE.Color ? [r: number, g: number, b: number] | [color: THREE.ColorRepresentation] : ConstructorParameters<T> : any[];
15
12
  type ArgsProp<P> = P extends ConstructorRepresentation ? IsAllOptional<ConstructorParameters<P>> extends true ? {
16
13
  args?: Args<P>;
@@ -41,8 +38,6 @@ export interface Instance<O = any> {
41
38
  previousVisible: boolean | undefined;
42
39
  isHidden: boolean;
43
40
  }
44
- export declare function extend<T extends ConstructorRepresentation>(objects: T): React.ExoticComponent<ThreeElement<T>>;
45
- export declare function extend<T extends Catalogue>(objects: T): void;
46
41
  export declare const reconciler: Reconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
47
42
  /**
48
43
  * Force React to flush any updates inside the provided callback synchronously and immediately.
@@ -51,4 +46,3 @@ export declare const reconciler: Reconciler.Reconciler<RootStore, Instance<any>,
51
46
  * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
52
47
  */
53
48
  export declare function flushSync<R>(fn: () => R): R;
54
- export {};
@@ -0,0 +1,9 @@
1
+ /** Renderer creation and resource release. Root lifetime decides when release is safe. */
2
+ import * as THREE from 'three';
3
+ import type { DefaultGLProps, GLProps } from "./configuration.js";
4
+ import type { Renderer } from "./store.js";
5
+ export declare const isRenderer: (def: any) => boolean;
6
+ /** The renderer to configure, or a promise for one from an async factory */
7
+ export declare function createRenderer(canvas: DefaultGLProps['canvas'], gl?: GLProps): Renderer | PromiseLike<Renderer>;
8
+ /** Owned renderers are disposed. Caller-provided renderers release caches and their context. */
9
+ export declare function releaseRenderer(gl: THREE.WebGLRenderer | undefined, owned: boolean): void | Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type Reconciler from '../../react-reconciler/index.js';
3
3
  import { type AppliedConfiguration, type RenderProps } from "./configuration.js";
4
- import { type TrackedPromise } from "./promise.js";
4
+ import { type TrackedPromise } from "./utils/promise.js";
5
5
  import { type RootStore } from "./store.js";
6
6
  interface OffscreenCanvas extends EventTarget {
7
7
  }
@@ -14,6 +14,8 @@ export interface Root {
14
14
  configuration: AppliedConfiguration;
15
15
  /** Whether R3F built `gl` (from defaults, props or a factory) and so disposes it on unmount */
16
16
  ownsRenderer: boolean;
17
+ /** Stops following devicePixelRatio changes */
18
+ unwatchDpr?: () => void;
17
19
  }
18
20
  export declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
19
21
  export type RootStateMachine = {
@@ -49,7 +49,7 @@ export interface Performance {
49
49
  export interface Renderer {
50
50
  render: (scene: THREE.Scene, camera: THREE.Camera) => any;
51
51
  }
52
- export declare const isRenderer: (def: any) => boolean;
52
+ export { isRenderer } from "./renderer.js";
53
53
  export interface InternalState {
54
54
  interaction: THREE.Object3D[];
55
55
  hovered: Map<string, ThreeEvent<DomEvent>>;
@@ -0,0 +1,184 @@
1
+ import * as React from 'react';
2
+ export type Act = <T = any>(cb: () => Promise<T>) => Promise<T>;
3
+ /**
4
+ * Safely flush async effects when testing, simulating a legacy root.
5
+ * @deprecated Import from React instead. import { act } from 'react'
6
+ */
7
+ export declare const act: Act;
8
+ /**
9
+ * An SSR-friendly useLayoutEffect.
10
+ *
11
+ * React currently throws a warning when using useLayoutEffect on the server.
12
+ * To get around it, we can conditionally useEffect on the server (no-op) and
13
+ * useLayoutEffect elsewhere.
14
+ *
15
+ * @see https://github.com/facebook/react/issues/14927
16
+ */
17
+ export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
18
+ export declare function useMutableCallback<T>(fn: T): React.RefObject<T>;
19
+ /** Waits for a promise in a null subtree, re-rendering the caller once it settles either way. */
20
+ export declare function useGate(): [gate: React.ReactNode, waitFor: (promise: PromiseLike<unknown>) => void];
21
+ export type Bridge = React.FC<{
22
+ children?: React.ReactNode;
23
+ }>;
24
+ /**
25
+ * Bridges Context, StrictMode, and Activity visibility from a primary renderer.
26
+ */
27
+ export declare function useBridge(): Bridge;
28
+ export type SetBlock = false | Promise<null> | null;
29
+ export type UnblockProps = {
30
+ set: React.Dispatch<React.SetStateAction<SetBlock>>;
31
+ children: React.ReactNode;
32
+ };
33
+ export declare function Block({ set }: Omit<UnblockProps, 'children'>): null;
34
+ export declare const ErrorBoundary: {
35
+ new (props: {
36
+ set: React.Dispatch<Error | undefined>;
37
+ children: React.ReactNode;
38
+ }): {
39
+ state: {
40
+ error: boolean;
41
+ };
42
+ componentDidCatch(err: Error): void;
43
+ render(): React.ReactNode;
44
+ context: unknown;
45
+ setState<K extends "error">(state: {
46
+ error: boolean;
47
+ } | ((prevState: Readonly<{
48
+ error: boolean;
49
+ }>, props: Readonly<{
50
+ set: React.Dispatch<Error | undefined>;
51
+ children: React.ReactNode;
52
+ }>) => {
53
+ error: boolean;
54
+ } | Pick<{
55
+ error: boolean;
56
+ }, K> | null) | Pick<{
57
+ error: boolean;
58
+ }, K> | null, callback?: (() => void) | undefined): void;
59
+ forceUpdate(callback?: (() => void) | undefined): void;
60
+ readonly props: Readonly<{
61
+ set: React.Dispatch<Error | undefined>;
62
+ children: React.ReactNode;
63
+ }>;
64
+ componentDidMount?(): void;
65
+ shouldComponentUpdate?(nextProps: Readonly<{
66
+ set: React.Dispatch<Error | undefined>;
67
+ children: React.ReactNode;
68
+ }>, nextState: Readonly<{
69
+ error: boolean;
70
+ }>, nextContext: any): boolean;
71
+ componentWillUnmount?(): void;
72
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{
73
+ set: React.Dispatch<Error | undefined>;
74
+ children: React.ReactNode;
75
+ }>, prevState: Readonly<{
76
+ error: boolean;
77
+ }>): any;
78
+ componentDidUpdate?(prevProps: Readonly<{
79
+ set: React.Dispatch<Error | undefined>;
80
+ children: React.ReactNode;
81
+ }>, prevState: Readonly<{
82
+ error: boolean;
83
+ }>, snapshot?: any): void;
84
+ componentWillMount?(): void;
85
+ UNSAFE_componentWillMount?(): void;
86
+ componentWillReceiveProps?(nextProps: Readonly<{
87
+ set: React.Dispatch<Error | undefined>;
88
+ children: React.ReactNode;
89
+ }>, nextContext: any): void;
90
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
91
+ set: React.Dispatch<Error | undefined>;
92
+ children: React.ReactNode;
93
+ }>, nextContext: any): void;
94
+ componentWillUpdate?(nextProps: Readonly<{
95
+ set: React.Dispatch<Error | undefined>;
96
+ children: React.ReactNode;
97
+ }>, nextState: Readonly<{
98
+ error: boolean;
99
+ }>, nextContext: any): void;
100
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<{
101
+ set: React.Dispatch<Error | undefined>;
102
+ children: React.ReactNode;
103
+ }>, nextState: Readonly<{
104
+ error: boolean;
105
+ }>, nextContext: any): void;
106
+ };
107
+ new (props: {
108
+ set: React.Dispatch<Error | undefined>;
109
+ children: React.ReactNode;
110
+ }, context: any): {
111
+ state: {
112
+ error: boolean;
113
+ };
114
+ componentDidCatch(err: Error): void;
115
+ render(): React.ReactNode;
116
+ context: unknown;
117
+ setState<K extends "error">(state: {
118
+ error: boolean;
119
+ } | ((prevState: Readonly<{
120
+ error: boolean;
121
+ }>, props: Readonly<{
122
+ set: React.Dispatch<Error | undefined>;
123
+ children: React.ReactNode;
124
+ }>) => {
125
+ error: boolean;
126
+ } | Pick<{
127
+ error: boolean;
128
+ }, K> | null) | Pick<{
129
+ error: boolean;
130
+ }, K> | null, callback?: (() => void) | undefined): void;
131
+ forceUpdate(callback?: (() => void) | undefined): void;
132
+ readonly props: Readonly<{
133
+ set: React.Dispatch<Error | undefined>;
134
+ children: React.ReactNode;
135
+ }>;
136
+ componentDidMount?(): void;
137
+ shouldComponentUpdate?(nextProps: Readonly<{
138
+ set: React.Dispatch<Error | undefined>;
139
+ children: React.ReactNode;
140
+ }>, nextState: Readonly<{
141
+ error: boolean;
142
+ }>, nextContext: any): boolean;
143
+ componentWillUnmount?(): void;
144
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{
145
+ set: React.Dispatch<Error | undefined>;
146
+ children: React.ReactNode;
147
+ }>, prevState: Readonly<{
148
+ error: boolean;
149
+ }>): any;
150
+ componentDidUpdate?(prevProps: Readonly<{
151
+ set: React.Dispatch<Error | undefined>;
152
+ children: React.ReactNode;
153
+ }>, prevState: Readonly<{
154
+ error: boolean;
155
+ }>, snapshot?: any): void;
156
+ componentWillMount?(): void;
157
+ UNSAFE_componentWillMount?(): void;
158
+ componentWillReceiveProps?(nextProps: Readonly<{
159
+ set: React.Dispatch<Error | undefined>;
160
+ children: React.ReactNode;
161
+ }>, nextContext: any): void;
162
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
163
+ set: React.Dispatch<Error | undefined>;
164
+ children: React.ReactNode;
165
+ }>, nextContext: any): void;
166
+ componentWillUpdate?(nextProps: Readonly<{
167
+ set: React.Dispatch<Error | undefined>;
168
+ children: React.ReactNode;
169
+ }>, nextState: Readonly<{
170
+ error: boolean;
171
+ }>, nextContext: any): void;
172
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<{
173
+ set: React.Dispatch<Error | undefined>;
174
+ children: React.ReactNode;
175
+ }>, nextState: Readonly<{
176
+ error: boolean;
177
+ }>, nextContext: any): void;
178
+ };
179
+ getDerivedStateFromError: () => {
180
+ error: boolean;
181
+ };
182
+ contextType?: React.Context<any> | undefined;
183
+ propTypes?: any;
184
+ };
@@ -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 Context, StrictMode, and Activity visibility 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>;