@react-three/fiber 8.7.2 → 8.7.4

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,11 +1,11 @@
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
- eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
9
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
10
- }
11
- 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
+ eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
9
+ eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
10
+ }
11
+ 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>;
@@ -90,7 +90,8 @@ ErrorBoundary.getDerivedStateFromError = () => ({
90
90
  const DEFAULT = '__default';
91
91
  const isDiffSet = def => def && !!def.memoized && !!def.changes;
92
92
  function calculateDpr(dpr) {
93
- return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], window.devicePixelRatio), dpr[1]) : dpr;
93
+ const target = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
94
+ return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
94
95
  }
95
96
  /**
96
97
  * Returns instance root state
@@ -443,9 +444,13 @@ function makeId(event) {
443
444
 
444
445
 
445
446
  function getEventPriority() {
446
- var _window, _window$event;
447
+ var _globalScope$event;
447
448
 
448
- let name = (_window = window) == null ? void 0 : (_window$event = _window.event) == null ? void 0 : _window$event.type;
449
+ // Get a handle to the current global scope in window and worker contexts if able
450
+ // https://github.com/pmndrs/react-three-fiber/pull/2493
451
+ const globalScope = typeof self !== 'undefined' && self || typeof window !== 'undefined' && window;
452
+ if (!globalScope) return constants.DefaultEventPriority;
453
+ const name = (_globalScope$event = globalScope.event) == null ? void 0 : _globalScope$event.type;
449
454
 
450
455
  switch (name) {
451
456
  case 'click':
@@ -63,7 +63,8 @@ ErrorBoundary.getDerivedStateFromError = () => ({
63
63
  const DEFAULT = '__default';
64
64
  const isDiffSet = def => def && !!def.memoized && !!def.changes;
65
65
  function calculateDpr(dpr) {
66
- return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], window.devicePixelRatio), dpr[1]) : dpr;
66
+ const target = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
67
+ return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
67
68
  }
68
69
  /**
69
70
  * Returns instance root state
@@ -416,9 +417,13 @@ function makeId(event) {
416
417
 
417
418
 
418
419
  function getEventPriority() {
419
- var _window, _window$event;
420
+ var _globalScope$event;
420
421
 
421
- let name = (_window = window) == null ? void 0 : (_window$event = _window.event) == null ? void 0 : _window$event.type;
422
+ // Get a handle to the current global scope in window and worker contexts if able
423
+ // https://github.com/pmndrs/react-three-fiber/pull/2493
424
+ const globalScope = typeof self !== 'undefined' && self || typeof window !== 'undefined' && window;
425
+ if (!globalScope) return DefaultEventPriority;
426
+ const name = (_globalScope$event = globalScope.event) == null ? void 0 : _globalScope$event.type;
422
427
 
423
428
  switch (name) {
424
429
  case 'click':
@@ -90,7 +90,8 @@ ErrorBoundary.getDerivedStateFromError = () => ({
90
90
  const DEFAULT = '__default';
91
91
  const isDiffSet = def => def && !!def.memoized && !!def.changes;
92
92
  function calculateDpr(dpr) {
93
- return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], window.devicePixelRatio), dpr[1]) : dpr;
93
+ const target = typeof window !== 'undefined' ? window.devicePixelRatio : 1;
94
+ return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
94
95
  }
95
96
  /**
96
97
  * Returns instance root state
@@ -443,9 +444,13 @@ function makeId(event) {
443
444
 
444
445
 
445
446
  function getEventPriority() {
446
- var _window, _window$event;
447
+ var _globalScope$event;
447
448
 
448
- let name = (_window = window) == null ? void 0 : (_window$event = _window.event) == null ? void 0 : _window$event.type;
449
+ // Get a handle to the current global scope in window and worker contexts if able
450
+ // https://github.com/pmndrs/react-three-fiber/pull/2493
451
+ const globalScope = typeof self !== 'undefined' && self || typeof window !== 'undefined' && window;
452
+ if (!globalScope) return constants.DefaultEventPriority;
453
+ const name = (_globalScope$event = globalScope.event) == null ? void 0 : _globalScope$event.type;
449
454
 
450
455
  switch (name) {
451
456
  case 'click':
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-407f3d70.cjs.dev.js');
5
+ var index = require('./index-78501abd.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -218,7 +218,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
218
218
  }, []);
219
219
  React__namespace.useEffect(() => {
220
220
  if (canvas) return () => index.unmountComponentAtNode(canvas);
221
- }, [canvas]);
221
+ }, [canvas]); // When the event source is not this div, we need to set pointer-events to none
222
+ // Or else the canvas will block events from reaching the event source
223
+
224
+ const pointerEvents = eventSource ? 'none' : 'auto';
222
225
  return /*#__PURE__*/React__namespace.createElement("div", _extends({
223
226
  ref: divRef,
224
227
  style: {
@@ -226,6 +229,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
226
229
  width: '100%',
227
230
  height: '100%',
228
231
  overflow: 'hidden',
232
+ pointerEvents,
229
233
  ...style
230
234
  }
231
235
  }, props), /*#__PURE__*/React__namespace.createElement("div", {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-5350eaac.cjs.prod.js');
5
+ var index = require('./index-e6292667.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -218,7 +218,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
218
218
  }, []);
219
219
  React__namespace.useEffect(() => {
220
220
  if (canvas) return () => index.unmountComponentAtNode(canvas);
221
- }, [canvas]);
221
+ }, [canvas]); // When the event source is not this div, we need to set pointer-events to none
222
+ // Or else the canvas will block events from reaching the event source
223
+
224
+ const pointerEvents = eventSource ? 'none' : 'auto';
222
225
  return /*#__PURE__*/React__namespace.createElement("div", _extends({
223
226
  ref: divRef,
224
227
  style: {
@@ -226,6 +229,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
226
229
  width: '100%',
227
230
  height: '100%',
228
231
  overflow: 'hidden',
232
+ pointerEvents,
229
233
  ...style
230
234
  }
231
235
  }, props), /*#__PURE__*/React__namespace.createElement("div", {
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, i as isRef, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-05f8627d.esm.js';
2
- export { t as ReactThreeFiber, v as _roots, s as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, k as dispose, e as extend, q as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, w as useInstanceHandle, C as useLoader, x as useStore, y as useThree } from './index-05f8627d.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, i as isRef, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-80784ca9.esm.js';
2
+ export { t as ReactThreeFiber, v as _roots, s as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, a as createRoot, k as dispose, e as extend, q as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, w as useInstanceHandle, C as useLoader, x as useStore, y as useThree } from './index-80784ca9.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';
@@ -191,7 +191,10 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
191
191
  }, []);
192
192
  React.useEffect(() => {
193
193
  if (canvas) return () => unmountComponentAtNode(canvas);
194
- }, [canvas]);
194
+ }, [canvas]); // When the event source is not this div, we need to set pointer-events to none
195
+ // Or else the canvas will block events from reaching the event source
196
+
197
+ const pointerEvents = eventSource ? 'none' : 'auto';
195
198
  return /*#__PURE__*/React.createElement("div", _extends({
196
199
  ref: divRef,
197
200
  style: {
@@ -199,6 +202,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
199
202
  width: '100%',
200
203
  height: '100%',
201
204
  overflow: 'hidden',
205
+ pointerEvents,
202
206
  ...style
203
207
  }
204
208
  }, props), /*#__PURE__*/React.createElement("div", {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-407f3d70.cjs.dev.js');
5
+ var index = require('../../dist/index-78501abd.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('../../dist/index-5350eaac.cjs.prod.js');
5
+ var index = require('../../dist/index-e6292667.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, d as unmountComponentAtNode } from '../../dist/index-05f8627d.esm.js';
2
- export { t as ReactThreeFiber, v as _roots, s as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, g as createPortal, a as createRoot, k as dispose, e as extend, q as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, w as useInstanceHandle, C as useLoader, x as useStore, y as useThree } from '../../dist/index-05f8627d.esm.js';
1
+ 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-80784ca9.esm.js';
2
+ export { t as ReactThreeFiber, v as _roots, s as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, g as createPortal, a as createRoot, k as dispose, e as extend, q as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, w as useInstanceHandle, C as useLoader, x as useStore, y as useThree } from '../../dist/index-80784ca9.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.7.2",
3
+ "version": "8.7.4",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",