@react-three/fiber 9.6.1 → 9.7.0

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +1214 -1204
  2. package/dist/declarations/src/core/events.d.ts +94 -94
  3. package/dist/declarations/src/core/hooks.d.ts +53 -53
  4. package/dist/declarations/src/core/index.d.ts +13 -13
  5. package/dist/declarations/src/core/loop.d.ts +31 -31
  6. package/dist/declarations/src/core/reconciler.d.ts +50 -50
  7. package/dist/declarations/src/core/renderer.d.ts +89 -89
  8. package/dist/declarations/src/core/store.d.ts +130 -130
  9. package/dist/declarations/src/core/utils.d.ts +262 -262
  10. package/dist/declarations/src/index.d.ts +6 -6
  11. package/dist/declarations/src/native/Canvas.d.ts +13 -13
  12. package/dist/declarations/src/native/events.d.ts +4 -4
  13. package/dist/declarations/src/native.d.ts +6 -6
  14. package/dist/declarations/src/three-types.d.ts +68 -68
  15. package/dist/declarations/src/web/Canvas.d.ts +23 -23
  16. package/dist/declarations/src/web/events.d.ts +4 -4
  17. package/dist/{events-b389eeca.esm.js → events-156d8d12.esm.js} +236 -125
  18. package/dist/{events-583399dd.cjs.prod.js → events-4c71f21f.cjs.prod.js} +235 -124
  19. package/dist/{events-f19bcc32.cjs.dev.js → events-b1bdeb1a.cjs.dev.js} +235 -124
  20. package/dist/react-three-fiber.cjs.dev.js +4 -4
  21. package/dist/react-three-fiber.cjs.prod.js +4 -4
  22. package/dist/react-three-fiber.esm.js +5 -5
  23. package/native/dist/react-three-fiber-native.cjs.dev.js +4 -4
  24. package/native/dist/react-three-fiber-native.cjs.prod.js +4 -4
  25. package/native/dist/react-three-fiber-native.esm.js +5 -5
  26. package/native/package.json +5 -5
  27. package/package.json +1 -1
  28. package/readme.md +253 -253
@@ -3,7 +3,7 @@ import React__default from 'react';
3
3
  import * as THREE from 'three';
4
4
  import { createWithEqualityFn } from 'zustand/traditional';
5
5
  import { suspend, preload, clear } from 'suspend-react';
6
- import Tb, { unstable_scheduleCallback, unstable_IdlePriority } from 'scheduler';
6
+ import Tb, { unstable_getCurrentPriorityLevel, unstable_IdlePriority, unstable_LowPriority, unstable_NormalPriority, unstable_UserBlockingPriority, unstable_ImmediatePriority, unstable_scheduleCallback } from 'scheduler';
7
7
  import { jsx, Fragment } from 'react/jsx-runtime';
8
8
  import { useFiber, useContextBridge, traverseFiber } from 'its-fine';
9
9
 
@@ -11,17 +11,17 @@ var threeTypes = /*#__PURE__*/Object.freeze({
11
11
  __proto__: null
12
12
  });
13
13
 
14
- /**
15
- * Returns the instance's initial (outmost) root.
14
+ /**
15
+ * Returns the instance's initial (outmost) root.
16
16
  */
17
17
  function findInitialRoot(instance) {
18
18
  let root = instance.root;
19
19
  while (root.getState().previousRoot) root = root.getState().previousRoot;
20
20
  return root;
21
21
  }
22
- /**
23
- * Safely flush async effects when testing, simulating a legacy root.
24
- * @deprecated Import from React instead. import { act } from 'react'
22
+ /**
23
+ * Safely flush async effects when testing, simulating a legacy root.
24
+ * @deprecated Import from React instead. import { act } from 'react'
25
25
  */
26
26
  // Reference with computed key to break Webpack static analysis
27
27
  // https://github.com/webpack/webpack/issues/14814
@@ -30,14 +30,14 @@ const isOrthographicCamera = def => def && def.isOrthographicCamera;
30
30
  const isRef = obj => obj && obj.hasOwnProperty('current');
31
31
  const isColorRepresentation = value => value != null && (typeof value === 'string' || typeof value === 'number' || value.isColor);
32
32
 
