@react-three/fiber 9.0.0-alpha.6 → 9.0.0-alpha.7

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,11 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.16.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 03ab82fe: fix(applyProps): null check indeterminate instances
8
+
3
9
  ## 8.16.5
4
10
 
5
11
  ### Patch Changes
@@ -4,6 +4,9 @@ import Reconciler from 'react-reconciler';
4
4
  import type { RootStore } from "./store.js";
5
5
  import { type EventHandlers } from "./events.js";
6
6
  import type { ThreeElement } from "../three-types.js";
7
+ declare module 'react-reconciler/constants' {
8
+ const NoEventPriority = 0;
9
+ }
7
10
  export interface Root {
8
11
  fiber: Reconciler.FiberRoot;
9
12
  store: RootStore;
@@ -39,5 +42,5 @@ export interface Instance<O = any> {
39
42
  autoRemovedBeforeAppend?: boolean;
40
43
  }
41
44
  export declare const catalogue: Catalogue;
42
- export declare const extend: <T extends Catalogue | ConstructorRepresentation<any>>(objects: T) => T extends ConstructorRepresentation<any> ? React.ExoticComponent<import("../three-types.js").Mutable<import("../three-types.js").Overwrite<Partial<import("../three-types.js").Overwrite<import("../three-types.js").WithMathProps<InstanceType<T>>, import("../three-types.js").ReactProps<InstanceType<T>> & import("../three-types.js").EventProps<InstanceType<T>>>>, Omit<InstanceProps<InstanceType<T>, T>, "object">>>> : void;
45
+ export declare const extend: <T extends ConstructorRepresentation<any> | Catalogue>(objects: T) => T extends ConstructorRepresentation<any> ? React.ExoticComponent<import("../three-types.js").Mutable<import("../three-types.js").Overwrite<Partial<import("../three-types.js").Overwrite<import("../three-types.js").WithMathProps<InstanceType<T>>, import("../three-types.js").ReactProps<InstanceType<T>> & import("../three-types.js").EventProps<InstanceType<T>>>>, Omit<InstanceProps<InstanceType<T>, T>, "object">>>> : void;
43
46
  export declare const reconciler: Reconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, any>;
@@ -10,7 +10,7 @@ export declare function findInitialRoot<T>(instance: Instance<T>): RootStore;
10
10
  /**
11
11
  * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
12
12
  */
13
- export declare const hasColorSpace: <T extends object | Renderer | THREE.Texture, P = T extends Renderer ? {
13
+ export declare const hasColorSpace: <T extends object | THREE.Texture | Renderer, P = T extends Renderer ? {
14
14
  outputColorSpace: string;
15
15
  } : {
16
16
  colorSpace: string;
@@ -12,6 +12,12 @@ var threeTypes = /*#__PURE__*/Object.freeze({
12
12
  __proto__: null
13
13
  });
14
14
 
15
+ const createReconciler = Reconciler;
16
+
17
+ // TODO: handle constructor overloads
18
+ // https://github.com/pmndrs/react-three-fiber/pull/2931
19
+ // https://github.com/microsoft/TypeScript/issues/37079
20
+
15
21
  const catalogue = {};
16
22
  let i = 0;
17
23
  const extend = objects => {
@@ -266,7 +272,7 @@ function switchInstance(oldInstance, type, props, fiber) {
266
272
  const handleTextInstance = () => console.warn('R3F: Text is not allowed in JSX! This could be stray whitespace or characters.');
267
273
  const NO_CONTEXT = {};
268
274
  let currentUpdatePriority = NoEventPriority;
269
- const reconciler = Reconciler({
275
+ const reconciler = createReconciler({
270
276
  isPrimaryRenderer: false,
271
277
  warnsIfNotActing: false,
272
278
  supportsMutation: true,
@@ -296,7 +302,6 @@ const reconciler = Reconciler({
296
302
  },
297
303
  getRootHostContext: () => NO_CONTEXT,
298
304
  getChildHostContext: () => NO_CONTEXT,
299
- // @ts-expect-error prepareUpdate and updatePayload removed with React 19
300
305
  commitUpdate(instance, type, oldProps, newProps, fiber) {
301
306
  var _newProps$args, _oldProps$args, _newProps$args2;
302
307
  let reconstruct = false;
@@ -343,8 +348,8 @@ const reconciler = Reconciler({
343
348
  beforeActiveInstanceBlur() {},
344
349
  afterActiveInstanceBlur() {},
345
350
  detachDeletedInstance() {},
346
- // TODO: add shell types for these and upstream to DefinitelyTyped
347
- // https://github.com/facebook/react/blob/main/packages/react-art/src/ReactFiberConfigART.js
351
+ prepareScopeUpdate() {},
352
+ getInstanceFromScope: () => null,
348
353
  shouldAttemptEagerTransition() {
349
354
  return false;
350
355
  },
@@ -388,7 +393,8 @@ const reconciler = Reconciler({
388
393
  default:
389
394
  return DefaultEventPriority;
390
395
  }
391
- }
396
+ },
397
+ resetFormInstance() {}
392
398
  });
393
399
 
394
400
  var _window$document, _window$navigator;
@@ -1982,9 +1988,11 @@ function createRoot(canvas) {
1982
1988
  applyProps(camera, cameraOptions);
1983
1989
  // Preserve user-defined frustum if possible
1984
1990
  // https://github.com/pmndrs/react-three-fiber/issues/3160
1985
- if ('aspect' in cameraOptions || 'left' in cameraOptions || 'right' in cameraOptions || 'bottom' in cameraOptions || 'top' in cameraOptions) {
1986
- camera.manual = true;
1987
- camera.updateProjectionMatrix();
1991
+ if (!camera.manual) {
1992
+ if ('aspect' in cameraOptions || 'left' in cameraOptions || 'right' in cameraOptions || 'bottom' in cameraOptions || 'top' in cameraOptions) {
1993
+ camera.manual = true;
1994
+ camera.updateProjectionMatrix();
1995
+ }
1988
1996
  }
1989
1997
  }
1990
1998
  // Always look at center by default
@@ -2239,7 +2247,7 @@ function Portal({
2239
2247
  const [raycaster] = React.useState(() => new THREE.Raycaster());
2240
2248
  const [pointer] = React.useState(() => new THREE.Vector2());
2241
2249
  const inject = useMutableCallback((rootState, injectState) => {
2242
- let viewport;
2250
+ let viewport = undefined;
2243
2251
  if (injectState.camera && size) {
2244
2252
  const camera = injectState.camera;
2245
2253
  // Calculate the override viewport, if present
@@ -2250,8 +2258,7 @@ function Portal({
2250
2258
  return {
2251
2259
  // The intersect consists of the previous root state
2252
2260
  ...rootState,
2253
- get: injectState.get,
2254
- set: injectState.set,
2261
+ ...injectState,
2255
2262
  // Portals have their own scene, which forms the root, a raycaster and a pointer
2256
2263
  scene: container,
2257
2264
  raycaster,
@@ -2284,6 +2291,7 @@ function Portal({
2284
2291
  };
2285
2292
  });
2286
2293
  const usePortalStore = React.useMemo(() => {
2294
+ // Create a mirrored store, based on the previous root with a few overrides ...
2287
2295
  const store = createWithEqualityFn((set, get) => ({
2288
2296
  ...rest,
2289
2297
  set,
@@ -38,6 +38,12 @@ var threeTypes = /*#__PURE__*/Object.freeze({
38
38
  __proto__: null
39
39
  });
40
40
 
41
+ const createReconciler = Reconciler__default["default"];
42
+
43
+ // TODO: handle constructor overloads
44
+ // https://github.com/pmndrs/react-three-fiber/pull/2931
45
+ // https://github.com/microsoft/TypeScript/issues/37079
46
+
41
47
  const catalogue = {};
42
48
  let i = 0;
43
49
  const extend = objects => {
@@ -292,7 +298,7 @@ function switchInstance(oldInstance, type, props, fiber) {
292
298
  const handleTextInstance = () => console.warn('R3F: Text is not allowed in JSX! This could be stray whitespace or characters.');
293
299
  const NO_CONTEXT = {};
294
300
  let currentUpdatePriority = constants.NoEventPriority;
295
- const reconciler = Reconciler__default["default"]({
301
+ const reconciler = createReconciler({
296
302
  isPrimaryRenderer: false,
297
303
  warnsIfNotActing: false,
298
304
  supportsMutation: true,
@@ -322,7 +328,6 @@ const reconciler = Reconciler__default["default"]({
322
328
  },
323
329
  getRootHostContext: () => NO_CONTEXT,
324
330
  getChildHostContext: () => NO_CONTEXT,
325
- // @ts-expect-error prepareUpdate and updatePayload removed with React 19
326
331
  commitUpdate(instance, type, oldProps, newProps, fiber) {
327
332
  var _newProps$args, _oldProps$args, _newProps$args2;
328
333
  let reconstruct = false;
@@ -369,8 +374,8 @@ const reconciler = Reconciler__default["default"]({
369
374
  beforeActiveInstanceBlur() {},
370
375
  afterActiveInstanceBlur() {},
371
376
  detachDeletedInstance() {},
372
- // TODO: add shell types for these and upstream to DefinitelyTyped
373
- // https://github.com/facebook/react/blob/main/packages/react-art/src/ReactFiberConfigART.js
377
+ prepareScopeUpdate() {},
378
+ getInstanceFromScope: () => null,
374
379
  shouldAttemptEagerTransition() {
375
380
  return false;
376
381
  },
@@ -414,7 +419,8 @@ const reconciler = Reconciler__default["default"]({
414
419
  default:
415
420
  return constants.DefaultEventPriority;
416
421
  }
417
- }
422
+ },
423
+ resetFormInstance() {}
418
424
  });
419
425
 
420
426
  var _window$document, _window$navigator;
@@ -2008,9 +2014,11 @@ function createRoot(canvas) {
2008
2014
  applyProps(camera, cameraOptions);
2009
2015
  // Preserve user-defined frustum if possible
2010
2016
  // https://github.com/pmndrs/react-three-fiber/issues/3160
2011
- if ('aspect' in cameraOptions || 'left' in cameraOptions || 'right' in cameraOptions || 'bottom' in cameraOptions || 'top' in cameraOptions) {
2012
- camera.manual = true;
2013
- camera.updateProjectionMatrix();
2017
+ if (!camera.manual) {
2018
+ if ('aspect' in cameraOptions || 'left' in cameraOptions || 'right' in cameraOptions || 'bottom' in cameraOptions || 'top' in cameraOptions) {
2019
+ camera.manual = true;
2020
+ camera.updateProjectionMatrix();
2021
+ }
2014
2022
  }
2015
2023
  }
2016
2024
  // Always look at center by default
@@ -2265,7 +2273,7 @@ function Portal({
2265
2273
  const [raycaster] = React__namespace.useState(() => new THREE__namespace.Raycaster());
2266
2274
  const [pointer] = React__namespace.useState(() => new THREE__namespace.Vector2());
2267
2275
  const inject = useMutableCallback((rootState, injectState) => {
2268
- let viewport;
2276
+ let viewport = undefined;
2269
2277
  if (injectState.camera && size) {
2270
2278
  const camera = injectState.camera;
2271
2279
  // Calculate the override viewport, if present
@@ -2276,8 +2284,7 @@ function Portal({
2276
2284
  return {
2277
2285
  // The intersect consists of the previous root state
2278
2286
  ...rootState,
2279
- get: injectState.get,
2280
- set: injectState.set,
2287
+ ...injectState,
2281
2288
  // Portals have their own scene, which forms the root, a raycaster and a pointer
2282
2289
  scene: container,
2283
2290
  raycaster,
@@ -2310,6 +2317,7 @@ function Portal({
2310
2317
  };
2311
2318
  });
2312
2319
  const usePortalStore = React__namespace.useMemo(() => {
2320
+ // Create a mirrored store, based on the previous root with a few overrides ...
2313
2321
  const store = traditional.createWithEqualityFn((set, get) => ({
2314
2322
  ...rest,
2315
2323
  set,
@@ -38,6 +38,12 @@ var threeTypes = /*#__PURE__*/Object.freeze({
38
38
  __proto__: null
39
39
  });
40
40
 
41
+ const createReconciler = Reconciler__default["default"];
42
+
43
+ // TODO: handle constructor overloads
44
+ // https://github.com/pmndrs/react-three-fiber/pull/2931
45
+ // https://github.com/microsoft/TypeScript/issues/37079
46
+
41
47
  const catalogue = {};
42
48
  let i = 0;
43
49
  const extend = objects => {
@@ -292,7 +298,7 @@ function switchInstance(oldInstance, type, props, fiber) {
292
298
  const handleTextInstance = () => console.warn('R3F: Text is not allowed in JSX! This could be stray whitespace or characters.');
293
299
  const NO_CONTEXT = {};
294
300
  let currentUpdatePriority = constants.NoEventPriority;
295
- const reconciler = Reconciler__default["default"]({
301
+ const reconciler = createReconciler({
296
302
  isPrimaryRenderer: false,
297
303
  warnsIfNotActing: false,
298
304
  supportsMutation: true,
@@ -322,7 +328,6 @@ const reconciler = Reconciler__default["default"]({
322
328
  },
323
329
  getRootHostContext: () => NO_CONTEXT,
324
330
  getChildHostContext: () => NO_CONTEXT,
325
- // @ts-expect-error prepareUpdate and updatePayload removed with React 19
326
331
  commitUpdate(instance, type, oldProps, newProps, fiber) {
327
332
  var _newProps$args, _oldProps$args, _newProps$args2;
328
333
  let reconstruct = false;
@@ -369,8 +374,8 @@ const reconciler = Reconciler__default["default"]({
369
374
  beforeActiveInstanceBlur() {},
370
375
  afterActiveInstanceBlur() {},
371
376
  detachDeletedInstance() {},
372
- // TODO: add shell types for these and upstream to DefinitelyTyped
373
- // https://github.com/facebook/react/blob/main/packages/react-art/src/ReactFiberConfigART.js
377
+ prepareScopeUpdate() {},
378
+ getInstanceFromScope: () => null,
374
379
  shouldAttemptEagerTransition() {
375
380
  return false;
376
381
  },
@@ -414,7 +419,8 @@ const reconciler = Reconciler__default["default"]({
414
419
  default:
415
420
  return constants.DefaultEventPriority;
416
421
  }
417
- }
422
+ },
423
+ resetFormInstance() {}
418
424
  });
419
425
 
420
426
  var _window$document, _window$navigator;
@@ -2008,9 +2014,11 @@ function createRoot(canvas) {
2008
2014
  applyProps(camera, cameraOptions);
2009
2015
  // Preserve user-defined frustum if possible
2010
2016
  // https://github.com/pmndrs/react-three-fiber/issues/3160
2011
- if ('aspect' in cameraOptions || 'left' in cameraOptions || 'right' in cameraOptions || 'bottom' in cameraOptions || 'top' in cameraOptions) {
2012
- camera.manual = true;
2013
- camera.updateProjectionMatrix();
2017
+ if (!camera.manual) {
2018
+ if ('aspect' in cameraOptions || 'left' in cameraOptions || 'right' in cameraOptions || 'bottom' in cameraOptions || 'top' in cameraOptions) {
2019
+ camera.manual = true;
2020
+ camera.updateProjectionMatrix();
2021
+ }
2014
2022
  }
2015
2023
  }
2016
2024
  // Always look at center by default
@@ -2265,7 +2273,7 @@ function Portal({
2265
2273
  const [raycaster] = React__namespace.useState(() => new THREE__namespace.Raycaster());
2266
2274
  const [pointer] = React__namespace.useState(() => new THREE__namespace.Vector2());
2267
2275
  const inject = useMutableCallback((rootState, injectState) => {
2268
- let viewport;
2276
+ let viewport = undefined;
2269
2277
  if (injectState.camera && size) {
2270
2278
  const camera = injectState.camera;
2271
2279
  // Calculate the override viewport, if present
@@ -2276,8 +2284,7 @@ function Portal({
2276
2284
  return {
2277
2285
  // The intersect consists of the previous root state
2278
2286
  ...rootState,
2279
- get: injectState.get,
2280
- set: injectState.set,
2287
+ ...injectState,
2281
2288
  // Portals have their own scene, which forms the root, a raycaster and a pointer
2282
2289
  scene: container,
2283
2290
  raycaster,
@@ -2310,6 +2317,7 @@ function Portal({
2310
2317
  };
2311
2318
  });
2312
2319
  const usePortalStore = React__namespace.useMemo(() => {
2320
+ // Create a mirrored store, based on the previous root with a few overrides ...
2313
2321
  const store = traditional.createWithEqualityFn((set, get) => ({
2314
2322
  ...rest,
2315
2323
  set,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var loop = require('./loop-c991cb05.cjs.dev.js');
5
+ var loop = require('./loop-4ac96174.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var useMeasure = require('react-use-measure');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var loop = require('./loop-6e8a6208.cjs.prod.js');
5
+ var loop = require('./loop-2e09d861.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var useMeasure = require('react-use-measure');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, d as createRoot, i as isRef, E as ErrorBoundary, B as Block, f as unmountComponentAtNode } from './loop-ef070875.esm.js';
2
- export { F as FixedStage, t as ReactThreeFiber, S as Stage, p as Stages, _ as _roots, x as act, j as addAfterEffect, h as addEffect, k as addTail, m as advance, s as applyProps, y as buildGraph, q as context, c as createEvents, o as createPortal, d as createRoot, w as dispose, e as extend, g as flushGlobalEffects, v as getRootState, l as invalidate, r as reconciler, n as render, f as unmountComponentAtNode, D as useFrame, H as useGraph, z as useInstanceHandle, I as useLoader, A as useStore, C as useThree, G as useUpdate } from './loop-ef070875.esm.js';
1
+ import { c as createEvents, e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, d as createRoot, i as isRef, E as ErrorBoundary, B as Block, f as unmountComponentAtNode } from './loop-2db547cd.esm.js';
2
+ export { F as FixedStage, t as ReactThreeFiber, S as Stage, p as Stages, _ as _roots, x as act, j as addAfterEffect, h as addEffect, k as addTail, m as advance, s as applyProps, y as buildGraph, q as context, c as createEvents, o as createPortal, d as createRoot, w as dispose, e as extend, g as flushGlobalEffects, v as getRootState, l as invalidate, r as reconciler, n as render, f as unmountComponentAtNode, D as useFrame, H as useGraph, z as useInstanceHandle, I as useLoader, A as useStore, C as useThree, G as useUpdate } from './loop-2db547cd.esm.js';
3
3
  import * as React from 'react';
4
4
  import * as THREE from 'three';
5
5
  import useMeasure from 'react-use-measure';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var loop = require('../../dist/loop-c991cb05.cjs.dev.js');
5
+ var loop = require('../../dist/loop-4ac96174.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var reactNative = require('react-native');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var loop = require('../../dist/loop-6e8a6208.cjs.prod.js');
5
+ var loop = require('../../dist/loop-2e09d861.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var reactNative = require('react-native');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useBridge, a as useMutableCallback, d as createRoot, E as ErrorBoundary, B as Block, f as unmountComponentAtNode } from '../../dist/loop-ef070875.esm.js';
2
- export { F as FixedStage, t as ReactThreeFiber, S as Stage, p as Stages, _ as _roots, x as act, j as addAfterEffect, h as addEffect, k as addTail, m as advance, s as applyProps, y as buildGraph, q as context, c as createEvents, o as createPortal, d as createRoot, w as dispose, e as extend, g as flushGlobalEffects, v as getRootState, l as invalidate, r as reconciler, n as render, f as unmountComponentAtNode, D as useFrame, H as useGraph, z as useInstanceHandle, I as useLoader, A as useStore, C as useThree, G as useUpdate } from '../../dist/loop-ef070875.esm.js';
1
+ import { c as createEvents, e as extend, u as useBridge, a as useMutableCallback, d as createRoot, E as ErrorBoundary, B as Block, f as unmountComponentAtNode } from '../../dist/loop-2db547cd.esm.js';
2
+ export { F as FixedStage, t as ReactThreeFiber, S as Stage, p as Stages, _ as _roots, x as act, j as addAfterEffect, h as addEffect, k as addTail, m as advance, s as applyProps, y as buildGraph, q as context, c as createEvents, o as createPortal, d as createRoot, w as dispose, e as extend, g as flushGlobalEffects, v as getRootState, l as invalidate, r as reconciler, n as render, f as unmountComponentAtNode, D as useFrame, H as useGraph, z as useInstanceHandle, I as useLoader, A as useStore, C as useThree, G as useUpdate } from '../../dist/loop-2db547cd.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "9.0.0-alpha.6",
3
+ "version": "9.0.0-alpha.7",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -47,9 +47,9 @@
47
47
  "base64-js": "^1.5.1",
48
48
  "buffer": "^6.0.3",
49
49
  "its-fine": "^1.2.5",
50
- "react-reconciler": "0.31.0-beta-6946ebe620-20240508",
50
+ "react-reconciler": "0.31.0-rc-915b914b3a-20240515",
51
51
  "react-use-measure": "^2.1.1",
52
- "scheduler": "0.25.0-beta-6946ebe620-20240508",
52
+ "scheduler": "0.25.0-rc-915b914b3a-20240515",
53
53
  "suspend-react": "^0.1.3",
54
54
  "zustand": "^4.1.2"
55
55
  },