@react-three/fiber 8.8.0 → 8.8.1

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>;
@@ -56,87 +56,6 @@ function useMutableCallback(fn) {
56
56
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
57
57
  return ref;
58
58
  }
59
- /**
60
- * Traverses up or down a {@link Fiber}, return `true` to stop and select a node.
61
- */
62
-
63
- function traverseFiber(fiber, ascending, selector) {
64
- if (selector(fiber) === true) return fiber;
65
- let child = ascending ? fiber.return : fiber.child;
66
-
67
- while (child) {
68
- const match = traverseFiber(child, ascending, selector);
69
- if (match) return match;
70
- child = child.sibling;
71
- }
72
- } // Active contexts
73
-
74
-
75
- const contexts = [];
76
- /**
77
- * Represents a react-context bridge provider component.
78
- */
79
-
80
- /**
81
- * React Context currently cannot be shared across [React renderers](https://reactjs.org/docs/codebase-overview.html#renderers) but explicitly forwarded between providers (see [react#17275](https://github.com/facebook/react/issues/17275)). This hook returns a {@link ContextBridge} of live context providers to pierce Context across renderers.
82
- *
83
- * Pass {@link ContextBridge} as a component to a secondary renderer to enable context-sharing within its children.
84
- */
85
- function useContextBridge(fiber) {
86
- if (fiber) {
87
- traverseFiber(fiber, true, node => {
88
- var _node$type;
89
-
90
- const context = (_node$type = node.type) == null ? void 0 : _node$type._context;
91
- if (!context || contexts.includes(context)) return; // In development, React will warn about using contexts between renderers because
92
- // of the above issue. We'll hide the warning because this hook works as expected
93
- // https://github.com/facebook/react/pull/12779
94
-
95
- Object.defineProperties(context, {
96
- _currentRenderer: {
97
- get() {
98
- return null;
99
- },
100
-
101
- set() {}
102
-
103
- },
104
- _currentRenderer2: {
105
- get() {
106
- return null;
107
- },
108
-
109
- set() {}
110
-
111
- }
112
- });
113
- contexts.push(context);
114
- });
115
- }
116
-
117
- return contexts.reduce((Prev, context) => {
118
- var _SECRET_INTERNALS_DO;
119
-
120
- const value = (_SECRET_INTERNALS_DO = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current) == null ? void 0 : _SECRET_INTERNALS_DO.readContext(context);
121
- return props => /*#__PURE__*/React__namespace.createElement(Prev, null, /*#__PURE__*/React__namespace.createElement(context.Provider, { ...props,
122
- value
123
- }));
124
- }, props => /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, props));
125
- }
126
- /**
127
- * Exposes the current react-internal {@link Fiber}.
128
- */
129
-
130
- class FiberProvider extends React__namespace.Component {
131
- componentDidMount() {
132
- this.props.setFiber(this._reactInternals);
133
- }
134
-
135
- render() {
136
- return this.props.children;
137
- }
138
-
139
- }
140
59
  function Block({
141
60
  set
142
61
  }) {
@@ -2248,7 +2167,6 @@ const act = React__namespace.unstable_act;
2248
2167
 
2249
2168
  exports.Block = Block;
2250
2169
  exports.ErrorBoundary = ErrorBoundary;
2251
- exports.FiberProvider = FiberProvider;
2252
2170
  exports.act = act;
2253
2171
  exports.addAfterEffect = addAfterEffect;
2254
2172
  exports.addEffect = addEffect;
@@ -2269,7 +2187,6 @@ exports.render = render;
2269
2187
  exports.roots = roots;
2270
2188
  exports.threeTypes = threeTypes;
2271
2189
  exports.unmountComponentAtNode = unmountComponentAtNode;
2272
- exports.useContextBridge = useContextBridge;
2273
2190
  exports.useFrame = useFrame;
2274
2191
  exports.useGraph = useGraph;
2275
2192
  exports.useInstanceHandle = useInstanceHandle;
@@ -29,87 +29,6 @@ function useMutableCallback(fn) {
29
29
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
30
30
  return ref;
31
31
  }
32
- /**
33
- * Traverses up or down a {@link Fiber}, return `true` to stop and select a node.
34
- */
35
-
36
- function traverseFiber(fiber, ascending, selector) {
37
- if (selector(fiber) === true) return fiber;
38
- let child = ascending ? fiber.return : fiber.child;
39
-
40
- while (child) {
41
- const match = traverseFiber(child, ascending, selector);
42
- if (match) return match;
43
- child = child.sibling;
44
- }
45
- } // Active contexts
46
-
47
-
48
- const contexts = [];
49
- /**
50
- * Represents a react-context bridge provider component.
51
- */
52
-
53
- /**
54
- * React Context currently cannot be shared across [React renderers](https://reactjs.org/docs/codebase-overview.html#renderers) but explicitly forwarded between providers (see [react#17275](https://github.com/facebook/react/issues/17275)). This hook returns a {@link ContextBridge} of live context providers to pierce Context across renderers.
55
- *
56
- * Pass {@link ContextBridge} as a component to a secondary renderer to enable context-sharing within its children.
57
- */
58
- function useContextBridge(fiber) {
59
- if (fiber) {
60
- traverseFiber(fiber, true, node => {
61
- var _node$type;
62
-
63
- const context = (_node$type = node.type) == null ? void 0 : _node$type._context;
64
- if (!context || contexts.includes(context)) return; // In development, React will warn about using contexts between renderers because
65
- // of the above issue. We'll hide the warning because this hook works as expected
66
- // https://github.com/facebook/react/pull/12779
67
-
68
- Object.defineProperties(context, {
69
- _currentRenderer: {
70
- get() {
71
- return null;
72
- },
73
-
74
- set() {}
75
-
76
- },
77
- _currentRenderer2: {
78
- get() {
79
- return null;
80
- },
81
-
82
- set() {}
83
-
84
- }
85
- });
86
- contexts.push(context);
87
- });
88
- }
89
-
90
- return contexts.reduce((Prev, context) => {
91
- var _SECRET_INTERNALS_DO;
92
-
93
- const value = (_SECRET_INTERNALS_DO = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current) == null ? void 0 : _SECRET_INTERNALS_DO.readContext(context);
94
- return props => /*#__PURE__*/React.createElement(Prev, null, /*#__PURE__*/React.createElement(context.Provider, { ...props,
95
- value
96
- }));
97
- }, props => /*#__PURE__*/React.createElement(React.Fragment, props));
98
- }
99
- /**
100
- * Exposes the current react-internal {@link Fiber}.
101
- */
102
-
103
- class FiberProvider extends React.Component {
104
- componentDidMount() {
105
- this.props.setFiber(this._reactInternals);
106
- }
107
-
108
- render() {
109
- return this.props.children;
110
- }
111
-
112
- }
113
32
  function Block({
114
33
  set
115
34
  }) {
@@ -2219,4 +2138,4 @@ reconciler.injectIntoDevTools({
2219
2138
  });
2220
2139
  const act = React.unstable_act;
2221
2140
 
2222
- export { useFrame as A, Block as B, useGraph as C, useLoader as D, ErrorBoundary as E, FiberProvider as F, useMutableCallback as a, createRoot as b, createEvents as c, useIsomorphicLayoutEffect as d, extend as e, unmountComponentAtNode as f, context as g, createPortal as h, isRef as i, reconciler as j, applyProps as k, dispose as l, invalidate as m, advance as n, addEffect as o, addAfterEffect as p, addTail as q, render as r, getRootState as s, threeTypes as t, useContextBridge as u, act as v, roots as w, useInstanceHandle as x, useStore as y, useThree as z };
2141
+ export { useGraph as A, Block as B, useLoader as C, ErrorBoundary as E, createRoot as a, useIsomorphicLayoutEffect as b, createEvents as c, unmountComponentAtNode as d, extend as e, context as f, createPortal as g, reconciler as h, isRef as i, applyProps as j, dispose as k, invalidate as l, advance as m, addEffect as n, addAfterEffect as o, addTail as p, getRootState as q, render as r, act as s, threeTypes as t, useMutableCallback as u, roots as v, useInstanceHandle as w, useStore as x, useThree as y, useFrame as z };
@@ -56,87 +56,6 @@ function useMutableCallback(fn) {
56
56
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
57
57
  return ref;
58
58
  }
59
- /**
60
- * Traverses up or down a {@link Fiber}, return `true` to stop and select a node.
61
- */
62
-
63
- function traverseFiber(fiber, ascending, selector) {
64
- if (selector(fiber) === true) return fiber;
65
- let child = ascending ? fiber.return : fiber.child;
66
-
67
- while (child) {
68
- const match = traverseFiber(child, ascending, selector);
69
- if (match) return match;
70
- child = child.sibling;
71
- }
72
- } // Active contexts
73
-
74
-
75
- const contexts = [];
76
- /**
77
- * Represents a react-context bridge provider component.
78
- */
79
-
80
- /**
81
- * React Context currently cannot be shared across [React renderers](https://reactjs.org/docs/codebase-overview.html#renderers) but explicitly forwarded between providers (see [react#17275](https://github.com/facebook/react/issues/17275)). This hook returns a {@link ContextBridge} of live context providers to pierce Context across renderers.
82
- *
83
- * Pass {@link ContextBridge} as a component to a secondary renderer to enable context-sharing within its children.
84
- */
85
- function useContextBridge(fiber) {
86
- if (fiber) {
87
- traverseFiber(fiber, true, node => {
88
- var _node$type;
89
-
90
- const context = (_node$type = node.type) == null ? void 0 : _node$type._context;
91
- if (!context || contexts.includes(context)) return; // In development, React will warn about using contexts between renderers because
92
- // of the above issue. We'll hide the warning because this hook works as expected
93
- // https://github.com/facebook/react/pull/12779
94
-
95
- Object.defineProperties(context, {
96
- _currentRenderer: {
97
- get() {
98
- return null;
99
- },
100
-
101
- set() {}
102
-
103
- },
104
- _currentRenderer2: {
105
- get() {
106
- return null;
107
- },
108
-
109
- set() {}
110
-
111
- }
112
- });
113
- contexts.push(context);
114
- });
115
- }
116
-
117
- return contexts.reduce((Prev, context) => {
118
- var _SECRET_INTERNALS_DO;
119
-
120
- const value = (_SECRET_INTERNALS_DO = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current) == null ? void 0 : _SECRET_INTERNALS_DO.readContext(context);
121
- return props => /*#__PURE__*/React__namespace.createElement(Prev, null, /*#__PURE__*/React__namespace.createElement(context.Provider, { ...props,
122
- value
123
- }));
124
- }, props => /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, props));
125
- }
126
- /**
127
- * Exposes the current react-internal {@link Fiber}.
128
- */
129
-
130
- class FiberProvider extends React__namespace.Component {
131
- componentDidMount() {
132
- this.props.setFiber(this._reactInternals);
133
- }
134
-
135
- render() {
136
- return this.props.children;
137
- }
138
-
139
- }
140
59
  function Block({
141
60
  set
142
61
  }) {
@@ -2248,7 +2167,6 @@ const act = React__namespace.unstable_act;
2248
2167
 
2249
2168
  exports.Block = Block;
2250
2169
  exports.ErrorBoundary = ErrorBoundary;
2251
- exports.FiberProvider = FiberProvider;
2252
2170
  exports.act = act;
2253
2171
  exports.addAfterEffect = addAfterEffect;
2254
2172
  exports.addEffect = addEffect;
@@ -2269,7 +2187,6 @@ exports.render = render;
2269
2187
  exports.roots = roots;
2270
2188
  exports.threeTypes = threeTypes;
2271
2189
  exports.unmountComponentAtNode = unmountComponentAtNode;
2272
- exports.useContextBridge = useContextBridge;
2273
2190
  exports.useFrame = useFrame;
2274
2191
  exports.useGraph = useGraph;
2275
2192
  exports.useInstanceHandle = useInstanceHandle;
@@ -2,11 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-a38b08b7.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');
9
9
  var useMeasure = require('react-use-measure');
10
+ var itsFine = require('its-fine');
10
11
  require('react-reconciler/constants');
11
12
  require('zustand');
12
13
  require('react-reconciler');
@@ -115,11 +116,7 @@ function createPointerEvents(store) {
115
116
  };
116
117
  }
117
118
 
118
- /**
119
- * A DOM canvas which accepts threejs elements as children.
120
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
121
- */
122
- const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
119
+ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
123
120
  children,
124
121
  fallback,
125
122
  resize,
@@ -146,8 +143,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
146
143
  // This will include the entire THREE namespace by default, users can extend
147
144
  // their own elements by using the createRoot API instead
148
145
  React__namespace.useMemo(() => index.extend(THREE__namespace), []);
149
- const [fiber, setFiber] = React__namespace.useState(null);
150
- const Bridge = index.useContextBridge(fiber);
146
+ const Bridge = itsFine.useContextBridge();
151
147
  const [containerRef, containerRect] = useMeasure__default["default"]({
152
148
  scroll: true,
153
149
  debounce: {
@@ -224,9 +220,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
224
220
  // Or else the canvas will block events from reaching the event source
225
221
 
226
222
  const pointerEvents = eventSource ? 'none' : 'auto';
227
- return /*#__PURE__*/React__namespace.createElement(index.FiberProvider, {
228
- setFiber: setFiber
229
- }, /*#__PURE__*/React__namespace.createElement("div", _extends({
223
+ return /*#__PURE__*/React__namespace.createElement("div", _extends({
230
224
  ref: divRef,
231
225
  style: {
232
226
  position: 'relative',
@@ -247,7 +241,17 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
247
241
  style: {
248
242
  display: 'block'
249
243
  }
250
- }, fallback))));
244
+ }, fallback)));
245
+ });
246
+ /**
247
+ * A DOM canvas which accepts threejs elements as children.
248
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
249
+ */
250
+
251
+ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
252
+ return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {
253
+ ref: ref
254
+ })));
251
255
  });
