@react-three/fiber 9.7.0 → 9.8.1

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var events = require('../../dist/events-4c71f21f.cjs.prod.js');
5
+ var events = require('../../dist/events-a816cbab.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var reactNative = require('react-native');
@@ -80,6 +80,7 @@ function CanvasImpl({
80
80
  const [bind, setBind] = React__namespace.useState();
81
81
  React__namespace.useImperativeHandle(ref, () => viewRef.current);
82
82
  const handlePointerMissed = events.useMutableCallback(onPointerMissed);
83
+ const pointerMissed = React__namespace.useCallback(event => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(event), [handlePointerMissed]);
83
84
  const [block, setBlock] = React__namespace.useState(false);
84
85
  const [error, setError] = React__namespace.useState(undefined);
85
86
 
@@ -190,45 +191,50 @@ function CanvasImpl({
190
191
  });
191
192
  setBind(responder.panHandlers);
192
193
  }, []);
194
+
195
+ // Waits for an async renderer without hiding the view
196
+ const [gate, waitFor] = events.useGate();
193
197
  events.useIsomorphicLayoutEffect(() => {
194
198
  if (root.current && width > 0 && height > 0) {
195
- async function run() {
196
- await root.current.configure({
197
- gl,
198
- events: events$1,
199
- shadows,
200
- linear,
201
- flat,
202
- legacy,
203
- orthographic,
204
- frameloop,
205
- performance,
206
- raycaster,
207
- camera,
208
- scene,
209
- // expo-gl can only render at native dpr/resolution
210
- // https://github.com/expo/expo-three/issues/39
211
- dpr: reactNative.PixelRatio.get(),
212
- size: {
213
- width,
214
- height,
215
- top,
216
- left
217
- },
218
- // Pass mutable reference to onPointerMissed so it's free to update
219
- onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
220
- // Overwrite onCreated to apply RN bindings
221
- onCreated: state => {
222
- // Bind render to RN bridge
223
- const context = state.gl.getContext();
224
- const renderFrame = state.gl.render.bind(state.gl);
225
- state.gl.render = (scene, camera) => {
226
- renderFrame(scene, camera);
227
- context.endFrameEXP();
228
- };
229
- return onCreated == null ? void 0 : onCreated(state);
230
- }
231
- });
199
+ root.current.configure({
200
+ gl,
201
+ events: events$1,
202
+ shadows,
203
+ linear,
204
+ flat,
205
+ legacy,
206
+ orthographic,
207
+ frameloop,
208
+ performance,
209
+ raycaster,
210
+ camera,
211
+ scene,
212
+ // expo-gl can only render at native dpr/resolution
213
+ // https://github.com/expo/expo-three/issues/39
214
+ dpr: reactNative.PixelRatio.get(),
215
+ size: {
216
+ width,
217
+ height,
218
+ top,
219
+ left
220
+ },
221
+ // Forwards to the latest onPointerMissed, so a new callback does not update the store
222
+ onPointerMissed: pointerMissed,
223
+ // Overwrite onCreated to apply RN bindings
224
+ onCreated: state => {
225
+ // Bind render to RN bridge
226
+ const context = state.gl.getContext();
227
+ const renderFrame = state.gl.render.bind(state.gl);
228
+ state.gl.render = (scene, camera) => {
229
+ renderFrame(scene, camera);
230
+ context.endFrameEXP();
231
+ };
232
+ return onCreated == null ? void 0 : onCreated(state);
233
+ }
234
+ }).catch(setError);
235
+
236
+ // Pending re-runs this effect once the renderer lands. Rejected is reported by the catch
237
+ if (root.current.ready.status === 'fulfilled') {
232
238
  root.current.render( /*#__PURE__*/jsxRuntime.jsx(Bridge, {
233
239
  children: /*#__PURE__*/jsxRuntime.jsx(events.ErrorBoundary, {
234
240
  set: setError,
@@ -240,8 +246,9 @@ function CanvasImpl({
240
246
  })
241
247
  })
242
248
  }));
249
+ } else if (root.current.ready.status === 'pending') {
250
+ waitFor(root.current.ready);
243
251
  }
244
- run();
245
252
  }
246
253
  });
247
254
  React__namespace.useEffect(() => {
@@ -265,7 +272,7 @@ function CanvasImpl({
265
272
  style: reactNative.StyleSheet.absoluteFill,
266
273
  pointerEvents: pointerEvents,
267
274
  ...bind
268
- })]
275
+ }), gate]
269
276
  });
