@react-three/fiber 8.0.13 → 8.0.16

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,9 +1,9 @@
1
- import * as React from 'react';
2
- import type { Options as ResizeOptions } from 'react-use-measure';
3
- import { RenderProps } from '../core';
4
- export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
- children: React.ReactNode;
6
- fallback?: React.ReactNode;
7
- resize?: ResizeOptions;
8
- }
9
- export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
1
+ import * as React from 'react';
2
+ import type { Options as ResizeOptions } from 'react-use-measure';
3
+ import { RenderProps } from '../core';
4
+ export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
+ children: React.ReactNode;
6
+ fallback?: React.ReactNode;
7
+ resize?: ResizeOptions;
8
+ }
9
+ export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
@@ -1,4 +1,4 @@
1
- import { UseBoundStore } from 'zustand';
2
- import { RootState } from '../core/store';
3
- import { EventManager } from '../core/events';
4
- export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
1
+ import { UseBoundStore } from 'zustand';
2
+ import { RootState } from '../core/store';
3
+ import { EventManager } from '../core/events';
4
+ export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
@@ -846,7 +846,7 @@ function createRenderer(roots, getEventPriority) {
846
846
  const target = catalogue[name];
847
847
 
848
848
  if (!target) {
849
- throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;
849
+ throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`;
850
850
  } // Throw if an object or literal was passed for args
851
851
 
852
852
 
@@ -1228,7 +1228,7 @@ const createStore = (invalidate, advance) => {
1228
1228
  connected: false
1229
1229
  },
1230
1230
  xr: null,
1231
- invalidate: () => invalidate(get()),
1231
+ invalidate: (frames = 1) => invalidate(get(), frames),
1232
1232
  advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
1233
1233
  legacy: false,
1234
1234
  linear: false,
@@ -1480,13 +1480,13 @@ function createLoop(roots) {
1480
1480
  }
1481
1481
  }
1482
1482
 
1483
- function invalidate(state) {
1483
+ function invalidate(state, frames = 1) {
1484
1484
  var _state$gl$xr2;
1485
1485
 
1486
- if (!state) return roots.forEach(root => invalidate(root.store.getState()));
1486
+ if (!state) return roots.forEach(root => invalidate(root.store.getState()), frames);
1487
1487
  if ((_state$gl$xr2 = state.gl.xr) != null && _state$gl$xr2.isPresenting || !state.internal.active || state.frameloop === 'never') return; // Increase frames, do not go higher than 60
1488
1488
 
1489
- state.internal.frames = Math.min(60, state.internal.frames + 1); // If the render-loop isn't active, start it
1489
+ state.internal.frames = Math.min(60, state.internal.frames + frames); // If the render-loop isn't active, start it
1490
1490
 
1491
1491
  if (!running) {
1492
1492
  running = true;
@@ -1566,14 +1566,13 @@ function loadingFn(extensions, onProgress) {
1566
1566
  }, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
1567
1567
  };
1568
1568
  }
1569
+
1569
1570
  /**
1570
1571
  * Synchronously loads and caches assets with a three loader.
1571
1572
  *
1572
1573
  * Note: this hook's caller must be wrapped with `React.Suspense`
1573
1574
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1574
1575
  */
1575
-
1576
-
1577
1576
  function useLoader(Proto, input, extensions, onProgress) {
1578
1577
  // Use suspense to load async assets
1579
1578
  const keys = Array.isArray(input) ? input : [input];
@@ -1631,11 +1630,17 @@ function createRoot(canvas) {
1631
1630
  let prevRoot = roots.get(canvas);
1632
1631
  let prevFiber = prevRoot == null ? void 0 : prevRoot.fiber;
1633
1632
  let prevStore = prevRoot == null ? void 0 : prevRoot.store;
1634
- if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Create store
1633
+ if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Report when an error was detected in a previous render
1634
+ // https://github.com/pmndrs/react-three-fiber/pull/2261
1635
+
1636
+ const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1637
+ // emulating an uncaught JavaScript error.
1638
+ reportError : // In older browsers and test environments, fallback to console.error.
1639
+ console.error; // Create store
1635
1640
 
1636
1641
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1637
1642
 
1638
- const fiber = prevFiber || reconciler.createContainer(store, ConcurrentRoot, false, null); // Map it
1643
+ const fiber = prevFiber || reconciler.createContainer(store, ConcurrentRoot, null, false, null, '', logRecoverableError, null); // Map it
1639
1644
 
1640
1645
  if (!prevRoot) roots.set(canvas, {
1641
1646
  fiber,
@@ -873,7 +873,7 @@ function createRenderer(roots, getEventPriority) {
873
873
  const target = catalogue[name];
874
874
 
875
875
  if (!target) {
876
- throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;
876
+ throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`;
877
877
  } // Throw if an object or literal was passed for args
878
878
 
879
879
 
@@ -1255,7 +1255,7 @@ const createStore = (invalidate, advance) => {
1255
1255
  connected: false
1256
1256
  },
1257
1257
  xr: null,
1258
- invalidate: () => invalidate(get()),
1258
+ invalidate: (frames = 1) => invalidate(get(), frames),
1259
1259
  advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
1260
1260
  legacy: false,
1261
1261
  linear: false,
@@ -1507,13 +1507,13 @@ function createLoop(roots) {
1507
1507
  }
1508
1508
  }
