@react-three/fiber 8.7.4 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 370d3ae5: refactor: pull context bridge from its-fine
8
+
9
+ ## 8.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 46d8b440: bridge cross-container context
14
+
3
15
  ## 8.7.4
4
16
 
5
17
  ### Patch Changes
@@ -7,6 +7,7 @@ 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,6 +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), []);
146
+ const Bridge = itsFine.useContextBridge();
149
147
  const [containerRef, containerRect] = useMeasure__default["default"]({
150
148
  scroll: true,
151
149
  debounce: {
@@ -204,13 +202,13 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
204
202
  onCreated == null ? void 0 : onCreated(state);
205
203
  }
206
204
  });
207
- root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
205
+ root.current.render( /*#__PURE__*/React__namespace.createElement(Bridge, null, /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
208
206
  set: setError
209
207
  }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
210
208
  fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
211
209
  set: setBlock
212
210
  })
213
- }, children)));
211
+ }, children))));
214
212
  }
215
213
 
216
214
  index.useIsomorphicLayoutEffect(() => {
@@ -245,6 +243,16 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
245
243
  }
246
244
  }, fallback)));
247
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
+ })));
255
+ });
248
256
 
249
257
  exports.ReactThreeFiber = index.threeTypes;
250
258
  exports._roots = index.roots;
@@ -7,6 +7,7 @@ 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,6 +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), []);
146
+ const Bridge = itsFine.useContextBridge();
149
147
  const [containerRef, containerRect] = useMeasure__default["default"]({
150
148
  scroll: true,
151
149
  debounce: {
@@ -204,13 +202,13 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
204
202
  onCreated == null ? void 0 : onCreated(state);
205
203
  }
206
204
  });
207
- root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
205
+ root.current.render( /*#__PURE__*/React__namespace.createElement(Bridge, null, /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
208
206
  set: setError
209
207
  }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
210
208
  fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
211
209
  set: setBlock
212
210
  })
213
- }, children)));
211
+ }, children))));
214
212
  }
215
213
 
216
214
  index.useIsomorphicLayoutEffect(() => {
@@ -245,6 +243,16 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
245
243
  }
246
244
  }, fallback)));
247
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
+ })));
255
+ });
248
256
 
249
257
  exports.ReactThreeFiber = index.threeTypes;
250
258
  exports._roots = index.roots;
@@ -4,6 +4,7 @@ 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,6 +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), []);
119
+ const Bridge = useContextBridge();
122
120
  const [containerRef, containerRect] = useMeasure({
123
121
  scroll: true,
124
122
  debounce: {
@@ -177,13 +175,13 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
177
175
  onCreated == null ? void 0 : onCreated(state);
178
176
  }
179
177
  });
180
- root.current.render( /*#__PURE__*/React.createElement(ErrorBoundary, {
178
+ root.current.render( /*#__PURE__*/React.createElement(Bridge, null, /*#__PURE__*/React.createElement(ErrorBoundary, {
181
179
  set: setError
182
180
  }, /*#__PURE__*/React.createElement(React.Suspense, {
183
181
  fallback: /*#__PURE__*/React.createElement(Block, {
184
182
  set: setBlock
185
183
  })
186
- }, children)));
184
+ }, children))));
187
185
  }
188
186
 
189
187
  useIsomorphicLayoutEffect(() => {
@@ -218,5 +216,15 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
218
216
  }
219
217
  }, fallback)));
220
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
+ })));
228
+ });
221
229
 
222
230
  export { Canvas, createPointerEvents as events };
@@ -8,6 +8,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,6 +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), []);
262
+ const Bridge = itsFine.useContextBridge();
261
263
  const [{
262
264
  width,
263
265
  height,
@@ -354,13 +356,13 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
354
356
  return onCreated == null ? void 0 : onCreated(state);
355
357
  }
356
358
  });
357
- root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
359
+ root.current.render( /*#__PURE__*/React__namespace.createElement(Bridge, null, /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
358
360
  set: setError
359
361
  }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
360
362
  fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
361
363
  set: setBlock
362
364
  })
363
- }, children)));
365
+ }, children))));
364
366
  }
365
367
 