270
277
  }
271
278
 
@@ -1,5 +1,5 @@
1
- import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, b as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-156d8d12.esm.js';
2
- export { t as ReactThreeFiber, _ as _roots, x as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, s as applyProps, y as buildGraph, q as context, g as createEvents, o as createPortal, c as createRoot, w as dispose, e as extend, h as flushGlobalEffects, p as flushSync, v as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, D as useFrame, F as useGraph, z as useInstanceHandle, G as useLoader, A as useStore, C as useThree } from '../../dist/events-156d8d12.esm.js';
1
+ import { e as extend, u as useBridge, a as useMutableCallback, d as createRoot, b as useGate, c as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, p as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-9ce18a08.esm.js';
2
+ export { t as ReactThreeFiber, _ as _roots, y as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, v as applyProps, z as buildGraph, s as context, g as createEvents, q as createPortal, d as createRoot, x as dispose, e as extend, h as flushGlobalEffects, o as flushSync, w as getRootState, m as invalidate, r as reconciler, p as unmountComponentAtNode, F as useFrame, G as useGraph, A as useInstanceHandle, H as useLoader, C as useStore, D as useThree } from '../../dist/events-9ce18a08.esm.js';
3
3
  import * as React from 'react';
4
4
  import * as THREE from 'three';
5
5
  import { PanResponder, PixelRatio, StyleSheet, View, Platform, Image, NativeModules } from 'react-native';
@@ -56,6 +56,7 @@ function CanvasImpl({
56
56
  const [bind, setBind] = React.useState();
57
57
  React.useImperativeHandle(ref, () => viewRef.current);
58
58
  const handlePointerMissed = useMutableCallback(onPointerMissed);
59
+ const pointerMissed = React.useCallback(event => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(event), [handlePointerMissed]);
59
60
  const [block, setBlock] = React.useState(false);
60
61
  const [error, setError] = React.useState(undefined);
61
62
 
@@ -166,45 +167,50 @@ function CanvasImpl({
166
167
  });
167
168
  setBind(responder.panHandlers);
168
169
  }, []);
170
+
171
+ // Waits for an async renderer without hiding the view
172
+ const [gate, waitFor] = useGate();
169
173
  useIsomorphicLayoutEffect(() => {
170
174
  if (root.current && width > 0 && height > 0) {
171
- async function run() {
172
- await root.current.configure({
173
- gl,
174
- events,
175
- shadows,
176
- linear,
177
- flat,
178
- legacy,
179
- orthographic,
180
- frameloop,
181
- performance,
182
- raycaster,
183
- camera,
184
- scene,
185
- // expo-gl can only render at native dpr/resolution
186
- // https://github.com/expo/expo-three/issues/39
187
- dpr: PixelRatio.get(),
188
- size: {
189
- width,
190
- height,
191
- top,
192
- left
193
- },
194
- // Pass mutable reference to onPointerMissed so it's free to update
195
- onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
196
- // Overwrite onCreated to apply RN bindings
197
- onCreated: state => {
198
- // Bind render to RN bridge
199
- const context = state.gl.getContext();
200
- const renderFrame = state.gl.render.bind(state.gl);
201
- state.gl.render = (scene, camera) => {
202
- renderFrame(scene, camera);
203
- context.endFrameEXP();
204
- };
205
- return onCreated == null ? void 0 : onCreated(state);
206
- }
207
- });
175
+ root.current.configure({
176
+ gl,
177
+ events,
178
+ shadows,
179
+ linear,
180
+ flat,
181
+ legacy,
182
+ orthographic,
183
+ frameloop,
184
+ performance,
185
+ raycaster,
186
+ camera,
187
+ scene,
188
+ // expo-gl can only render at native dpr/resolution
189
+ // https://github.com/expo/expo-three/issues/39
190
+ dpr: PixelRatio.get(),
191
+ size: {
192
+ width,
193
+ height,
194
+ top,
195
+ left
196
+ },
197
+ // Forwards to the latest onPointerMissed, so a new callback does not update the store
198
+ onPointerMissed: pointerMissed,
199
+ // Overwrite onCreated to apply RN bindings
200
+ onCreated: state => {
201
+ // Bind render to RN bridge
202
+ const context = state.gl.getContext();
203
+ const renderFrame = state.gl.render.bind(state.gl);
204
+ state.gl.render = (scene, camera) => {
205
+ renderFrame(scene, camera);
206
+ context.endFrameEXP();
207
+ };
208
+ return onCreated == null ? void 0 : onCreated(state);
209
+ }
210
+ }).catch(setError);
211
+
212
+ // Pending re-runs this effect once the renderer lands. Rejected is reported by the catch
213
+ if (root.current.ready.status === 'fulfilled') {
208
214
  root.current.render( /*#__PURE__*/jsx(Bridge, {
209
215
  children: /*#__PURE__*/jsx(ErrorBoundary, {
210
216
  set: setError,
@@ -216,8 +222,9 @@ function CanvasImpl({
216
222
  })
217
223
  })
218
224
  }));
225
+ } else if (root.current.ready.status === 'pending') {
226
+ waitFor(root.current.ready);
219
227
  }
220
- run();
221
228
  }
222
229
  });
223
230
  React.useEffect(() => {
@@ -241,7 +248,7 @@ function CanvasImpl({
241
248
  style: StyleSheet.absoluteFill,
242
249
  pointerEvents: pointerEvents,
243
250
  ...bind
244
- })]
251
+ }), gate]
245
252
  });
