@react-three/fiber 9.0.0-beta.0 → 9.0.0-rc.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,83 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.17.10
4
+
5
+ ### Patch Changes
6
+
7
+ - d1a072ac: fix: ThreeEvent should not include initMouseEvent
8
+
9
+ ## 8.17.9
10
+
11
+ ### Patch Changes
12
+
13
+ - f34de655: fix: add orientation handling
14
+
15
+ ## 8.17.8
16
+
17
+ ### Patch Changes
18
+
19
+ - 3c885807: fix(types): fix React typings, fault tolerant Node type
20
+
21
+ ## 8.17.7
22
+
23
+ ### Patch Changes
24
+
25
+ - c20a7d73: fix(native): missing pointerId in pointer events
26
+
27
+ ## 8.17.6
28
+
29
+ ### Patch Changes
30
+
31
+ - 66c3e9fe: fix(native): don't bind events to GLView
32
+
33
+ ## 8.17.5
34
+
35
+ ### Patch Changes
36
+
37
+ - 162dbbdd: fix: npmignore ignored types"
38
+
39
+ ## 8.17.4
40
+
41
+ ### Patch Changes
42
+
43
+ - 43866f4e: fix: rebuild with types
44
+
45
+ ## 8.17.3
46
+
47
+ ### Patch Changes
48
+
49
+ - 8363eb7a: fix: rebuild with types
50
+
51
+ ## 8.17.2
52
+
53
+ ### Patch Changes
54
+
55
+ - 6aa4eb28: fix: rebuild with types
56
+
57
+ ## 8.17.1
58
+
59
+ ### Patch Changes
60
+
61
+ - e5f3f4f9: fix: rebuild with types
62
+
63
+ ## 8.17.0
64
+
65
+ ### Minor Changes
66
+
67
+ - 3c22194d: feat: flushSync, native EventTarget
68
+
69
+ ## 8.16.8
70
+
71
+ ### Patch Changes
72
+
73
+ - 4748b365: fix: update is.equ to compare booleans
74
+
75
+ ## 8.16.7
76
+
77
+ ### Patch Changes
78
+
79
+ - 4d6408c7: fix(types): revert usage of future module JSX
80
+
3
81
  ## 8.16.6
4
82
 
5
83
  ### Patch Changes
@@ -77,4 +77,11 @@ export type InjectState = Partial<Omit<RootState, 'events'> & {
77
77
  };
78
78
  }>;
79
79
  export declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): React.JSX.Element;
80
+ /**
81
+ * Force React to flush any updates inside the provided callback synchronously and immediately.
82
+ * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
83
+ * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
84
+ * having to revert to a non-React solution.
85
+ */
86
+ export declare function flushSync<R>(fn: () => R): R;
80
87
  export {};
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { View, ViewProps, ViewStyle } from 'react-native';
2
+ import { View, type ViewProps, type ViewStyle } from 'react-native';
3
3
  import { RenderProps } from "../core/index.js";