252
256
 
253
257
  exports.ReactThreeFiber = index.threeTypes;
@@ -2,11 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-fb8e3829.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');
9
9
  var useMeasure = require('react-use-measure');
10
+ var itsFine = require('its-fine');
10
11
  require('react-reconciler/constants');
11
12
  require('zustand');
12
13
  require('react-reconciler');
@@ -115,11 +116,7 @@ function createPointerEvents(store) {
115
116
  };
116
117
  }
117
118
 
118
- /**
119
- * A DOM canvas which accepts threejs elements as children.
120
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
121
- */
122
- const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
119
+ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
123
120
  children,
124
121
  fallback,
125
122
  resize,
@@ -146,8 +143,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
146
143
  // This will include the entire THREE namespace by default, users can extend
147
144
  // their own elements by using the createRoot API instead
148
145
  React__namespace.useMemo(() => index.extend(THREE__namespace), []);
149
- const [fiber, setFiber] = React__namespace.useState(null);
150
- const Bridge = index.useContextBridge(fiber);
146
+ const Bridge = itsFine.useContextBridge();
151
147
  const [containerRef, containerRect] = useMeasure__default["default"]({
152
148
  scroll: true,
153
149
  debounce: {
@@ -224,9 +220,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
224
220
  // Or else the canvas will block events from reaching the event source
225
221
 
226
222
  const pointerEvents = eventSource ? 'none' : 'auto';
227
- return /*#__PURE__*/React__namespace.createElement(index.FiberProvider, {
228
- setFiber: setFiber
229
- }, /*#__PURE__*/React__namespace.createElement("div", _extends({
223
+ return /*#__PURE__*/React__namespace.createElement("div", _extends({
230
224
  ref: divRef,
231
225
  style: {
232
226
  position: 'relative',
@@ -247,7 +241,17 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
247
241
  style: {
248
242
  display: 'block'
249
243
  }
250
- }, fallback))));
244
+ }, fallback)));
245
+ });
246
+ /**
247
+ * A DOM canvas which accepts threejs elements as children.
248
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
249
+ */
250
+
251
+ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
252
+ return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {
253
+ ref: ref
254
+ })));
251
255
  });