366
368
  React__namespace.useEffect(() => {
@@ -380,6 +382,16 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
380
382
  style: reactNative.StyleSheet.absoluteFill
381
383
  }));
382
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
393
+ })));
394
+ });
383
395
 
384
396
  exports.ReactThreeFiber = index.threeTypes;
385
397
  exports._roots = index.roots;
@@ -8,6 +8,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,6 +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), []);
262
+ const Bridge = itsFine.useContextBridge();
261
263
  const [{
262
264
  width,
263
265
  height,
@@ -354,13 +356,13 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
354
356
  return onCreated == null ? void 0 : onCreated(state);
355
357
  }
356
358
  });
357
- root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
359
+ root.current.render( /*#__PURE__*/React__namespace.createElement(Bridge, null, /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
358
360
  set: setError
359
361
  }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
360
362
  fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
361
363
  set: setBlock
362
364
  })
363
- }, children)));
365
+ }, children))));
364
366
  }
365
367
 
366
368
  React__namespace.useEffect(() => {
@@ -380,6 +382,16 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
380
382
  style: reactNative.StyleSheet.absoluteFill
381
383
  }));
382
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
393
+ })));
394
+ });
383
395
 
384
396
  exports.ReactThreeFiber = index.threeTypes;
385
397
  exports._roots = index.roots;
@@ -5,6 +5,7 @@ import * as React from 'react';
5
5
  import * as THREE from 'three';
6
6
  import { PixelRatio, View, StyleSheet } from 'react-native';
7
7
  import { GLView } from 'expo-gl';
8
+ import { FiberProvider, useContextBridge } from 'its-fine';
8
9
  import Pressability from 'react-native/Libraries/Pressability/Pressability';
9
10
  import 'react-reconciler/constants';
10
11
  import 'zustand';
@@ -209,7 +210,7 @@ function polyfills() {
209
210
  * A native canvas which accepts threejs elements as children.
210
211
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
211
212
  */
212
- const Canvas = /*#__PURE__*/React.forwardRef(({
213
+ const CanvasImpl = /*#__PURE__*/React.forwardRef(({
213
214
  children,
214
215
  style,
215
216
  gl,
@@ -231,6 +232,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
231
232
  // This will include the entire THREE namespace by default, users can extend
232
233
  // their own elements by using the createRoot API instead
233
234
  React.useMemo(() => extend(THREE), []);
235
+ const Bridge = useContextBridge();
234
236
  const [{
235
237
  width,
236
238
  height,
@@ -327,13 +329,13 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
327
329
  return onCreated == null ? void 0 : onCreated(state);
328
330
  }
329
331
  });
330
- root.current.render( /*#__PURE__*/React.createElement(ErrorBoundary, {
332
+ root.current.render( /*#__PURE__*/React.createElement(Bridge, null, /*#__PURE__*/React.createElement(ErrorBoundary, {
331
333
  set: setError
332
334
  }, /*#__PURE__*/React.createElement(React.Suspense, {
333
335
  fallback: /*#__PURE__*/React.createElement(Block, {
334
336
  set: setBlock
335
337
  })
336
- }, children)));
338
+ }, children))));
337
339
  }
338
340
 
339
341
  React.useEffect(() => {
@@ -353,5 +355,15 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
353
355
  style: StyleSheet.absoluteFill
354
356
  }));
355
357
  });
358
+ /**
359
+ * A native canvas which accepts threejs elements as children.
360
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
361
+ */
362
+
363
+ const Canvas = /*#__PURE__*/React.forwardRef(function CanvasWrapper(props, ref) {
364
+ return /*#__PURE__*/React.createElement(FiberProvider, null, /*#__PURE__*/React.createElement(CanvasImpl, _extends({}, props, {
365
+ ref: ref
366
+ })));
367
+ });
356
368
 
357
369
  export { Canvas, createTouchEvents as events };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.7.4",
3
+ "version": "8.8.1",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -44,6 +44,7 @@
44
44
  "dependencies": {
45
45
  "@babel/runtime": "^7.17.8",
46
46
  "@types/react-reconciler": "^0.26.7",
47
+ "its-fine": "^1.0.0",
47
48
  "react-reconciler": "^0.27.0",
48
49
  "react-use-measure": "^2.1.1",
49
50
  "scheduler": "^0.21.0",