@react-three/fiber 9.7.0 → 9.8.0

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-a79ef12b.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var reactNative = require('react-native');
@@ -190,45 +190,50 @@ function CanvasImpl({
190
190
  });
191
191
  setBind(responder.panHandlers);
192
192
  }, []);
193
+
194
+ // Waits for an async renderer without hiding the view
195
+ const [gate, waitFor] = events.useGate();
193
196
  events.useIsomorphicLayoutEffect(() => {
194
197
  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
- });
198
+ root.current.configure({
199
+ gl,
200
+ events: events$1,
201
+ shadows,
202
+ linear,
203
+ flat,
204
+ legacy,
205
+ orthographic,
206
+ frameloop,
207
+ performance,
208
+ raycaster,
209
+ camera,
210
+ scene,
211
+ // expo-gl can only render at native dpr/resolution
212
+ // https://github.com/expo/expo-three/issues/39
213
+ dpr: reactNative.PixelRatio.get(),
214
+ size: {
215
+ width,
216
+ height,
217
+ top,
218
+ left
219
+ },
220
+ // Pass mutable reference to onPointerMissed so it's free to update
221
+ onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
222
+ // Overwrite onCreated to apply RN bindings
223
+ onCreated: state => {
224
+ // Bind render to RN bridge
225
+ const context = state.gl.getContext();
226
+ const renderFrame = state.gl.render.bind(state.gl);
227
+ state.gl.render = (scene, camera) => {
228
+ renderFrame(scene, camera);
229
+ context.endFrameEXP();
230
+ };
231
+ return onCreated == null ? void 0 : onCreated(state);
232
+ }
233
+ }).catch(setError);
234
+
235
+ // Pending re-runs this effect once the renderer lands. Rejected is reported by the catch
236
+ if (root.current.ready.status === 'fulfilled') {
232
237
  root.current.render( /*#__PURE__*/jsxRuntime.jsx(Bridge, {
233
238
  children: /*#__PURE__*/jsxRuntime.jsx(events.ErrorBoundary, {
234
239
  set: setError,
@@ -240,8 +245,9 @@ function CanvasImpl({
240
245
  })
241
246
  })
242
247
  }));
248
+ } else if (root.current.ready.status === 'pending') {
249
+ waitFor(root.current.ready);
243
250
  }
244
- run();
245
251
  }
246
252
  });
247
253
  React__namespace.useEffect(() => {
@@ -265,7 +271,7 @@ function CanvasImpl({
265
271
  style: reactNative.StyleSheet.absoluteFill,
266
272
  pointerEvents: pointerEvents,
267
273
  ...bind
268
- })]
274
+ }), gate]
269
275
  });
270
276
  }
271
277
 
@@ -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, f as unmountComponentAtNode, g as createPointerEvents, h as createEvents } from '../../dist/events-803f4abc.esm.js';
2
+ export { t as ReactThreeFiber, _ as _roots, y as act, l as addAfterEffect, k as addEffect, m as addTail, o as advance, v as applyProps, z as buildGraph, s as context, h as createEvents, p as createPortal, d as createRoot, x as dispose, e as extend, j as flushGlobalEffects, q as flushSync, w as getRootState, n as invalidate, r as reconciler, f as unmountComponentAtNode, F as useFrame, G as useGraph, A as useInstanceHandle, H as useLoader, C as useStore, D as useThree } from '../../dist/events-803f4abc.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';
@@ -166,45 +166,50 @@ function CanvasImpl({
166
166
  });
167
167
  setBind(responder.panHandlers);
168
168
  }, []);
169
+
170
+ // Waits for an async renderer without hiding the view
171
+ const [gate, waitFor] = useGate();
169
172
  useIsomorphicLayoutEffect(() => {
170
173
  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
- });
174
+ root.current.configure({
175
+ gl,
176
+ events,
177
+ shadows,
178
+ linear,
179
+ flat,
180
+ legacy,
181
+ orthographic,
182
+ frameloop,
183
+ performance,
184
+ raycaster,
185
+ camera,
186
+ scene,
187
+ // expo-gl can only render at native dpr/resolution
188
+ // https://github.com/expo/expo-three/issues/39
189
+ dpr: PixelRatio.get(),
190
+ size: {
191
+ width,
192
+ height,
193
+ top,
194
+ left
195
+ },
196
+ // Pass mutable reference to onPointerMissed so it's free to update
197
+ onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
198
+ // Overwrite onCreated to apply RN bindings
199
+ onCreated: state => {
200
+ // Bind render to RN bridge
201
+ const context = state.gl.getContext();
202
+ const renderFrame = state.gl.render.bind(state.gl);
203
+ state.gl.render = (scene, camera) => {
204
+ renderFrame(scene, camera);
205
+ context.endFrameEXP();
206
+ };
207
+ return onCreated == null ? void 0 : onCreated(state);
208
+ }
209
+ }).catch(setError);
210
+
211
+ // Pending re-runs this effect once the renderer lands. Rejected is reported by the catch
212
+ if (root.current.ready.status === 'fulfilled') {
208
213
  root.current.render( /*#__PURE__*/jsx(Bridge, {
209
214
  children: /*#__PURE__*/jsx(ErrorBoundary, {
210
215
  set: setError,
@@ -216,8 +221,9 @@ function CanvasImpl({
216
221
  })
217
222
  })
218
223
  }));
224
+ } else if (root.current.ready.status === 'pending') {
225
+ waitFor(root.current.ready);
219
226
  }
220
- run();
221
227
  }
222
228
  });
223
229
  React.useEffect(() => {
@@ -241,7 +247,7 @@ function CanvasImpl({
241
247
  style: StyleSheet.absoluteFill,
242
248
  pointerEvents: pointerEvents,
243
249
  ...bind
244
- })]
250
+ }), gate]
245
251
  });
246
252
  }
247
253
 
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.0",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -43,8 +43,8 @@
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",
@@ -53,7 +53,7 @@
53
53
  "buffer": "^6.0.3",
54
54
  "its-fine": "^2.0.0",
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;