252
256
 
253
257
  exports.ReactThreeFiber = index.threeTypes;
@@ -1,9 +1,10 @@
1
- import { c as createEvents, e as extend, u as useContextBridge, a as useMutableCallback, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as useIsomorphicLayoutEffect, f as unmountComponentAtNode, F as FiberProvider } from './index-f01196c6.esm.js';
2
- export { t as ReactThreeFiber, w as _roots, v as act, p as addAfterEffect, o as addEffect, q as addTail, n as advance, k as applyProps, g as context, c as createEvents, h as createPortal, b as createRoot, l as dispose, e as extend, s as getRootState, m as invalidate, j as reconciler, r as render, f as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-f01196c6.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';
6
6
  import useMeasure from 'react-use-measure';
7
+ import { FiberProvider, useContextBridge } from 'its-fine';
7
8
  import 'react-reconciler/constants';
8
9
  import 'zustand';
9
10
  import 'react-reconciler';
@@ -88,11 +89,7 @@ function createPointerEvents(store) {
88
89
  };
89
90
  }
90
91
 
91
- /**
92
- * A DOM canvas which accepts threejs elements as children.
93
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
94
- */
95
- const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
92
+ const CanvasImpl = /*#__PURE__*/React.forwardRef(function Canvas({
96
93
  children,
97
94
  fallback,
98
95
  resize,
@@ -119,8 +116,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
119
116
  // This will include the entire THREE namespace by default, users can extend
120
117
  // their own elements by using the createRoot API instead
121
118
  React.useMemo(() => extend(THREE), []);
122
- const [fiber, setFiber] = React.useState(null);
123
- const Bridge = useContextBridge(fiber);
119
+ const Bridge = useContextBridge();
124
120
  const [containerRef, containerRect] = useMeasure({
125
121
  scroll: true,
126
122
  debounce: {
@@ -197,9 +193,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
197
193
  // Or else the canvas will block events from reaching the event source
198
194
 
199
195
  const pointerEvents = eventSource ? 'none' : 'auto';
200
- return /*#__PURE__*/React.createElement(FiberProvider, {
201
- setFiber: setFiber
202
- }, /*#__PURE__*/React.createElement("div", _extends({
196
+ return /*#__PURE__*/React.createElement("div", _extends({
203
197
  ref: divRef,
204
198
  style: {
205
199
  position: 'relative',
@@ -220,7 +214,17 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
220
214
  style: {
221
215
  display: 'block'
222
216
  }
223
- }, fallback))));
217
+ }, fallback)));
218
+ });
219
+ /**
220
+ * A DOM canvas which accepts threejs elements as children.
221
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
222
+ */
223
+
224
+ const Canvas = /*#__PURE__*/React.forwardRef(function CanvasWrapper(props, ref) {
225
+ return /*#__PURE__*/React.createElement(FiberProvider, null, /*#__PURE__*/React.createElement(CanvasImpl, _extends({}, props, {
226
+ ref: ref
227
+ })));
224
228
  });
225
229
 
226
230
  export { Canvas, createPointerEvents as events };
@@ -2,12 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-a38b08b7.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');
9
9
  var reactNative = require('react-native');
10
10
  var expoGl = require('expo-gl');
11
+ var itsFine = require('its-fine');
11
12
  var Pressability = require('react-native/Libraries/Pressability/Pressability');
12
13
  require('react-reconciler/constants');
13
14
  require('zustand');
@@ -236,7 +237,7 @@ function polyfills() {
236
237
  * A native canvas which accepts threejs elements as children.
237
238
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
238
239
  */
239
- const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
240
+ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
240
241
  children,
241
242
  style,
242
243
  gl,
@@ -258,8 +259,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
258
259
  // This will include the entire THREE namespace by default, users can extend
259
260
  // their own elements by using the createRoot API instead
260
261
  React__namespace.useMemo(() => index.extend(THREE__namespace), []);
261
- const [fiber, setFiber] = React__namespace.useState(null);
262
- const Bridge = index.useContextBridge(fiber);
262
+ const Bridge = itsFine.useContextBridge();
263
263
  const [{
264
264
  width,
265
265
  height,
@@ -370,9 +370,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
370
370
  return () => index.unmountComponentAtNode(canvas);
371
371
  }
372
372
  }, [canvas]);
373
- return /*#__PURE__*/React__namespace.createElement(index.FiberProvider, {
374
- setFiber: setFiber
375
- }, /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, props, {
373
+ return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, props, {
376
374
  ref: viewRef,
377
375
  onLayout: onLayout,
378
376
  style: {
@@ -382,6 +380,16 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
382
380
  }, bind), width > 0 && /*#__PURE__*/React__namespace.createElement(expoGl.GLView, {
383
381
  onContextCreate: onContextCreate,
384
382
  style: reactNative.StyleSheet.absoluteFill
383
+ }));
384
+ });
385
+ /**
386
+ * A native canvas which accepts threejs elements as children.
387
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
388
+ */
389
+
390
+ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
391
+ return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {
392
+ ref: ref
385
393
  })));