246
253
  }
247
254
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "9.7.0",
3
+ "version": "9.8.1",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -43,17 +43,17 @@
43
43
  "prebuild": "cp ../../readme.md readme.md"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/react-reconciler": "^0.32.3",
47
- "react-reconciler": "^0.33.0"
46
+ "@types/react-reconciler": "^0.33.0",
47
+ "react-reconciler": "^0.34.0"
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.17.8",
51
51
  "@types/webxr": "*",
52
52
  "base64-js": "^1.5.1",
53
53
  "buffer": "^6.0.3",
54
- "its-fine": "^2.0.0",
54
+ "its-fine": "^2.1.1",
55
55
  "react-use-measure": "^2.1.7",
56
- "scheduler": "^0.27.0",
56
+ "scheduler": "^0.28.0",
57
57
  "suspend-react": "^0.1.3",
58
58
  "use-sync-external-store": "^1.4.0",
59
59
  "zustand": "^5.0.3"
@@ -63,8 +63,8 @@
63
63
  "expo-asset": ">=8.4",
64
64
  "expo-file-system": ">=11.0",
65
65
  "expo-gl": ">=11.0",
66
- "react": ">=19 <19.3",
67
- "react-dom": ">=19 <19.3",
66
+ "react": ">=19 <19.4",
67
+ "react-dom": ">=19 <19.4",
68
68
  "react-native": ">=0.78",
69
69
  "three": ">=0.156"
70
70
  },