1509
1509
 
1510
- function invalidate(state) {
1510
+ function invalidate(state, frames = 1) {
1511
1511
  var _state$gl$xr2;
1512
1512
 
1513
- if (!state) return roots.forEach(root => invalidate(root.store.getState()));
1513
+ if (!state) return roots.forEach(root => invalidate(root.store.getState()), frames);
1514
1514
  if ((_state$gl$xr2 = state.gl.xr) != null && _state$gl$xr2.isPresenting || !state.internal.active || state.frameloop === 'never') return; // Increase frames, do not go higher than 60
1515
1515
 
1516
- state.internal.frames = Math.min(60, state.internal.frames + 1); // If the render-loop isn't active, start it
1516
+ state.internal.frames = Math.min(60, state.internal.frames + frames); // If the render-loop isn't active, start it
1517
1517
 
1518
1518
  if (!running) {
1519
1519
  running = true;
@@ -1593,14 +1593,13 @@ function loadingFn(extensions, onProgress) {
1593
1593
  }, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
1594
1594
  };
1595
1595
  }
1596
+
1596
1597
  /**
1597
1598
  * Synchronously loads and caches assets with a three loader.
1598
1599
  *
1599
1600
  * Note: this hook's caller must be wrapped with `React.Suspense`
1600
1601
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1601
1602
  */
1602
-
1603
-
1604
1603
  function useLoader(Proto, input, extensions, onProgress) {
1605
1604
  // Use suspense to load async assets
1606
1605
  const keys = Array.isArray(input) ? input : [input];
@@ -1658,11 +1657,17 @@ function createRoot(canvas) {
1658
1657
  let prevRoot = roots.get(canvas);
1659
1658
  let prevFiber = prevRoot == null ? void 0 : prevRoot.fiber;
1660
1659
  let prevStore = prevRoot == null ? void 0 : prevRoot.store;
1661
- if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Create store
1660
+ if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Report when an error was detected in a previous render
1661
+ // https://github.com/pmndrs/react-three-fiber/pull/2261
1662
+
1663
+ const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1664
+ // emulating an uncaught JavaScript error.
1665
+ reportError : // In older browsers and test environments, fallback to console.error.
1666
+ console.error; // Create store
1662
1667
 
1663
1668
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1664
1669
 
1665
- const fiber = prevFiber || reconciler.createContainer(store, constants.ConcurrentRoot, false, null); // Map it
1670
+ const fiber = prevFiber || reconciler.createContainer(store, constants.ConcurrentRoot, null, false, null, '', logRecoverableError, null); // Map it
1666
1671
 
1667
1672
  if (!prevRoot) roots.set(canvas, {
1668
1673
  fiber,
@@ -873,7 +873,7 @@ function createRenderer(roots, getEventPriority) {
873
873
  const target = catalogue[name];
874
874
 
875
875
  if (!target) {
876
- throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`;
876
+ throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`;
877
877
  } // Throw if an object or literal was passed for args
878
878
 
879
879
 
@@ -1255,7 +1255,7 @@ const createStore = (invalidate, advance) => {
1255
1255
  connected: false
1256
1256
  },
1257
1257
  xr: null,
1258
- invalidate: () => invalidate(get()),
1258
+ invalidate: (frames = 1) => invalidate(get(), frames),
1259
1259
  advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
1260
1260
  legacy: false,
1261
1261
  linear: false,
@@ -1507,13 +1507,13 @@ function createLoop(roots) {
1507
1507
  }
1508
1508
  }
1509
1509
 
1510
- function invalidate(state) {
1510
+ function invalidate(state, frames = 1) {
1511
1511
  var _state$gl$xr2;
1512
1512
 
1513
- if (!state) return roots.forEach(root => invalidate(root.store.getState()));
1513
+ if (!state) return roots.forEach(root => invalidate(root.store.getState()), frames);
1514
1514
  if ((_state$gl$xr2 = state.gl.xr) != null && _state$gl$xr2.isPresenting || !state.internal.active || state.frameloop === 'never') return; // Increase frames, do not go higher than 60
1515
1515
 
1516
- state.internal.frames = Math.min(60, state.internal.frames + 1); // If the render-loop isn't active, start it
1516
+ state.internal.frames = Math.min(60, state.internal.frames + frames); // If the render-loop isn't active, start it
1517
1517
 
1518
1518
  if (!running) {
1519
1519
  running = true;
@@ -1593,14 +1593,13 @@ function loadingFn(extensions, onProgress) {
1593
1593
  }, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
1594
1594
  };
1595
1595
  }
1596
+
1596
1597
  /**
1597
1598
  * Synchronously loads and caches assets with a three loader.
1598
1599
  *
1599
1600
  * Note: this hook's caller must be wrapped with `React.Suspense`
1600
1601
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1601
1602
  */
1602
-
1603
-
1604
1603
  function useLoader(Proto, input, extensions, onProgress) {
1605
1604
  // Use suspense to load async assets
1606
1605
  const keys = Array.isArray(input) ? input : [input];
@@ -1658,11 +1657,17 @@ function createRoot(canvas) {
1658
1657
  let prevRoot = roots.get(canvas);
1659
1658
  let prevFiber = prevRoot == null ? void 0 : prevRoot.fiber;
1660
1659
  let prevStore = prevRoot == null ? void 0 : prevRoot.store;
1661
- if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Create store
1660
+ if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Report when an error was detected in a previous render
1661
+ // https://github.com/pmndrs/react-three-fiber/pull/2261
1662
+
1663
+ const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1664
+ // emulating an uncaught JavaScript error.
1665
+ reportError : // In older browsers and test environments, fallback to console.error.
1666
+ console.error; // Create store
1662
1667
 
1663
1668
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1664
1669
 
1665
- const fiber = prevFiber || reconciler.createContainer(store, constants.ConcurrentRoot, false, null); // Map it
1670
+ const fiber = prevFiber || reconciler.createContainer(store, constants.ConcurrentRoot, null, false, null, '', logRecoverableError, null); // Map it
1666
1671
 
1667
1672
  if (!prevRoot) roots.set(canvas, {
1668
1673
  fiber,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-9ced08b3.cjs.dev.js');
5
+ var index = require('./index-f3176a33.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-46325a70.cjs.prod.js');
5
+ var index = require('./index-4e1c76e5.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-ec95272c.esm.js';
2
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-ec95272c.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-136ca0b0.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-136ca0b0.esm.js';
3
3
  import _extends from '@babel/runtime/helpers/esm/extends';
4
4
  import * as React from 'react';
5
5
  import * as THREE from 'three';
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var THREE = require('three');
6
6
  var expoAsset = require('expo-asset');
7
- var index = require('../../dist/index-9ced08b3.cjs.dev.js');
7
+ var index = require('../../dist/index-f3176a33.cjs.dev.js');
8
8
  var _extends = require('@babel/runtime/helpers/extends');
9
9
  var React = require('react');
10
10
  var mergeRefs = require('react-merge-refs');
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var THREE = require('three');
6
6
  var expoAsset = require('expo-asset');
7
- var index = require('../../dist/index-46325a70.cjs.prod.js');
7
+ var index = require('../../dist/index-4e1c76e5.cjs.prod.js');
8
8
  var _extends = require('@babel/runtime/helpers/extends');
9
9
  var React = require('react');
10
10
  var mergeRefs = require('react-merge-refs');
@@ -1,7 +1,7 @@
1
1
  import * as THREE from 'three';
2
2
  import { Asset } from 'expo-asset';
3
- import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-ec95272c.esm.js';
4
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-ec95272c.esm.js';
3
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-136ca0b0.esm.js';
4
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-136ca0b0.esm.js';
5
5
  import _extends from '@babel/runtime/helpers/esm/extends';
6
6
  import * as React from 'react';
7
7
  import mergeRefs from 'react-merge-refs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.0.13",
3
+ "version": "8.0.16",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@babel/runtime": "^7.17.8",
46
- "@types/react-reconciler": "^0.26.6",
46
+ "@types/react-reconciler": "^0.26.7",
47
47
  "react-merge-refs": "^1.1.0",
48
48
  "react-reconciler": "^0.27.0",
49
49
  "react-use-measure": "^2.1.1",