@react-three/fiber 8.0.14 → 8.0.15

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.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - c4715d5f: allow invalidate to preempt more than 1 frame
8
+
3
9
  ## 8.0.14
4
10
 
5
11
  ### Patch Changes
@@ -9,7 +9,7 @@ import { addEffect, addAfterEffect, addTail } from './loop';
9
9
  import { EventManager, ComputeFunction } from './events';
10
10
  import { dispose, getRootState, Camera } from './utils';
11
11
  declare const roots: Map<Element, Root>;
12
- declare const invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void;
12
+ declare const invalidate: (state?: RootState | undefined, frames?: number) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void;
13
13
  declare const reconciler: import("react-reconciler").Reconciler<unknown, unknown, unknown, unknown, unknown>, applyProps: typeof import("./utils").applyProps;
14
14
  declare type Properties<T> = Pick<T, {
15
15
  [K in keyof T]: T[K] extends (_: any) => any ? never : K;
@@ -7,7 +7,7 @@ export declare const addAfterEffect: (callback: GlobalRenderCallback) => () => v
7
7
  export declare const addTail: (callback: GlobalRenderCallback) => () => void;
8
8
  export declare function createLoop<TCanvas>(roots: Map<TCanvas, Root>): {
9
9
  loop: (timestamp: number) => void;
10
- invalidate: (state?: RootState | undefined) => void;
10
+ invalidate: (state?: RootState | undefined, frames?: number) => void;
11
11
  advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void;
12
12
  };
13
13
  export {};
@@ -77,7 +77,7 @@ export declare type RootState = {
77
77
  viewport: Viewport & {
78
78
  getCurrentViewport: (camera?: Camera, target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>, size?: Size) => Omit<Viewport, 'dpr' | 'initialDpr'>;
79
79
  };
80
- invalidate: () => void;
80
+ invalidate: (frames?: number) => void;
81
81
  advance: (timestamp: number, runGlobalEffects?: boolean) => void;
82
82
  setEvents: (events: Partial<EventManager<any>>) => void;
83
83
  setSize: (width: number, height: number) => void;
@@ -88,5 +88,5 @@ export declare type RootState = {
88
88
  internal: InternalState;
89
89
  };
90
90
  declare const context: React.Context<UseBoundStore<RootState, StoreApi<RootState>>>;
91
- declare const createStore: (invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void) => UseBoundStore<RootState>;
91
+ declare const createStore: (invalidate: (state?: RootState | undefined, frames?: number | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void) => UseBoundStore<RootState>;
92
92
  export { createStore, context };
@@ -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;
@@ -1653,19 +1653,18 @@ const createRendererInstance = (gl, canvas) => {
1653
1653
  });
1654
1654
  };
1655
1655
 
1656
- const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1657
- // emulating an uncaught JavaScript error.
1658
- reportError : error => {
1659
- // In older browsers and test environments, fallback to console.error.
1660
- console.error(error);
1661
- };
1662
-
1663
1656
  function createRoot(canvas) {
1664
1657
  // Check against mistaken use of createRoot
1665
1658
  let prevRoot = roots.get(canvas);
1666
1659
  let prevFiber = prevRoot == null ? void 0 : prevRoot.fiber;
1667
1660
  let prevStore = prevRoot == null ? void 0 : prevRoot.store;
1668
- if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Create store
1661
+ if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Report when an error was detected in a previous render
1662
+ // https://github.com/pmndrs/react-three-fiber/pull/2261
1663
+
1664
+ const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1665
+ // emulating an uncaught JavaScript error.
1666
+ reportError : // In older browsers and test environments, fallback to console.error.
1667
+ console.error; // Create store
1669
1668
 
1670
1669
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1671
1670
 
@@ -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;
@@ -1626,19 +1626,18 @@ const createRendererInstance = (gl, canvas) => {
1626
1626
  });
1627
1627
  };
1628
1628
 
1629
- const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1630
- // emulating an uncaught JavaScript error.
1631
- reportError : error => {
1632
- // In older browsers and test environments, fallback to console.error.
1633
- console.error(error);
1634
- };
1635
-
1636
1629
  function createRoot(canvas) {
1637
1630
  // Check against mistaken use of createRoot
1638
1631
  let prevRoot = roots.get(canvas);
1639
1632
  let prevFiber = prevRoot == null ? void 0 : prevRoot.fiber;
1640
1633
  let prevStore = prevRoot == null ? void 0 : prevRoot.store;
1641
- if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Create store
1634
+ if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Report when an error was detected in a previous render
1635
+ // https://github.com/pmndrs/react-three-fiber/pull/2261
1636
+
1637
+ const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1638
+ // emulating an uncaught JavaScript error.
1639
+ reportError : // In older browsers and test environments, fallback to console.error.
1640
+ console.error; // Create store
1642
1641
 
1643
1642
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1644
1643
 
@@ -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;
@@ -1653,19 +1653,18 @@ const createRendererInstance = (gl, canvas) => {
1653
1653
  });
1654
1654
  };
1655
1655
 
1656
- const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1657
- // emulating an uncaught JavaScript error.
1658
- reportError : error => {
1659
- // In older browsers and test environments, fallback to console.error.
1660
- console.error(error);
1661
- };
1662
-
1663
1656
  function createRoot(canvas) {
1664
1657
  // Check against mistaken use of createRoot
1665
1658
  let prevRoot = roots.get(canvas);
1666
1659
  let prevFiber = prevRoot == null ? void 0 : prevRoot.fiber;
1667
1660
  let prevStore = prevRoot == null ? void 0 : prevRoot.store;
1668
- if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Create store
1661
+ if (prevRoot) console.warn('R3F.createRoot should only be called once!'); // Report when an error was detected in a previous render
1662
+ // https://github.com/pmndrs/react-three-fiber/pull/2261
1663
+
1664
+ const logRecoverableError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event,
1665
+ // emulating an uncaught JavaScript error.
1666
+ reportError : // In older browsers and test environments, fallback to console.error.
1667
+ console.error; // Create store
1669
1668
 
1670
1669
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1671
1670
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-cf0e5bff.cjs.dev.js');
5
+ var index = require('./index-606d3385.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-5844e9ba.cjs.prod.js');
5
+ var index = require('./index-05d06e15.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-c0771a1d.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-c0771a1d.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-208291a3.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-208291a3.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-cf0e5bff.cjs.dev.js');
7
+ var index = require('../../dist/index-606d3385.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-5844e9ba.cjs.prod.js');
7
+ var index = require('../../dist/index-05d06e15.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-c0771a1d.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-c0771a1d.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-208291a3.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-208291a3.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.14",
3
+ "version": "8.0.15",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",