33
- /**
34
- * An SSR-friendly useLayoutEffect.
35
- *
36
- * React currently throws a warning when using useLayoutEffect on the server.
37
- * To get around it, we can conditionally useEffect on the server (no-op) and
38
- * useLayoutEffect elsewhere.
39
- *
40
- * @see https://github.com/facebook/react/issues/14927
33
+ /**
34
+ * An SSR-friendly useLayoutEffect.
35
+ *
36
+ * React currently throws a warning when using useLayoutEffect on the server.
37
+ * To get around it, we can conditionally useEffect on the server (no-op) and
38
+ * useLayoutEffect elsewhere.
39
+ *
40
+ * @see https://github.com/facebook/react/issues/14927
41
41
  */
42
42
  const useIsomorphicLayoutEffect = /* @__PURE__ */((_window$document, _window$navigator) => typeof window !== 'undefined' && (((_window$document = window.document) == null ? void 0 : _window$document.createElement) || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative'))() ? React.useLayoutEffect : React.useEffect;
43
43
  function useMutableCallback(fn) {
@@ -45,8 +45,8 @@ function useMutableCallback(fn) {
45
45
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
46
46
  return ref;
47
47
  }
48
- /**
49
- * Bridges renderer Context and StrictMode from a primary renderer.
48
+ /**
49
+ * Bridges renderer Context and StrictMode from a primary renderer.
50
50
  */
51
51
  function useBridge() {
52
52
  const fiber = useFiber();
@@ -98,8 +98,8 @@ function calculateDpr(dpr) {
98
98
  return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
99
99
  }
100
100
 
101
- /**
102
- * Returns instance root state
101
+ /**
102
+ * Returns instance root state
103
103
  */
104
104
  function getRootState(obj) {
105
105
  var _r3f;
@@ -355,10 +355,10 @@ function diffProps(instance, newProps) {
355
355
  if (root.constructor && root.constructor.length === 0) {
356
356
  // create a blank slate of the instance and copy the particular parameter.
357
357
  const ctor = getMemoizedPrototype(root);
358
- if (!is.und(ctor)) changedProps[key] = ctor[key];
358
+ if (!is.und(ctor)) changedProps[prop] = ctor[key];
359
359
  } else {
360
360
  // instance does not have constructor, just set it to 0
361
- changedProps[key] = 0;
361
+ changedProps[prop] = 0;
362
362
  }
363
363
  }
364
364
  return changedProps;
@@ -502,9 +502,9 @@ function makeId(event) {
502
502
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
503
503
  }
504
504
 
505
- /**
506
- * Release pointer captures.
507
- * This is called by releasePointerCapture in the API, and when an object is removed.
505
+ /**
506
+ * Release pointer captures.
507
+ * This is called by releasePointerCapture in the API, and when an object is removed.
508
508
  */
509
509
  function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
510
510
  const captureData = captures.get(obj);
@@ -882,19 +882,19 @@ function createEvents(store) {
882
882
  if (!(instance != null && instance.eventCount)) return;
883
883
  const handlers = instance.handlers;
884
884
 
885
- /*
886
- MAYBE TODO, DELETE IF NOT:
887
- Check if the object is captured, captured events should not have intersects running in parallel
888
- But wouldn't it be better to just replace capturedMap with a single entry?
889
- Also, are we OK with straight up making picking up multiple objects impossible?
890
-
891
- const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
892
- if (pointerId !== undefined) {
893
- const capturedMeshSet = internal.capturedMap.get(pointerId)
894
- if (capturedMeshSet) {
895
- const captured = capturedMeshSet.get(eventObject)
896
- if (captured && captured.localState.stopped) return
897
- }
885
+ /*
886
+ MAYBE TODO, DELETE IF NOT:
887
+ Check if the object is captured, captured events should not have intersects running in parallel
888
+ But wouldn't it be better to just replace capturedMap with a single entry?
889
+ Also, are we OK with straight up making picking up multiple objects impossible?
890
+
891
+ const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
892
+ if (pointerId !== undefined) {
893
+ const capturedMeshSet = internal.capturedMap.get(pointerId)
894
+ if (capturedMeshSet) {
895
+ const captured = capturedMeshSet.get(eventObject)
896
+ if (captured && captured.localState.stopped) return
897
+ }
898
898
  }*/
899
899
 
900
900
  if (isPointerMove) {
@@ -1185,11 +1185,11 @@ const createStore = (invalidate, advance) => {
1185
1185
  return rootStore;
1186
1186
  };
1187
1187
 
1188
- /**
1189
- * Exposes an object's {@link Instance}.
1190
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1191
- *
1192
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1188
+ /**
1189
+ * Exposes an object's {@link Instance}.
1190
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1191
+ *
1192
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1193
1193
  */
1194
1194
  function useInstanceHandle(ref) {
1195
1195
  const instance = React.useRef(null);
@@ -1197,9 +1197,9 @@ function useInstanceHandle(ref) {
1197
1197
  return instance;
1198
1198
  }
1199
1199
 
1200
- /**
1201
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1202
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1200
+ /**
1201
+ * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1202
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1203
1203
  */
1204
1204
  function useStore() {
1205
1205
  const store = React.useContext(context);
@@ -1207,18 +1207,18 @@ function useStore() {
1207
1207
  return store;
1208
1208
  }
1209
1209
 
1210
- /**
1211
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1212
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1210
+ /**
1211
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1212
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1213
1213
  */
1214
1214
  function useThree(selector = state => state, equalityFn) {
1215
1215
  return useStore()(selector, equalityFn);
1216
1216
  }
1217
1217
 
1218
- /**
1219
- * Executes a callback before render in a shared frame loop.
1220
- * Can order effects with render priority or manually render with a positive priority.
1221
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1218
+ /**
1219
+ * Executes a callback before render in a shared frame loop.
1220
+ * Can order effects with render priority or manually render with a positive priority.
1221
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1222
1222
  */
1223
1223
  function useFrame(callback, renderPriority = 0) {
1224
1224
  const store = useStore();
@@ -1230,9 +1230,9 @@ function useFrame(callback, renderPriority = 0) {
1230
1230
  return null;
1231
1231
  }
1232
1232
 
1233
- /**
1234
- * Returns a node graph of an object with named nodes & materials.
1235
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1233
+ /**
1234
+ * Returns a node graph of an object with named nodes & materials.
1235
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1236
1236
  */
1237
1237
  function useGraph(object) {
1238
1238
  return React.useMemo(() => buildGraph(object), [object]);
@@ -1268,11 +1268,11 @@ function loadingFn(extensions, onProgress) {
1268
1268
  };
1269
1269
  }
1270
1270
 
1271
- /**
1272
- * Synchronously loads and caches assets with a three loader.
1273
- *
1274
- * Note: this hook's caller must be wrapped with `React.Suspense`
1275
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1271
+ /**
1272
+ * Synchronously loads and caches assets with a three loader.
1273
+ *
1274
+ * Note: this hook's caller must be wrapped with `React.Suspense`
1275
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1276
1276
  */
1277
1277
  function useLoader(loader, input, extensions, onProgress) {
1278
1278
  // Use suspense to load async assets
@@ -1284,16 +1284,16 @@ function useLoader(loader, input, extensions, onProgress) {
1284
1284
  return Array.isArray(input) ? results : results[0];
1285
1285
  }
1286
1286
 
1287
- /**
1288
- * Preloads an asset into cache as a side-effect.
1287
+ /**
1288
+ * Preloads an asset into cache as a side-effect.
1289
1289
  */
1290
1290
  useLoader.preload = function (loader, input, extensions) {
1291
1291
  const keys = Array.isArray(input) ? input : [input];
1292
1292
  return preload(loadingFn(extensions), [loader, ...keys]);
1293
1293
  };
1294
1294
 
1295
- /**
1296
- * Removes a loaded asset from cache.
1295
+ /**
1296
+ * Removes a loaded asset from cache.
1297
1297
  */
1298
1298
  useLoader.clear = function (loader, input) {
1299
1299
  const keys = Array.isArray(input) ? input : [input];
@@ -1311,11 +1311,12 @@ useLoader.clear = function (loader, input) {
1311
1311
  */const t = 1,
1312
1312
  o = 8,
1313
1313
  r = 32,
1314
- e = 2;
1314
+ e = 2,
1315
+ i$1 = 268435456;
1315
1316
 
1316
1317
  var packageData = {
1317
1318
  name: "@react-three/fiber",
1318
- version: "9.6.1",
1319
+ version: "9.7.0",
1319
1320
  description: "A React renderer for Threejs",
1320
1321
  keywords: [
1321
1322
  "react",
@@ -15151,6 +15152,12 @@ function handleContainerEffects(parent, child, beforeChild) {
15151
15152
  function appendChild(parent, child) {
15152
15153
  if (!child) return;
15153
15154
 
15155
+ // Move an existing child instead of duplicating it
15156
+ if (child.parent === parent) {
15157
+ const childIndex = parent.children.indexOf(child);
15158
+ if (childIndex !== -1) parent.children.splice(childIndex, 1);
15159
+ }
15160
+
15154
15161
  // Link instances
15155
15162
  child.parent = parent;
15156
15163
  parent.children.push(child);
@@ -15161,6 +15168,12 @@ function appendChild(parent, child) {
15161
15168
  function insertBefore(parent, child, beforeChild) {
15162
15169
  if (!child || !beforeChild) return;
15163
15170
 
15171
+ // Move an existing child instead of duplicating it.
15172
+ if (child.parent === parent) {
15173
+ const childIndex = parent.children.indexOf(child);
15174
+ if (childIndex !== -1) parent.children.splice(childIndex, 1);
15175
+ }
15176
+
15164
15177
  // Link instances
15165
15178
  child.parent = parent;
15166
15179
  const childIndex = parent.children.indexOf(beforeChild);
@@ -15241,7 +15254,15 @@ function setFiberRef(fiber, publicInstance) {
15241
15254
  }
15242
15255
  }
15243
15256
  const reconstructed = [];
15244
- function swapInstances() {
15257
+ function flushReconstructedInstances() {
15258
+ if (reconstructed.length === 0) return;
15259
+ try {
15260
+ swapReconstructedInstances();
15261
+ } finally {
15262
+ reconstructed.length = 0;
15263
+ }
15264
+ }
15265
+ function swapReconstructedInstances() {
15245
15266
  // Detach instance
15246
15267
  for (const [instance] of reconstructed) {
15247
15268
  const parent = instance.parent;
@@ -15304,7 +15325,6 @@ function swapInstances() {
15304
15325
  invalidateInstance(instance);
15305
15326
  }
15306
15327
  }
15307
- reconstructed.length = 0;
15308
15328
  }
15309
15329
 
15310
15330
  // Don't handle text instances, make it no-op
@@ -15312,9 +15332,112 @@ const handleTextInstance = () => {};
15312
15332
  const NO_CONTEXT = {};
15313
15333
  let currentUpdatePriority = NoEventPriority;
15314
15334
 
15315
- // https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactFiberFlags.js
15316
- const NoFlags = 0;
15317
- const Update = 4;
15335
+ // Mirrors react-dom's getEventPriority for parity with events outside of React
15336
+ // https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/events/ReactDOMEventListener.js
15337
+ function getEventPriority(type) {
15338
+ switch (type) {
15339
+ case 'beforetoggle':
15340
+ case 'cancel':
15341
+ case 'click':
15342
+ case 'close':
15343
+ case 'contextmenu':
15344
+ case 'copy':
15345
+ case 'cut':
15346
+ case 'auxclick':
15347
+ case 'dblclick':
15348
+ case 'dragend':
15349
+ case 'dragstart':
15350
+ case 'drop':
15351
+ case 'focusin':
15352
+ case 'focusout':
15353
+ case 'input':
15354
+ case 'invalid':
15355
+ case 'keydown':
15356
+ case 'keypress':
15357
+ case 'keyup':
15358
+ case 'mousedown':
15359
+ case 'mouseup':
15360
+ case 'paste':
15361
+ case 'pause':
15362
+ case 'play':
15363
+ case 'pointercancel':
15364
+ case 'pointerdown':
15365
+ case 'pointerup':
15366
+ case 'ratechange':
15367
+ case 'reset':
15368
+ case 'resize':
15369
+ case 'seeked':
15370
+ case 'submit':
15371
+ case 'touchcancel':
15372
+ case 'touchend':
15373
+ case 'touchstart':
15374
+ case 'volumechange':
15375
+ case 'change':
15376
+ case 'selectionchange':
15377
+ case 'compositionstart':
15378
+ case 'compositionend':
15379
+ case 'compositionupdate':
15380
+ case 'beforeinput':
15381
+ case 'blur':
15382
+ case 'fullscreenchange':
15383
+ case 'focus':
15384
+ case 'hashchange':
15385
+ case 'popstate':
15386
+ case 'select':
15387
+ case 'selectstart':
15388
+ return e;
15389
+ case 'drag':
15390
+ case 'dragenter':
15391
+ case 'dragexit':
15392
+ case 'dragleave':
15393
+ case 'dragover':
15394
+ case 'mousemove':
15395
+ case 'mouseout':
15396
+ case 'mouseover':
15397
+ case 'pointermove':
15398
+ case 'pointerout':
15399
+ case 'pointerover':
15400
+ case 'scroll':
15401
+ case 'touchmove':
15402
+ case 'wheel':
15403
+ case 'mouseenter':
15404
+ case 'mouseleave':
15405
+ case 'pointerenter':
15406
+ case 'pointerleave':
15407
+ return o;
15408
+ case 'message':
15409
+ {
15410
+ switch (unstable_getCurrentPriorityLevel()) {
15411
+ case unstable_ImmediatePriority:
15412
+ return e;
15413
+ case unstable_UserBlockingPriority:
15414
+ return o;
15415
+ case unstable_NormalPriority:
15416
+ case unstable_LowPriority:
15417
+ return r;
15418
+ case unstable_IdlePriority:
15419
+ return i$1;
15420
+ default:
15421
+ return r;
15422
+ }
15423
+ }
15424
+ default:
15425
+ return r;
15426
+ }
15427
+ }
15428
+ function scheduleMicrotask(callback) {
15429
+ if (typeof queueMicrotask === 'function') {
15430
+ queueMicrotask(callback);
15431
+ } else if (typeof Promise !== 'undefined') {
15432
+ Promise.resolve().then(callback).catch(error => {
15433
+ setTimeout(() => {
15434
+ throw error;
15435
+ });
15436
+ });
15437
+ } else {
15438
+ setTimeout(callback);
15439
+ }
15440
+ }
15318
15441
  const reconciler = /* @__PURE__ */createReconciler({
15319
15442
  isPrimaryRenderer: false,
15320
15443
  warnsIfNotActing: false,
@@ -15358,30 +15481,30 @@ const reconciler = /* @__PURE__ */createReconciler({
15358
15481
  return value !== ((_oldProps$args2 = oldProps.args) == null ? void 0 : _oldProps$args2[index]);
15359
15482
  })) reconstruct = true;
15360
15483
 
15361
- // Reconstruct when args or <primitive object={...} have changes
15484
+ // Reconstruct when args or <primitive object={...} have changes.
15485
+ // Instances are swapped at the end of the mutation phase (resetAfterCommit)
15362
15486
  if (reconstruct) {
15363
- reconstructed.push([instance, {
15364
- ...newProps
15365
- }, fiber]);
15487
+ reconstructed.push([instance, getInstanceProps(newProps), fiber]);
15366
15488
  } else {
15367
15489
  // Create a diff-set, flag if there are any changes
15368
15490
  const changedProps = diffProps(instance, newProps);
15369
- if (Object.keys(changedProps).length) {
15370
- Object.assign(instance.props, changedProps);
15371
- applyProps(instance.object, changedProps);
15372
- }
15373
- }
15374
15491
 
15375
- // Flush reconstructed siblings when we hit the last updated child in a sequence
15376
- const isTailSibling = fiber.sibling === null || (fiber.flags & Update) === NoFlags;
15377
- if (isTailSibling) swapInstances();
15492
+ // Replace the old prop snapshot after computing the diff
15493
+ //`attach` is preserved since it cannot be updated dynamically
15494
+ const attach = instance.props.attach;
15495
+ instance.props = getInstanceProps(newProps);
15496
+ if (attach !== undefined) instance.props.attach = attach;else delete instance.props.attach;
15497
+ if (Object.keys(changedProps).length) applyProps(instance.object, changedProps);
15498
+ }
15378
15499
  },
15379
15500
  finalizeInitialChildren: () => false,
15380
15501
  commitMount() {},
15381
15502
  getPublicInstance: instance => instance == null ? void 0 : instance.object,
15382
15503
  prepareForCommit: () => null,
15383
15504
  preparePortalMount: container => prepare(container.getState().scene, container, '', {}),
15384
- resetAfterCommit: () => {},
15505
+ // Reconstructed instances are swapped once all mutations are committed,
15506
+ // before layout effects run so refs point to the new objects
15507
+ resetAfterCommit: flushReconstructedInstances,
15385
15508
  shouldSetTextContent: () => false,
15386
15509
  clearContainer: () => false,
15387
15510
  hideInstance,
@@ -15389,6 +15512,9 @@ const reconciler = /* @__PURE__ */createReconciler({
15389
15512
  createTextInstance: handleTextInstance,
15390
15513
  hideTextInstance: handleTextInstance,
15391
15514
  unhideTextInstance: handleTextInstance,
15515
+ // Mirrors react-dom, which flushes discrete work in microtasks
15516
+ supportsMicrotasks: true,
15517
+ scheduleMicrotask,
15392
15518
  scheduleTimeout: typeof setTimeout === 'function' ? setTimeout : undefined,
15393
15519
  cancelTimeout: typeof clearTimeout === 'function' ? clearTimeout : undefined,
15394
15520
  noTimeout: -1,
@@ -15421,24 +15547,9 @@ const reconciler = /* @__PURE__ */createReconciler({
15421
15547
  resolveUpdatePriority() {
15422
15548
  var _window$event;
15423
15549
  if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
15424
- switch (typeof window !== 'undefined' && ((_window$event = window.event) == null ? void 0 : _window$event.type)) {
15425
- case 'click':
15426
- case 'contextmenu':
15427
- case 'dblclick':
15428
- case 'pointercancel':
15429
- case 'pointerdown':
15430
- case 'pointerup':
15431
- return e;
15432
- case 'pointermove':
15433
- case 'pointerout':
15434
- case 'pointerover':
15435
- case 'pointerenter':
15436
- case 'pointerleave':
15437
- case 'wheel':
15438
- return o;
15439
- default:
15440
- return r;
15441
- }
15550
+ const eventType = typeof window !== 'undefined' ? (_window$event = window.event) == null ? void 0 : _window$event.type : undefined;
15551
+ if (eventType === undefined) return r;
15552
+ return getEventPriority(eventType);
15442
15553
  },
15443
15554
  resetFormInstance() {},
15444
15555
  // @ts-ignore DefinitelyTyped is not up to date
@@ -15895,10 +16006,10 @@ function Portal({
15895
16006
  children,
15896
16007
  container
15897
16008
  }) {
15898
- /** This has to be a component because it would not be able to call useThree/useStore otherwise since
15899
- * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
15900
- * the "R3F hooks can only be used within the Canvas component!" warning:
15901
- * <Canvas>
16009
+ /** This has to be a component because it would not be able to call useThree/useStore otherwise since
16010
+ * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
16011
+ * the "R3F hooks can only be used within the Canvas component!" warning:
16012
+ * <Canvas>
15902
16013
  * {createPortal(...)} */
15903
16014
  const {
15904
16015
  events,
@@ -15979,11 +16090,11 @@ function Portal({
15979
16090
  );
15980
16091
  }
15981
16092
 
15982
- /**
15983
- * Force React to flush any updates inside the provided callback synchronously and immediately.
15984
- * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
15985
- * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
15986
- * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
16093
+ /**
16094
+ * Force React to flush any updates inside the provided callback synchronously and immediately.
16095
+ * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
16096
+ * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
16097
+ * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
15987
16098
  */
15988
16099
  function flushSync(fn) {
15989
16100
  // @ts-ignore - reconciler types are not maintained
@@ -16001,21 +16112,21 @@ const globalEffects = new Set();
16001
16112
  const globalAfterEffects = new Set();
16002
16113
  const globalTailEffects = new Set();
16003
16114
 
16004
- /**
16005
- * Adds a global render callback which is called each frame.
16006
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
16115
+ /**
16116
+ * Adds a global render callback which is called each frame.
16117
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
16007
16118
  */
16008
16119
  const addEffect = callback => createSubs(callback, globalEffects);
16009
16120
 
16010
- /**
16011
- * Adds a global after-render callback which is called each frame.
16012
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
16121
+ /**
16122
+ * Adds a global after-render callback which is called each frame.
16123
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
16013
16124
  */
16014
16125
  const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
16015
16126
 
16016
- /**
16017
- * Adds a global callback which is called when rendering stops.
16018
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
16127
+ /**
16128
+ * Adds a global callback which is called when rendering stops.
16129
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
16019
16130
  */
16020
16131
  const addTail = callback => createSubs(callback, globalTailEffects);
16021
16132
  function run(effects, timestamp) {
@@ -16103,9 +16214,9 @@ function loop(timestamp) {
16103
16214
  }
16104
16215
  }
16105
16216
 
16106
- /**
16107
- * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
16108
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
16217
+ /**
16218
+ * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
16219
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
16109
16220
  */
16110
16221
  function invalidate(state, frames = 1) {
16111
16222
  var _state$gl$xr2;
@@ -16132,9 +16243,9 @@ function invalidate(state, frames = 1) {
16132
16243
  }
16133
16244
  }
16134
16245
 
16135
- /**
16136
- * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
16137
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
16246
+ /**
16247
+ * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
16248
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
16138
16249
  */
16139
16250
  function advance(timestamp, runGlobalEffects = true, state, frame) {
16140
16251
  if (runGlobalEffects) flushGlobalEffects('before', timestamp);