4
4
  export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'dpr'>, Omit<ViewProps, 'children'> {
5
5
  children: React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { Options as ResizeOptions } from 'react-use-measure';
2
+ import { Options as ResizeOptions } from "./use-measure.js";
3
3
  import { RenderProps } from "../core/index.js";
4
4
  export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
5
  children: React.ReactNode;
@@ -0,0 +1,34 @@
1
+ declare type ResizeObserverCallback = (entries: any[], observer: ResizeObserver) => void;
2
+ declare class ResizeObserver {
3
+ constructor(callback: ResizeObserverCallback);
4
+ observe(target: Element, options?: any): void;
5
+ unobserve(target: Element): void;
6
+ disconnect(): void;
7
+ static toString(): string;
8
+ }
9
+ export interface RectReadOnly {
10
+ readonly x: number;
11
+ readonly y: number;
12
+ readonly width: number;
13
+ readonly height: number;
14
+ readonly top: number;
15
+ readonly right: number;
16
+ readonly bottom: number;
17
+ readonly left: number;
18
+ [key: string]: number;
19
+ }
20
+ type HTMLOrSVGElement = HTMLElement | SVGElement;
21
+ type Result = [(element: HTMLOrSVGElement | null) => void, RectReadOnly, () => void];
22
+ export type Options = {
23
+ debounce?: number | {
24
+ scroll: number;
25
+ resize: number;
26
+ };
27
+ scroll?: boolean;
28
+ polyfill?: {
29
+ new (cb: ResizeObserverCallback): ResizeObserver;
30
+ };
31
+ offsetSize?: boolean;
32
+ };
33
+ export declare function useMeasure({ debounce, scroll, polyfill, offsetSize }?: Options): Result;
34
+ export {};
@@ -2,11 +2,11 @@ import * as THREE from 'three';
2
2
  import * as React from 'react';
3
3
  import { NoEventPriority, DefaultEventPriority, ContinuousEventPriority, DiscreteEventPriority, ConcurrentRoot } from 'react-reconciler/constants';
4
4
  import { createWithEqualityFn } from 'zustand/traditional';
5
+ import { suspend, preload, clear } from 'suspend-react';
6
+ import { jsx, Fragment } from 'react/jsx-runtime';
5
7
  import { useFiber, useContextBridge, traverseFiber } from 'its-fine';
6
8
  import Reconciler from 'react-reconciler';
7
9
  import { unstable_scheduleCallback, unstable_IdlePriority } from 'scheduler';
8
- import { jsx, Fragment } from 'react/jsx-runtime';
9
- import { suspend, preload, clear } from 'suspend-react';
10
10
 
11
11
  var threeTypes = /*#__PURE__*/Object.freeze({
12
12
  __proto__: null
@@ -289,8 +289,8 @@ function swapInstances() {
289
289
  reconstructed.length = 0;
290
290
  }
291
291
 
292
- // Don't handle text instances, warn on undefined behavior
293
- const handleTextInstance = () => console.warn('R3F: Text is not allowed in JSX! This could be stray whitespace or characters.');
292
+ // Don't handle text instances, make it no-op
293
+ const handleTextInstance = () => {};
294
294
  const NO_CONTEXT = {};
295
295
  let currentUpdatePriority = NoEventPriority;
296
296
 
@@ -546,7 +546,7 @@ const is = {
546
546
  // Wrong type or one of the two undefined, doesn't match
547
547
  if (typeof a !== typeof b || !!a !== !!b) return false;
548
548
  // Atomic, just compare a against b
549
- if (is.str(a) || is.num(a)) return a === b;
549
+ if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
550
550
  const isObj = is.obj(a);
551
551
  if (isObj && objects === 'reference') return a === b;
552
552
  const isArr = is.arr(a);
@@ -754,7 +754,7 @@ function diffProps(instance, newProps) {
754
754
  }
755
755
  return changedProps;
756
756
  }
757
- const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
757
+ typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
758
758
 
759
759
  // const LinearEncoding = 3000
760
760
  const sRGBEncoding = 3001;
@@ -809,12 +809,7 @@ function applyProps(object, props) {
809
809
  }
810
810
 
811
811
  // Copy if properties match signatures
812
- if (target != null && target.copy && (
813
- // Some environments may break strict identity checks by duplicating versions of three.js.
814
- // Loosen to unminified names, ignoring descendents.
815
- // https://github.com/pmndrs/react-three-fiber/issues/2856
816
- // TODO: fix upstream and remove in v9
817
- __DEV__ ? target.constructor.name === value.constructor.name : target.constructor === value.constructor)) {
812
+ if (typeof (target == null ? void 0 : target.copy) === 'function' && target.copy === value.copy) {
818
813
  target.copy(value);
819
814
  }
820
815
  // Layers have no copy function, we must therefore copy the mask property
@@ -2286,4 +2281,90 @@ function advance(timestamp, runGlobalEffects = true, state, frame) {
2286
2281
  if (runGlobalEffects) flushGlobalEffects('after', timestamp);
2287
2282
  }
2288
2283
 
2289
- export { useThree as A, Block as B, useFrame as C, useGraph as D, ErrorBoundary as E, useLoader as F, _roots as _, useMutableCallback as a, useIsomorphicLayoutEffect as b, createEvents as c, createRoot as d, extend as e, unmountComponentAtNode as f, flushGlobalEffects as g, addEffect as h, isRef as i, addAfterEffect as j, addTail as k, invalidate as l, advance as m, render as n, createPortal as o, context as p, applyProps as q, reconciler as r, getRootState as s, threeTypes as t, useBridge as u, dispose as v, act as w, buildGraph as x, useInstanceHandle as y, useStore as z };
2284
+ const DOM_EVENTS = {
2285
+ onClick: ['click', false],
2286
+ onContextMenu: ['contextmenu', false],
2287
+ onDoubleClick: ['dblclick', false],
2288
+ onWheel: ['wheel', true],
2289
+ onPointerDown: ['pointerdown', true],
2290
+ onPointerUp: ['pointerup', true],
2291
+ onPointerLeave: ['pointerleave', true],
2292
+ onPointerMove: ['pointermove', true],
2293
+ onPointerCancel: ['pointercancel', true],
2294
+ onLostPointerCapture: ['lostpointercapture', true]
2295
+ };
2296
+
2297
+ /** Default R3F event manager for web */
2298
+ function createPointerEvents(store) {
2299
+ const {
2300
+ handlePointer
2301
+ } = createEvents(store);
2302
+ return {
2303
+ priority: 1,
2304
+ enabled: true,
2305
+ compute(event, state, previous) {
2306
+ // https://github.com/pmndrs/react-three-fiber/pull/782
2307
+ // Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
2308
+ state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
2309
+ state.raycaster.setFromCamera(state.pointer, state.camera);
2310
+ },
2311
+ connected: undefined,
2312
+ handlers: Object.keys(DOM_EVENTS).reduce((acc, key) => ({
2313
+ ...acc,
2314
+ [key]: handlePointer(key)
2315
+ }), {}),
2316
+ update: () => {
2317
+ var _internal$lastEvent;
2318
+ const {
2319
+ events,
2320
+ internal
2321
+ } = store.getState();
2322
+ if ((_internal$lastEvent = internal.lastEvent) != null && _internal$lastEvent.current && events.handlers) events.handlers.onPointerMove(internal.lastEvent.current);
2323
+ },
2324
+ connect: target => {
2325
+ const {
2326
+ set,
2327
+ events
2328
+ } = store.getState();
2329
+ events.disconnect == null ? void 0 : events.disconnect();
2330
+ set(state => ({
2331
+ events: {
2332
+ ...state.events,
2333
+ connected: target
2334
+ }
2335
+ }));
2336
+ if (events.handlers) {
2337
+ for (const name in events.handlers) {
2338
+ const event = events.handlers[name];
2339
+ const [eventName, passive] = DOM_EVENTS[name];
2340
+ target.addEventListener(eventName, event, {
2341
+ passive
2342
+ });
2343
+ }
2344
+ }
2345
+ },
2346
+ disconnect: () => {
2347
+ const {
2348
+ set,
2349
+ events
2350
+ } = store.getState();
2351
+ if (events.connected) {
2352
+ if (events.handlers) {
2353
+ for (const name in events.handlers) {
2354
+ const event = events.handlers[name];
2355
+ const [eventName] = DOM_EVENTS[name];
2356
+ events.connected.removeEventListener(eventName, event);
2357
+ }
2358
+ }
2359
+ set(state => ({
2360
+ events: {
2361
+ ...state.events,
2362
+ connected: undefined
2363
+ }
2364
+ }));
2365
+ }
2366
+ }
2367
+ };
2368
+ }
2369
+
2370
+ export { useStore as A, Block as B, useThree as C, useFrame as D, ErrorBoundary as E, useGraph as F, useLoader as G, _roots as _, useMutableCallback as a, useIsomorphicLayoutEffect as b, createRoot as c, unmountComponentAtNode as d, extend as e, createPointerEvents as f, createEvents as g, flushGlobalEffects as h, isRef as i, addEffect as j, addAfterEffect as k, addTail as l, invalidate as m, advance as n, render as o, createPortal as p, context as q, reconciler as r, applyProps as s, threeTypes as t, useBridge as u, getRootState as v, dispose as w, act as x, buildGraph as y, useInstanceHandle as z };
@@ -4,11 +4,11 @@ var THREE = require('three');
4
4
  var React = require('react');
5
5
  var constants = require('react-reconciler/constants');
6
6
  var traditional = require('zustand/traditional');
7
+ var suspendReact = require('suspend-react');
8
+ var jsxRuntime = require('react/jsx-runtime');
7
9
  var itsFine = require('its-fine');
8
10
  var Reconciler = require('react-reconciler');
9
11
  var scheduler = require('scheduler');
10
- var jsxRuntime = require('react/jsx-runtime');
11
- var suspendReact = require('suspend-react');
12
12
 
13
13
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
14
 
@@ -315,8 +315,8 @@ function swapInstances() {
315
315
  reconstructed.length = 0;
316
316
  }
317
317
 
318
- // Don't handle text instances, warn on undefined behavior
319
- const handleTextInstance = () => console.warn('R3F: Text is not allowed in JSX! This could be stray whitespace or characters.');
318
+ // Don't handle text instances, make it no-op
319
+ const handleTextInstance = () => {};
320
320
  const NO_CONTEXT = {};
321
321
  let currentUpdatePriority = constants.NoEventPriority;
322
322
 
@@ -572,7 +572,7 @@ const is = {
572
572
  // Wrong type or one of the two undefined, doesn't match
573
573
  if (typeof a !== typeof b || !!a !== !!b) return false;
574
574
  // Atomic, just compare a against b
575
- if (is.str(a) || is.num(a)) return a === b;
575
+ if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
576
576
  const isObj = is.obj(a);
577
577
  if (isObj && objects === 'reference') return a === b;
578
578
  const isArr = is.arr(a);
@@ -780,7 +780,6 @@ function diffProps(instance, newProps) {
780
780
  }
781
781
  return changedProps;
782
782
  }
783
- const __DEV__ = typeof process !== 'undefined' && "production" !== 'production';
784
783
 
785
784
  // const LinearEncoding = 3000
786
785
  const sRGBEncoding = 3001;
@@ -835,12 +834,7 @@ function applyProps(object, props) {
835
834
  }
836
835
 
837
836
  // Copy if properties match signatures
838
- if (target != null && target.copy && (
839
- // Some environments may break strict identity checks by duplicating versions of three.js.
840
- // Loosen to unminified names, ignoring descendents.
841
- // https://github.com/pmndrs/react-three-fiber/issues/2856
842
- // TODO: fix upstream and remove in v9
843
- __DEV__ ? target.constructor.name === value.constructor.name : target.constructor === value.constructor)) {
837
+ if (typeof (target == null ? void 0 : target.copy) === 'function' && target.copy === value.copy) {
844
838
  target.copy(value);
845
839
  }
846
840
  // Layers have no copy function, we must therefore copy the mask property
@@ -2312,6 +2306,92 @@ function advance(timestamp, runGlobalEffects = true, state, frame) {
2312
2306
  if (runGlobalEffects) flushGlobalEffects('after', timestamp);
2313
2307
  }
2314
2308
 
2309
+ const DOM_EVENTS = {
2310
+ onClick: ['click', false],
2311
+ onContextMenu: ['contextmenu', false],
2312
+ onDoubleClick: ['dblclick', false],
2313
+ onWheel: ['wheel', true],
2314
+ onPointerDown: ['pointerdown', true],
2315
+ onPointerUp: ['pointerup', true],
2316
+ onPointerLeave: ['pointerleave', true],
2317
+ onPointerMove: ['pointermove', true],
2318
+ onPointerCancel: ['pointercancel', true],
2319
+ onLostPointerCapture: ['lostpointercapture', true]
2320
+ };
2321
+
2322
+ /** Default R3F event manager for web */
2323
+ function createPointerEvents(store) {
2324
+ const {
2325
+ handlePointer
2326
+ } = createEvents(store);
2327
+ return {
2328
+ priority: 1,
2329
+ enabled: true,
2330
+ compute(event, state, previous) {
2331
+ // https://github.com/pmndrs/react-three-fiber/pull/782
2332
+ // Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
2333
+ state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
2334
+ state.raycaster.setFromCamera(state.pointer, state.camera);
2335
+ },
2336
+ connected: undefined,
2337
+ handlers: Object.keys(DOM_EVENTS).reduce((acc, key) => ({
2338
+ ...acc,
2339
+ [key]: handlePointer(key)
2340
+ }), {}),
2341
+ update: () => {
2342
+ var _internal$lastEvent;
2343
+ const {
2344
+ events,
2345
+ internal
2346
+ } = store.getState();
2347
+ if ((_internal$lastEvent = internal.lastEvent) != null && _internal$lastEvent.current && events.handlers) events.handlers.onPointerMove(internal.lastEvent.current);
2348
+ },
2349
+ connect: target => {
2350
+ const {
2351
+ set,
2352
+ events
2353
+ } = store.getState();
2354
+ events.disconnect == null ? void 0 : events.disconnect();
2355
+ set(state => ({
2356
+ events: {
2357
+ ...state.events,
2358
+ connected: target
2359
+ }
2360
+ }));
2361
+ if (events.handlers) {
2362
+ for (const name in events.handlers) {
2363
+ const event = events.handlers[name];
2364
+ const [eventName, passive] = DOM_EVENTS[name];
2365
+ target.addEventListener(eventName, event, {
2366
+ passive
2367
+ });
2368
+ }
2369
+ }
2370
+ },
2371
+ disconnect: () => {
2372
+ const {
2373
+ set,
2374
+ events
2375
+ } = store.getState();
2376
+ if (events.connected) {
2377
+ if (events.handlers) {
2378
+ for (const name in events.handlers) {
2379
+ const event = events.handlers[name];
2380
+ const [eventName] = DOM_EVENTS[name];
2381
+ events.connected.removeEventListener(eventName, event);
2382
+ }
2383
+ }
2384
+ set(state => ({
2385
+ events: {
2386
+ ...state.events,
2387
+ connected: undefined
2388
+ }
2389
+ }));
2390
+ }
2391
+ }
2392
+ };
2393
+ }
2394
+
2315
2395
  exports.Block = Block;
2316
2396
  exports.ErrorBoundary = ErrorBoundary;
2317
2397
  exports._roots = _roots;
@@ -2324,6 +2404,7 @@ exports.applyProps = applyProps;
2324
2404
  exports.buildGraph = buildGraph;
2325
2405
  exports.context = context;
2326
2406
  exports.createEvents = createEvents;
2407
+ exports.createPointerEvents = createPointerEvents;
2327
2408
  exports.createPortal = createPortal;
2328
2409
  exports.createRoot = createRoot;
2329
2410
  exports.dispose = dispose;
@@ -4,11 +4,11 @@ var THREE = require('three');
4
4
  var React = require('react');
5
5
  var constants = require('react-reconciler/constants');
6
6
  var traditional = require('zustand/traditional');
7
+ var suspendReact = require('suspend-react');
8
+ var jsxRuntime = require('react/jsx-runtime');
7
9
  var itsFine = require('its-fine');
8
10
  var Reconciler = require('react-reconciler');
9
11
  var scheduler = require('scheduler');
10
- var jsxRuntime = require('react/jsx-runtime');
11
- var suspendReact = require('suspend-react');
12
12
 
13
13
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
14
14
 
@@ -315,8 +315,8 @@ function swapInstances() {
315
315
  reconstructed.length = 0;
316
316
  }
317
317
 
318
- // Don't handle text instances, warn on undefined behavior
319
- const handleTextInstance = () => console.warn('R3F: Text is not allowed in JSX! This could be stray whitespace or characters.');
318
+ // Don't handle text instances, make it no-op
319
+ const handleTextInstance = () => {};
320
320
  const NO_CONTEXT = {};
321
321
  let currentUpdatePriority = constants.NoEventPriority;
322
322
 
@@ -572,7 +572,7 @@ const is = {
572
572
  // Wrong type or one of the two undefined, doesn't match
573
573
  if (typeof a !== typeof b || !!a !== !!b) return false;
574
574
  // Atomic, just compare a against b
575
- if (is.str(a) || is.num(a)) return a === b;
575
+ if (is.str(a) || is.num(a) || is.boo(a)) return a === b;
576
576
  const isObj = is.obj(a);
577
577
  if (isObj && objects === 'reference') return a === b;
578
578
  const isArr = is.arr(a);
@@ -780,7 +780,7 @@ function diffProps(instance, newProps) {
780
780
  }
781
781
  return changedProps;
782
782
  }
783
- const __DEV__ = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
783
+ typeof process !== 'undefined' && process.env.NODE_ENV !== 'production';
784
784
 
785
785
  // const LinearEncoding = 3000
786
786
  const sRGBEncoding = 3001;
@@ -835,12 +835,7 @@ function applyProps(object, props) {
835
835
  }
836
836
 
837
837
  // Copy if properties match signatures
838
- if (target != null && target.copy && (
839
- // Some environments may break strict identity checks by duplicating versions of three.js.
840
- // Loosen to unminified names, ignoring descendents.
841
- // https://github.com/pmndrs/react-three-fiber/issues/2856
842
- // TODO: fix upstream and remove in v9
843
- __DEV__ ? target.constructor.name === value.constructor.name : target.constructor === value.constructor)) {
838
+ if (typeof (target == null ? void 0 : target.copy) === 'function' && target.copy === value.copy) {
844
839
  target.copy(value);
845
840
  }
846
841
  // Layers have no copy function, we must therefore copy the mask property
@@ -2312,6 +2307,92 @@ function advance(timestamp, runGlobalEffects = true, state, frame) {
2312
2307
  if (runGlobalEffects) flushGlobalEffects('after', timestamp);
2313
2308
  }
2314
2309
 
2310
+ const DOM_EVENTS = {
2311
+ onClick: ['click', false],
2312
+ onContextMenu: ['contextmenu', false],
2313
+ onDoubleClick: ['dblclick', false],
2314
+ onWheel: ['wheel', true],
2315
+ onPointerDown: ['pointerdown', true],
2316
+ onPointerUp: ['pointerup', true],
2317
+ onPointerLeave: ['pointerleave', true],
2318
+ onPointerMove: ['pointermove', true],
2319
+ onPointerCancel: ['pointercancel', true],
2320
+ onLostPointerCapture: ['lostpointercapture', true]
2321
+ };
2322
+
2323
+ /** Default R3F event manager for web */
2324
+ function createPointerEvents(store) {
2325
+ const {
2326
+ handlePointer
2327
+ } = createEvents(store);
2328
+ return {
2329
+ priority: 1,
2330
+ enabled: true,
2331
+ compute(event, state, previous) {
2332
+ // https://github.com/pmndrs/react-three-fiber/pull/782
2333
+ // Events trigger outside of canvas when moved, use offsetX/Y by default and allow overrides
2334
+ state.pointer.set(event.offsetX / state.size.width * 2 - 1, -(event.offsetY / state.size.height) * 2 + 1);
2335
+ state.raycaster.setFromCamera(state.pointer, state.camera);
2336
+ },
2337
+ connected: undefined,
2338
+ handlers: Object.keys(DOM_EVENTS).reduce((acc, key) => ({
2339
+ ...acc,
2340
+ [key]: handlePointer(key)
2341
+ }), {}),
2342
+ update: () => {
2343
+ var _internal$lastEvent;
2344
+ const {
2345
+ events,
2346
+ internal
2347
+ } = store.getState();
2348
+ if ((_internal$lastEvent = internal.lastEvent) != null && _internal$lastEvent.current && events.handlers) events.handlers.onPointerMove(internal.lastEvent.current);
2349
+ },
2350
+ connect: target => {
2351
+ const {
2352
+ set,
2353
+ events
2354
+ } = store.getState();
2355
+ events.disconnect == null ? void 0 : events.disconnect();
2356
+ set(state => ({
2357
+ events: {
2358
+ ...state.events,
2359
+ connected: target
2360
+ }
2361
+ }));
2362
+ if (events.handlers) {
2363
+ for (const name in events.handlers) {
2364
+ const event = events.handlers[name];
2365
+ const [eventName, passive] = DOM_EVENTS[name];
2366
+ target.addEventListener(eventName, event, {
2367
+ passive
2368
+ });
2369
+ }
2370
+ }
2371
+ },
2372
+ disconnect: () => {
2373
+ const {
2374
+ set,
2375
+ events
2376
+ } = store.getState();
2377
+ if (events.connected) {
2378
+ if (events.handlers) {
2379
+ for (const name in events.handlers) {
2380
+ const event = events.handlers[name];
2381
+ const [eventName] = DOM_EVENTS[name];
2382
+ events.connected.removeEventListener(eventName, event);
2383
+ }
2384
+ }
2385
+ set(state => ({
2386
+ events: {
2387
+ ...state.events,
2388
+ connected: undefined
2389
+ }
2390
+ }));
2391
+ }
2392
+ }
2393
+ };
2394
+ }
2395
+
2315
2396
  exports.Block = Block;
2316
2397
  exports.ErrorBoundary = ErrorBoundary;
2317
2398
  exports._roots = _roots;
@@ -2324,6 +2405,7 @@ exports.applyProps = applyProps;
2324
2405
  exports.buildGraph = buildGraph;
2325
2406
  exports.context = context;
2326
2407
  exports.createEvents = createEvents;
2408
+ exports.createPointerEvents = createPointerEvents;
2327
2409
  exports.createPortal = createPortal;
2328
2410
  exports.createRoot = createRoot;
2329
2411
  exports.dispose = dispose;