386
394
  });
387
395
 
@@ -2,12 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-fb8e3829.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');
9
9
  var reactNative = require('react-native');
10
10
  var expoGl = require('expo-gl');
11
+ var itsFine = require('its-fine');
11
12
  var Pressability = require('react-native/Libraries/Pressability/Pressability');
12
13
  require('react-reconciler/constants');
13
14
  require('zustand');
@@ -236,7 +237,7 @@ function polyfills() {
236
237
  * A native canvas which accepts threejs elements as children.
237
238
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
238
239
  */
239
- const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
240
+ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
240
241
  children,
241
242
  style,
242
243
  gl,
@@ -258,8 +259,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
258
259
  // This will include the entire THREE namespace by default, users can extend
259
260
  // their own elements by using the createRoot API instead
260
261
  React__namespace.useMemo(() => index.extend(THREE__namespace), []);
261
- const [fiber, setFiber] = React__namespace.useState(null);
262
- const Bridge = index.useContextBridge(fiber);
262
+ const Bridge = itsFine.useContextBridge();
263
263
  const [{
264
264
  width,
265
265
  height,
@@ -370,9 +370,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
370
370
  return () => index.unmountComponentAtNode(canvas);
371
371
  }
372
372
  }, [canvas]);
373
- return /*#__PURE__*/React__namespace.createElement(index.FiberProvider, {
374
- setFiber: setFiber
375
- }, /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, props, {
373
+ return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, props, {
376
374
  ref: viewRef,
377
375
  onLayout: onLayout,
378
376
  style: {
@@ -382,6 +380,16 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
382
380
  }, bind), width > 0 && /*#__PURE__*/React__namespace.createElement(expoGl.GLView, {
383
381
  onContextCreate: onContextCreate,
384
382
  style: reactNative.StyleSheet.absoluteFill
383
+ }));
384
+ });
385
+ /**
386
+ * A native canvas which accepts threejs elements as children.
387
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
388
+ */
389
+
390
+ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function CanvasWrapper(props, ref) {
391
+ return /*#__PURE__*/React__namespace.createElement(itsFine.FiberProvider, null, /*#__PURE__*/React__namespace.createElement(CanvasImpl, _extends({}, props, {
392
+ ref: ref
385
393
  })));
386
394
  });
387
395