@@ -610,7 +610,8 @@ declare namespace ReactReconciler {
610
610
  type LanePriority = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17;
611
611
 
612
612
  type Lanes = number;
613
- type Lane = number;
613
+
614
+ type Lane = number & { __LaneBrand: any };
614
615
 
615
616
  type Flags = number;
616
617
 
@@ -941,7 +942,6 @@ declare namespace ReactReconciler {
941
942
  onCaughtError: (error: Error, info: BaseErrorInfo) => void,
942
943
  onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
943
944
  onDefaultTransitionIndicator: () => void,
944
- transitionCallbacks: null | TransitionTracingCallbacks,
945
945
  ): OpaqueRoot;
946
946
 
947
947
  createPortal(
@@ -951,8 +951,6 @@ declare namespace ReactReconciler {
951
951
  key?: string | null,
952
952
  ): ReactPortal;
953
953
 
954
- registerMutableSourceForHydration(root: FiberRoot, mutableSource: MutableSource): void;
955
-
956
954
  createComponentSelector(component: React$AbstractComponent<never, unknown>): ComponentSelector;
957
955
 
958
956
  createHasPseudoClassSelector(selectors: Selector[]): HasPseudoClassSelector;
@@ -987,8 +985,12 @@ declare namespace ReactReconciler {
987
985
  isStrictMode: boolean,
988
986
  concurrentUpdatesByDefaultOverride: null | boolean,
989
987
  identifierPrefix: string,
990
- onRecoverableError: (error: Error) => void,
988
+ onUncaughtError: (error: Error, info: BaseErrorInfo & { errorBoundary?: Component }) => void,
989
+ onCaughtError: (error: Error, info: BaseErrorInfo) => void,
990
+ onRecoverableError: (error: Error, info: BaseErrorInfo) => void,
991
+ onDefaultTransitionIndicator: () => void,
991
992
  transitionCallbacks: null | TransitionTracingCallbacks,
993
+ formState: unknown,
992
994
  ): OpaqueRoot;
993
995
 
994
996
  updateContainer(
@@ -998,17 +1000,27 @@ declare namespace ReactReconciler {
998
1000
  callback?: (() => void) | null,
999
1001
  ): Lane;
1000
1002
 
1003
+ updateContainerSync(
1004
+ element: ReactNode,
1005
+ container: OpaqueRoot,
1006
+ parentComponent?: Component<any, any> | null,
1007
+ callback?: (() => void) | null,
1008
+ ): Lane;
1009
+
1001
1010
  batchedUpdates<A, R>(fn: (a: A) => R, a: A): R;
1002
1011
 
1003
1012
  deferredUpdates<A>(fn: () => A): A;
1004
1013
 
1005
1014
  discreteUpdates<A, B, C, D, R>(fn: (arg0: A, arg1: B, arg2: C, arg3: D) => R, a: A, b: B, c: C, d: D): R;
1006
1015
 
1007
- flushControlled(fn: () => any): void;
1008
-
1009
1016
  flushSync(): void;
1010
1017
  flushSync<R>(fn: () => R): R;
1011
1018
 
1019
+ flushSyncFromReconciler(): void;
1020
+ flushSyncFromReconciler<R>(fn: () => R): R;
1021
+
1022
+ flushSyncWork(): boolean;
1023
+
1012
1024
  isAlreadyRendering(): boolean;
1013
1025
 
1014
1026
  flushPassiveEffects(): boolean;
@@ -1017,16 +1029,10 @@ declare namespace ReactReconciler {
1017
1029
 
1018
1030
  attemptSynchronousHydration(fiber: Fiber): void;
1019
1031
 
1020
- attemptDiscreteHydration(fiber: Fiber): void;
1021
-
1022
1032
  attemptContinuousHydration(fiber: Fiber): void;
1023
1033
 
1024
1034
  attemptHydrationAtCurrentPriority(fiber: Fiber): void;
1025
1035
 
1026
- getCurrentUpdatePriority(): LanePriority;
1027
-
1028
- runWithPriority<T>(priority: LanePriority, fn: () => T): T;
1029
-
1030
1036
  findHostInstance(component: any): PublicInstance | null;
1031
1037
 
1032
1038
  findHostInstanceWithWarning(component: any, methodName: string): PublicInstance | null;
@@ -1039,6 +1045,17 @@ declare namespace ReactReconciler {
1039
1045
 
1040
1046
  injectIntoDevTools(devToolsConfig: DevToolsConfig<Instance, TextInstance, any>): boolean;
1041
1047
  }
1048
+
1049
+ function defaultOnUncaughtError(error: Error): void;
1050
+ function defaultOnCaughtError(error: Error): void;
1051
+ function defaultOnRecoverableError(error: Error): void;
1052
+
1053
+ function startHostTransition(
1054
+ formFiber: Fiber,
1055
+ pendingState: unknown,
1056
+ action: ((formData: FormData) => void) | null,
1057
+ formData: FormData,
1058
+ ): void;
1042
1059
  }
1043
1060
 
1044
1061
  export = ReactReconciler;