From babca2f47abfebee8f5ac355c49ae2fb7a7add7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Tue, 14 Apr 2026 14:35:37 +0200 Subject: [PATCH 1/2] Fix imports issues --- .../src/RNGestureHandlerModule.web.ts | 9 +-- .../src/RNGestureHandlerModule.windows.ts | 19 ++--- .../src/__tests__/Errors.test.tsx | 6 +- .../src/__tests__/Events.test.tsx | 12 +-- .../src/__tests__/RelationsTraversal.test.tsx | 9 ++- .../src/__tests__/api_v3.test.tsx | 10 +-- .../src/__tests__/mocks.test.tsx | 21 ++--- .../src/components/GestureButtons.tsx | 24 +++--- .../src/components/GestureButtonsProps.ts | 4 +- .../src/components/GestureComponents.tsx | 29 +++---- .../src/components/GestureComponents.web.tsx | 5 +- .../src/components/GestureHandlerButton.tsx | 2 +- .../components/GestureHandlerButton.web.tsx | 3 +- .../GestureHandlerRootView.android.tsx | 6 +- .../src/components/GestureHandlerRootView.tsx | 4 +- .../components/GestureHandlerRootView.web.tsx | 5 +- .../src/components/Pressable/Pressable.tsx | 45 +++++------ .../components/Pressable/PressableProps.tsx | 14 ++-- .../src/components/Pressable/StateMachine.tsx | 2 +- .../components/Pressable/stateDefinitions.ts | 4 +- .../src/components/Pressable/utils.ts | 16 ++-- .../src/components/ReanimatedDrawerLayout.tsx | 64 +++++++-------- .../ReanimatedSwipeable.tsx | 29 ++++--- .../ReanimatedSwipeableProps.ts | 10 +-- .../src/components/Text.tsx | 11 +-- .../touchables/GenericTouchable.tsx | 12 ++- .../touchables/GenericTouchableProps.ts | 6 +- .../touchables/TouchableHighlight.tsx | 13 ++- .../TouchableNativeFeedback.android.tsx | 11 +-- .../TouchableNativeFeedbackProps.tsx | 4 +- .../touchables/TouchableOpacity.tsx | 13 +-- .../touchables/TouchableWithoutFeedback.tsx | 2 +- .../src/components/utils.ts | 2 +- .../src/findNodeHandle.web.ts | 2 +- .../src/handlers/FlingGestureHandler.ts | 6 +- .../src/handlers/ForceTouchGestureHandler.ts | 13 ++- .../handlers/GestureHandlerEventPayload.ts | 2 +- .../src/handlers/LongPressGestureHandler.ts | 8 +- .../src/handlers/NativeViewGestureHandler.ts | 6 +- .../src/handlers/PanGestureHandler.ts | 6 +- .../src/handlers/PinchGestureHandler.ts | 8 +- .../src/handlers/RotationGestureHandler.ts | 8 +- .../src/handlers/TapGestureHandler.ts | 6 +- .../src/handlers/createHandler.tsx | 40 +++++----- .../src/handlers/createNativeWrapper.tsx | 5 +- .../src/handlers/gestureHandlerCommon.ts | 11 ++- .../src/handlers/gestureHandlerTypesCompat.ts | 30 +++---- .../gestures/GestureDetector/Wrap.web.tsx | 4 +- .../GestureDetector/attachHandlers.ts | 26 +++--- .../gestures/GestureDetector/dropHandlers.ts | 6 +- .../gestures/GestureDetector/index.tsx | 22 +++--- .../GestureDetector/needsToReattach.ts | 4 +- .../gestures/GestureDetector/types.ts | 4 +- .../GestureDetector/updateHandlers.ts | 18 ++--- .../GestureDetector/useAnimatedGesture.ts | 17 ++-- .../GestureDetector/useDetectorUpdater.ts | 18 ++--- .../GestureDetector/useMountReactions.ts | 6 +- .../GestureDetector/useViewRefHandler.ts | 10 +-- .../gestures/GestureDetector/utils.ts | 35 ++++---- .../src/handlers/gestures/eventReceiver.ts | 19 +++-- .../src/handlers/gestures/flingGesture.ts | 5 +- .../handlers/gestures/forceTouchGesture.ts | 7 +- .../src/handlers/gestures/gesture.ts | 16 ++-- .../handlers/gestures/gestureComposition.ts | 3 +- .../src/handlers/gestures/gestureObjects.ts | 12 +-- .../gestures/gestureStateManager.web.ts | 4 +- .../src/handlers/gestures/hoverGesture.ts | 5 +- .../src/handlers/gestures/longPressGesture.ts | 5 +- .../src/handlers/gestures/manualGesture.ts | 2 +- .../src/handlers/gestures/nativeGesture.ts | 5 +- .../src/handlers/gestures/panGesture.ts | 7 +- .../src/handlers/gestures/pinchGesture.ts | 2 +- .../handlers/gestures/reanimatedWrapper.ts | 6 +- .../src/handlers/gestures/rotationGesture.ts | 2 +- .../src/handlers/gestures/tapGesture.ts | 5 +- .../src/handlers/handlersRegistry.ts | 9 ++- .../src/handlers/utils.ts | 6 +- .../src/jestUtils/jestUtils.ts | 79 ++++++++----------- .../src/mocks/GestureButtons.tsx | 2 +- .../src/mountRegistry.ts | 2 +- .../src/specs/NativeRNGestureHandlerModule.ts | 5 +- .../RNGestureHandlerButtonNativeComponent.ts | 6 +- ...RNGestureHandlerDetectorNativeComponent.ts | 6 +- ...RNGestureHandlerRootViewNativeComponent.ts | 2 +- .../src/v3/NativeProxy.ts | 6 +- .../src/v3/NativeProxy.web.ts | 4 +- .../src/v3/components/GestureButtons.tsx | 9 +-- .../src/v3/components/GestureButtonsProps.ts | 7 +- .../src/v3/components/GestureComponents.tsx | 23 +++--- .../v3/components/GestureComponents.web.tsx | 5 +- .../src/v3/components/Pressable.tsx | 41 +++++----- .../src/v3/components/Touchable/Touchable.tsx | 7 +- .../v3/components/Touchable/TouchableProps.ts | 4 +- .../src/v3/createNativeWrapper.tsx | 11 ++- .../src/v3/detectors/GestureDetector.tsx | 10 +-- .../v3/detectors/HostGestureDetector.web.tsx | 12 ++- .../src/v3/detectors/NativeDetector.tsx | 13 ++- .../v3/detectors/ReanimatedNativeDetector.tsx | 8 +- .../ReanimatedNativeDetector.web.tsx | 2 +- .../InterceptingGestureDetector.tsx | 33 ++++---- .../VirtualDetector/VirtualDetector.tsx | 12 +-- .../useInterceptingDetectorContext.ts | 2 +- .../src/v3/detectors/common.ts | 11 ++- .../useEnsureGestureHandlerRootView.ts | 4 +- .../src/v3/detectors/utils.ts | 5 +- .../src/v3/gestureStateManager.web.ts | 6 +- .../src/v3/hooks/callbacks/eventHandler.ts | 24 +++--- .../v3/hooks/callbacks/stateChangeHandler.ts | 8 +- .../v3/hooks/callbacks/touchEventHandler.ts | 4 +- .../src/v3/hooks/callbacks/updateHandler.ts | 8 +- .../hooks/callbacks/useGestureEventHandler.ts | 6 +- .../callbacks/useReanimatedEventHandler.ts | 10 +-- .../hooks/composition/useCompetingGestures.ts | 3 +- .../hooks/composition/useComposedGesture.ts | 10 +-- .../hooks/composition/useExclusiveGestures.ts | 3 +- .../composition/useSimultaneousGestures.ts | 3 +- .../src/v3/hooks/gestures/fling/FlingTypes.ts | 2 +- .../hooks/gestures/fling/useFlingGesture.ts | 8 +- .../src/v3/hooks/gestures/hover/HoverTypes.ts | 6 +- .../hooks/gestures/hover/useHoverGesture.ts | 15 ++-- .../src/v3/hooks/gestures/index.ts | 28 +++---- .../gestures/longPress/LongPressTypes.ts | 2 +- .../gestures/longPress/useLongPressGesture.ts | 8 +- .../v3/hooks/gestures/manual/ManualTypes.ts | 2 +- .../hooks/gestures/manual/useManualGesture.ts | 12 +-- .../v3/hooks/gestures/native/NativeTypes.ts | 2 +- .../hooks/gestures/native/useNativeGesture.ts | 8 +- .../src/v3/hooks/gestures/pan/PanTypes.ts | 4 +- .../v3/hooks/gestures/pan/usePanGesture.ts | 18 ++--- .../src/v3/hooks/gestures/pinch/PinchTypes.ts | 2 +- .../hooks/gestures/pinch/usePinchGesture.ts | 15 ++-- .../hooks/gestures/rotation/RotationTypes.ts | 2 +- .../gestures/rotation/useRotationGesture.ts | 15 ++-- .../src/v3/hooks/gestures/tap/TapTypes.ts | 2 +- .../v3/hooks/gestures/tap/useTapGesture.ts | 14 ++-- .../src/v3/hooks/useGesture.ts | 20 +++-- .../src/v3/hooks/useGestureCallbacks.ts | 8 +- .../src/v3/hooks/utils/configUtils.ts | 12 +-- .../src/v3/hooks/utils/eventHandlersUtils.ts | 8 +- .../src/v3/hooks/utils/eventUtils.ts | 8 +- .../src/v3/hooks/utils/propsWhiteList.ts | 6 +- .../src/v3/hooks/utils/reanimatedUtils.ts | 6 +- .../src/v3/hooks/utils/relationUtils.ts | 2 +- .../src/v3/types/ConfigTypes.ts | 6 +- .../src/v3/types/DetectorTypes.ts | 9 ++- .../src/v3/types/EventTypes.ts | 8 +- .../src/v3/types/GestureTypes.ts | 6 +- .../src/v3/types/NativeWrapperType.ts | 10 ++- .../src/v3/types/UtilityTypes.ts | 14 ++-- .../src/web/Gestures.ts | 12 +-- .../web/detectors/RotationGestureDetector.ts | 5 +- .../src/web/detectors/ScaleGestureDetector.ts | 6 +- .../src/web/handlers/FlingGestureHandler.ts | 11 ++- .../src/web/handlers/GestureHandler.ts | 49 ++++++------ .../src/web/handlers/HoverGestureHandler.ts | 12 +-- .../src/web/handlers/IGestureHandler.ts | 6 +- .../web/handlers/LongPressGestureHandler.ts | 13 ++- .../src/web/handlers/ManualGestureHandler.ts | 8 +- .../web/handlers/NativeViewGestureHandler.ts | 13 ++- .../src/web/handlers/PanGestureHandler.ts | 12 +-- .../src/web/handlers/PinchGestureHandler.ts | 16 ++-- .../web/handlers/RotationGestureHandler.ts | 16 ++-- .../src/web/handlers/TapGestureHandler.ts | 12 +-- .../src/web/interfaces.ts | 16 ++-- .../src/web/tools/EventManager.ts | 2 +- .../web/tools/GestureHandlerOrchestrator.ts | 5 +- .../web/tools/GestureHandlerWebDelegate.ts | 16 ++-- .../src/web/tools/InteractionManager.ts | 5 +- .../src/web/tools/KeyboardEventManager.ts | 3 +- .../src/web/tools/NodeManager.ts | 4 +- .../src/web/tools/PointerEventManager.ts | 9 ++- .../src/web/tools/PointerTracker.ts | 2 +- .../src/web/tools/Vector.ts | 2 +- .../src/web/tools/VelocityTracker.ts | 2 +- .../src/web/tools/WheelEventManager.ts | 3 +- .../src/web/utils.ts | 4 +- 176 files changed, 893 insertions(+), 942 deletions(-) diff --git a/packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts b/packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts index c30bfd7729..9ee6253cb5 100644 --- a/packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts +++ b/packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts @@ -1,12 +1,11 @@ -import React from 'react'; - +import type { Config, PropsRef } from './web/interfaces'; import type { ActionType } from './ActionType'; +import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate'; +import type { GestureRelations } from './v3/types'; import { Gestures } from './web/Gestures'; -import type { Config, PropsRef } from './web/interfaces'; import InteractionManager from './web/tools/InteractionManager'; import NodeManager from './web/tools/NodeManager'; -import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate'; -import { GestureRelations } from './v3/types'; +import React from 'react'; // init method is called inside attachGestureHandler function. However, this function may // fail when received view is not valid HTML element. On the other hand, dropGestureHandler diff --git a/packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts b/packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts index cf71b49397..01f4a7a1a7 100644 --- a/packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts +++ b/packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts @@ -1,17 +1,14 @@ -import React from 'react'; - -import { ActionType } from './ActionType'; - -// GestureHandlers -import PanGestureHandler from './web/handlers/PanGestureHandler'; -import TapGestureHandler from './web/handlers/TapGestureHandler'; +import type { ActionType } from './ActionType'; +import type { Config } from './web/interfaces'; +import FlingGestureHandler from './web/handlers/FlingGestureHandler'; import LongPressGestureHandler from './web/handlers/LongPressGestureHandler'; +import ManualGestureHandler from './web/handlers/ManualGestureHandler'; +import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler'; +import PanGestureHandler from './web/handlers/PanGestureHandler'; import PinchGestureHandler from './web/handlers/PinchGestureHandler'; +import type React from 'react'; import RotationGestureHandler from './web/handlers/RotationGestureHandler'; -import FlingGestureHandler from './web/handlers/FlingGestureHandler'; -import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler'; -import ManualGestureHandler from './web/handlers/ManualGestureHandler'; -import { Config } from './web/interfaces'; +import TapGestureHandler from './web/handlers/TapGestureHandler'; export const Gestures = { NativeViewGestureHandler, diff --git a/packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx b/packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx index c760e13ce1..606cce5d8b 100644 --- a/packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx @@ -1,5 +1,3 @@ -import React from 'react'; -import { render, cleanup } from '@testing-library/react-native'; import { Gesture, GestureDetector, @@ -7,7 +5,9 @@ import { InterceptingGestureDetector, useTapGesture, } from '../index'; -import { findNodeHandle, View } from 'react-native'; +import { View, findNodeHandle } from 'react-native'; +import { cleanup, render } from '@testing-library/react-native'; +import React from 'react'; import { VirtualDetector } from '../v3/detectors/VirtualDetector/VirtualDetector'; jest.mock('react-native-worklets', () => diff --git a/packages/react-native-gesture-handler/src/__tests__/Events.test.tsx b/packages/react-native-gesture-handler/src/__tests__/Events.test.tsx index 73e1b4437b..e77d5c39ab 100644 --- a/packages/react-native-gesture-handler/src/__tests__/Events.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/Events.test.tsx @@ -1,19 +1,21 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ // Disabling lint for assymetric matchers, check proposal below // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/56937 -import React from 'react'; -import { render, cleanup } from '@testing-library/react-native'; -import { Text } from 'react-native'; import { - GestureHandlerRootView, - PanGestureHandler, Gesture, GestureDetector, + GestureHandlerRootView, State, +} from '../index'; +import type { LegacyPanGesture, LegacyTapGesture, + PanGestureHandler, } from '../index'; +import { cleanup, render } from '@testing-library/react-native'; import { fireGestureHandler, getByGestureTestId } from '../jestUtils'; +import React from 'react'; +import { Text } from 'react-native'; beforeEach(cleanup); diff --git a/packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx b/packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx index 2dc9e3245d..83c8b17147 100644 --- a/packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx @@ -1,13 +1,14 @@ -import { tagMessage } from '../utils'; import { - useExclusiveGestures, useCompetingGestures, + useExclusiveGestures, useSimultaneousGestures, } from '../v3/hooks/composition'; -import { useGesture } from '../v3/hooks/useGesture'; +import type { SingleGesture } from '../v3/types'; +import { SingleGestureName } from '../v3/types'; import { configureRelations } from '../v3/detectors/utils'; -import { SingleGesture, SingleGestureName } from '../v3/types'; import { renderHook } from '@testing-library/react-native'; +import { tagMessage } from '../utils'; +import { useGesture } from '../v3/hooks/useGesture'; type AnySingleGesture = SingleGesture; diff --git a/packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx b/packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx index 59afb6aeb8..52646749dc 100644 --- a/packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx @@ -1,11 +1,11 @@ -import { usePanGesture } from '../v3/hooks/gestures'; -import { render, renderHook } from '@testing-library/react-native'; +import { RectButton, Touchable } from '../v3/components'; import { fireGestureHandler, getByGestureTestId } from '../jestUtils'; -import { State } from '../State'; +import { render, renderHook } from '@testing-library/react-native'; import GestureHandlerRootView from '../components/GestureHandlerRootView'; -import { RectButton, Touchable } from '../v3/components'; -import { act } from 'react'; import type { SingleGesture } from '../v3/types'; +import { State } from '../State'; +import { act } from 'react'; +import { usePanGesture } from '../v3/hooks/gestures'; describe('[API v3] Hooks', () => { test('Pan gesture', () => { diff --git a/packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx b/packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx index b9af7addf6..e4cf5807cf 100644 --- a/packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx +++ b/packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx @@ -1,33 +1,28 @@ -import React from 'react'; -import { Text } from 'react-native'; -import { render, fireEvent } from '@testing-library/react-native'; - import { - LegacyRawButton, LegacyBaseButton, - LegacyRectButton, LegacyBorderlessButton, LegacyPureNativeButton, + LegacyRawButton, + LegacyRectButton, } from '../mocks/GestureButtons'; - import { - LegacyScrollView, LegacyFlatList, + LegacyRefreshControl, + LegacyScrollView, LegacySwitch, LegacyTextInput, - LegacyRefreshControl, } from '../mocks/gestureComponents'; - import { TouchableHighlight, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback, } from '../mocks/Touchables'; - -import LegacyPressable from '../mocks/Pressable'; - +import { fireEvent, render } from '@testing-library/react-native'; import GestureHandlerRootView from '../components/GestureHandlerRootView'; +import LegacyPressable from '../mocks/Pressable'; +import React from 'react'; +import { Text } from 'react-native'; import { Touchable } from '../v3/components'; describe('Jest mocks – legacy components render without crashing', () => { diff --git a/packages/react-native-gesture-handler/src/components/GestureButtons.tsx b/packages/react-native-gesture-handler/src/components/GestureButtons.tsx index 83648eaa20..d47fb333cc 100644 --- a/packages/react-native-gesture-handler/src/components/GestureButtons.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureButtons.tsx @@ -1,25 +1,23 @@ import * as React from 'react'; import { Animated, Platform, StyleSheet } from 'react-native'; - -import createNativeWrapper from '../handlers/createNativeWrapper'; -import GestureHandlerButton from './GestureHandlerButton'; -import { State } from '../State'; - -import { - GestureEvent, - HandlerStateChangeEvent, -} from '../handlers/gestureHandlerCommon'; -import type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload'; import type { BaseButtonWithRefProps, - LegacyBaseButtonProps, - RectButtonWithRefProps, - LegacyRectButtonProps, BorderlessButtonWithRefProps, + LegacyBaseButtonProps, LegacyBorderlessButtonProps, LegacyRawButtonProps, + LegacyRectButtonProps, + RectButtonWithRefProps, } from './GestureButtonsProps'; +import type { + GestureEvent, + HandlerStateChangeEvent, +} from '../handlers/gestureHandlerCommon'; +import GestureHandlerButton from './GestureHandlerButton'; import type { HostComponent } from 'react-native'; +import type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload'; +import { State } from '../State'; +import createNativeWrapper from '../handlers/createNativeWrapper'; /** * @deprecated use `RawButton` instead diff --git a/packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts b/packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts index 905d70c125..73502ad303 100644 --- a/packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts +++ b/packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts @@ -1,5 +1,5 @@ -import * as React from 'react'; -import { +import type * as React from 'react'; +import type { AccessibilityProps, ColorValue, LayoutChangeEvent, diff --git a/packages/react-native-gesture-handler/src/components/GestureComponents.tsx b/packages/react-native-gesture-handler/src/components/GestureComponents.tsx index aac075a8d0..e35e70b0e0 100644 --- a/packages/react-native-gesture-handler/src/components/GestureComponents.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureComponents.tsx @@ -1,31 +1,28 @@ import * as React from 'react'; -import { - PropsWithChildren, +import type { ForwardedRef, - RefAttributes, + PropsWithChildren, ReactElement, + RefAttributes, } from 'react'; import { + DrawerLayoutAndroid as RNDrawerLayoutAndroid, + FlatList as RNFlatList, + RefreshControl as RNRefreshControl, ScrollView as RNScrollView, - ScrollViewProps as RNScrollViewProps, Switch as RNSwitch, - SwitchProps as RNSwitchProps, TextInput as RNTextInput, - TextInputProps as RNTextInputProps, - DrawerLayoutAndroid as RNDrawerLayoutAndroid, +} from 'react-native'; +import type { DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps, - FlatList as RNFlatList, FlatListProps as RNFlatListProps, - RefreshControl as RNRefreshControl, + ScrollViewProps as RNScrollViewProps, + SwitchProps as RNSwitchProps, + TextInputProps as RNTextInputProps, } from 'react-native'; - +import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; import createNativeWrapper from '../handlers/createNativeWrapper'; - -import { - NativeViewGestureHandlerProps, - nativeViewProps, -} from '../handlers/NativeViewGestureHandler'; - +import { nativeViewProps } from '../handlers/NativeViewGestureHandler'; import { toArray } from '../utils'; /** diff --git a/packages/react-native-gesture-handler/src/components/GestureComponents.web.tsx b/packages/react-native-gesture-handler/src/components/GestureComponents.web.tsx index 6526532342..d986ce1f52 100644 --- a/packages/react-native-gesture-handler/src/components/GestureComponents.web.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureComponents.web.tsx @@ -1,13 +1,12 @@ import * as React from 'react'; import { FlatList as RNFlatList, + ScrollView as RNScrollView, Switch as RNSwitch, TextInput as RNTextInput, - ScrollView as RNScrollView, - FlatListProps, View, } from 'react-native'; - +import type { FlatListProps } from 'react-native'; import createNativeWrapper from '../handlers/createNativeWrapper'; /** diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx index b57cef3a90..f9c8008ccd 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx @@ -1,4 +1,4 @@ -import { +import type { AccessibilityProps, ColorValue, HostComponent, diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx index 78df90cdeb..a118f6a95a 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; -import { ColorValue, View, ViewProps } from 'react-native'; +import type { ColorValue, ViewProps } from 'react-native'; +import { View } from 'react-native'; type ButtonProps = ViewProps & { ref?: React.Ref>; diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.android.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.android.tsx index 4a07468d47..4608841ce0 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.android.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.android.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; -import { PropsWithChildren } from 'react'; -import { StyleSheet } from 'react-native'; import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; -import type { RootViewNativeProps } from '../specs/RNGestureHandlerRootViewNativeComponent'; import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent'; +import type { PropsWithChildren } from 'react'; +import type { RootViewNativeProps } from '../specs/RNGestureHandlerRootViewNativeComponent'; +import { StyleSheet } from 'react-native'; export interface GestureHandlerRootViewProps extends PropsWithChildren {} diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.tsx index 0b8e8c907e..4ad7960544 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; -import { PropsWithChildren } from 'react'; -import { View, StyleSheet } from 'react-native'; +import { StyleSheet, View } from 'react-native'; import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; +import type { PropsWithChildren } from 'react'; import type { RootViewNativeProps } from '../specs/RNGestureHandlerRootViewNativeComponent'; export interface GestureHandlerRootViewProps diff --git a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.web.tsx b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.web.tsx index 965f29f4af..63a13a5d00 100644 --- a/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.web.tsx +++ b/packages/react-native-gesture-handler/src/components/GestureHandlerRootView.web.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; -import { PropsWithChildren } from 'react'; -import { View, ViewProps, StyleSheet } from 'react-native'; +import { StyleSheet, View } from 'react-native'; import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; +import type { PropsWithChildren } from 'react'; +import type { ViewProps } from 'react-native'; export interface GestureHandlerRootViewProps extends PropsWithChildren {} diff --git a/packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx b/packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx index 350fb5449f..a7e04c6b7f 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx +++ b/packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx @@ -1,3 +1,15 @@ +import { INT32_MAX, isTestEnv } from '../../utils'; +import type { + Insets, + LayoutChangeEvent, + StyleProp, + ViewStyle, +} from 'react-native'; +import type { + LegacyPressableProps, + PressableDimensions, + PressableEvent, +} from './PressableProps'; import React, { useCallback, useEffect, @@ -5,37 +17,22 @@ import React, { useRef, useState, } from 'react'; -import { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects'; -import { GestureDetector } from '../../handlers/gestures/GestureDetector'; -import { - PressableEvent, - PressableDimensions, - LegacyPressableProps, -} from './PressableProps'; +import type { RelationPropName, RelationPropType } from '../utils'; +import { StateMachineEvent, getStatesConfig } from './stateDefinitions'; import { - Insets, - LayoutChangeEvent, - Platform, - StyleProp, - ViewStyle, -} from 'react-native'; -import { ButtonComponent as NativeButton } from '../GestureHandlerButton'; -import { - gestureToPressableEvent, addInsets, - numberAsInset, + gestureToPressableEvent, gestureTouchToPressableEvent, isTouchWithinInset, + numberAsInset, } from './utils'; +import { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects'; +import { GestureDetector } from '../../handlers/gestures/GestureDetector'; +import { ButtonComponent as NativeButton } from '../GestureHandlerButton'; +import { Platform } from 'react-native'; import { PressabilityDebugView } from '../../handlers/PressabilityDebugView'; -import { INT32_MAX, isTestEnv } from '../../utils'; -import { - applyRelationProp, - RelationPropName, - RelationPropType, -} from '../utils'; -import { getStatesConfig, StateMachineEvent } from './stateDefinitions'; import { PressableStateMachine } from './StateMachine'; +import { applyRelationProp } from '../utils'; import { useIsScreenReaderEnabled } from '../../useIsScreenReaderEnabled'; const DEFAULT_LONG_PRESS_DURATION = 500; diff --git a/packages/react-native-gesture-handler/src/components/Pressable/PressableProps.tsx b/packages/react-native-gesture-handler/src/components/Pressable/PressableProps.tsx index ab3d1fbee2..cf207e9e46 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/PressableProps.tsx +++ b/packages/react-native-gesture-handler/src/components/Pressable/PressableProps.tsx @@ -1,15 +1,15 @@ -import { +import type { AccessibilityProps, - ViewProps, Insets, - StyleProp, - ViewStyle, - PressableStateCallbackType as RNPressableStateCallbackType, PressableAndroidRippleConfig as RNPressableAndroidRippleConfig, + PressableStateCallbackType as RNPressableStateCallbackType, + StyleProp, View, + ViewProps, + ViewStyle, } from 'react-native'; -import { RelationPropType } from '../utils'; -import { AnyGesture } from '../../v3/types'; +import type { AnyGesture } from '../../v3/types'; +import type { RelationPropType } from '../utils'; export type PressableDimensions = { width: number; height: number }; diff --git a/packages/react-native-gesture-handler/src/components/Pressable/StateMachine.tsx b/packages/react-native-gesture-handler/src/components/Pressable/StateMachine.tsx index 7c47877792..b65491e2f2 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/StateMachine.tsx +++ b/packages/react-native-gesture-handler/src/components/Pressable/StateMachine.tsx @@ -1,4 +1,4 @@ -import { PressableEvent } from './PressableProps'; +import type { PressableEvent } from './PressableProps'; export interface StateDefinition { eventName: string; diff --git a/packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts b/packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts index 89cf2bf1e9..e8e22d5525 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts +++ b/packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts @@ -1,6 +1,6 @@ import { Platform } from 'react-native'; -import { PressableEvent } from './PressableProps'; -import { StateDefinition } from './StateMachine'; +import type { PressableEvent } from './PressableProps'; +import type { StateDefinition } from './StateMachine'; export enum StateMachineEvent { NATIVE_BEGIN = 'nativeBegin', diff --git a/packages/react-native-gesture-handler/src/components/Pressable/utils.ts b/packages/react-native-gesture-handler/src/components/Pressable/utils.ts index 04650ce576..5e1981579a 100644 --- a/packages/react-native-gesture-handler/src/components/Pressable/utils.ts +++ b/packages/react-native-gesture-handler/src/components/Pressable/utils.ts @@ -1,20 +1,20 @@ -import { Insets } from 'react-native'; import type { - HoverGestureHandlerEventPayload, - LongPressGestureHandlerEventPayload, -} from '../../handlers/GestureHandlerEventPayload'; -import type { - TouchData, GestureStateChangeEvent, GestureTouchEvent, + TouchData, } from '../../handlers/gestureHandlerCommon'; +import type { HoverGestureEvent, LongPressGestureEvent } from '../../v3'; +import type { + HoverGestureHandlerEventPayload, + LongPressGestureHandlerEventPayload, +} from '../../handlers/GestureHandlerEventPayload'; import type { - PressableDimensions, InnerPressableEvent, + PressableDimensions, PressableEvent, } from './PressableProps'; -import type { HoverGestureEvent, LongPressGestureEvent } from '../../v3'; import type { HoverGestureActiveEvent } from '../../v3/hooks'; +import type { Insets } from 'react-native'; const numberAsInset = (value: number): Insets => ({ left: value, diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx b/packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx index 43eedda301..6ae41896ef 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx +++ b/packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx @@ -2,31 +2,13 @@ // It's cross-compatible with all platforms despite // `DrawerLayoutAndroid` only being available on android -import React, { - ReactNode, - forwardRef, - useCallback, - useEffect, - useImperativeHandle, - useMemo, - useState, -} from 'react'; - -import { - StyleSheet, - Keyboard, - StatusBar, - I18nManager, - StatusBarAnimation, - StyleProp, - ViewStyle, - LayoutChangeEvent, - Platform, -} from 'react-native'; - +import type { + ActiveCursor, + HitSlop, + UserSelect, +} from '../handlers/gestureHandlerCommon'; import Animated, { Extrapolation, - SharedValue, interpolate, runOnJS, useAnimatedProps, @@ -35,19 +17,33 @@ import Animated, { useSharedValue, withSpring, } from 'react-native-reanimated'; - import { - UserSelect, - ActiveCursor, - MouseButton, - HitSlop, -} from '../handlers/gestureHandlerCommon'; -import { - PanGestureActiveEvent, - usePanGesture, - useTapGesture, -} from '../v3/hooks/gestures'; + I18nManager, + Keyboard, + Platform, + StatusBar, + StyleSheet, +} from 'react-native'; +import type { + LayoutChangeEvent, + StatusBarAnimation, + StyleProp, + ViewStyle, +} from 'react-native'; +import React, { + forwardRef, + useCallback, + useEffect, + useImperativeHandle, + useMemo, + useState, +} from 'react'; +import { usePanGesture, useTapGesture } from '../v3/hooks/gestures'; import { GestureDetector } from '../v3/detectors'; +import { MouseButton } from '../handlers/gestureHandlerCommon'; +import type { PanGestureActiveEvent } from '../v3/hooks/gestures'; +import type { ReactNode } from 'react'; +import type { SharedValue } from 'react-native-reanimated'; const DRAG_TOSS = 0.05; diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx index 7495b6fd46..ac79b3df49 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +++ b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx @@ -1,27 +1,26 @@ -import { useMemo, useCallback, useImperativeHandle, ForwardedRef } from 'react'; -import { LayoutChangeEvent, View, I18nManager, StyleSheet } from 'react-native'; import Animated, { - useSharedValue, - interpolate, - runOnJS, ReduceMotion, - withSpring, - useAnimatedRef, + interpolate, measure, + runOnJS, runOnUI, + useAnimatedRef, useAnimatedStyle, + useSharedValue, + withSpring, } from 'react-native-reanimated'; -import { - SwipeableProps, +import { I18nManager, StyleSheet, View } from 'react-native'; +import type { SwipeableMethods, - SwipeDirection, + SwipeableProps, } from './ReanimatedSwipeableProps'; -import { - PanGestureActiveEvent, - usePanGesture, - useTapGesture, -} from '../../v3/hooks/gestures'; +import { useCallback, useImperativeHandle, useMemo } from 'react'; +import { usePanGesture, useTapGesture } from '../../v3/hooks/gestures'; +import type { ForwardedRef } from 'react'; import { GestureDetector } from '../../v3/detectors'; +import type { LayoutChangeEvent } from 'react-native'; +import type { PanGestureActiveEvent } from '../../v3/hooks/gestures'; +import { SwipeDirection } from './ReanimatedSwipeableProps'; const DRAG_TOSS = 0.05; diff --git a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts index a44832893d..c94846422e 100644 --- a/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +++ b/packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts @@ -1,8 +1,8 @@ -import React from 'react'; -import { SharedValue } from 'react-native-reanimated'; -import { StyleProp, ViewStyle } from 'react-native'; -import { HitSlop } from '../../handlers/gestureHandlerCommon'; -import { AnyGesture } from '../../v3/types'; +import type { StyleProp, ViewStyle } from 'react-native'; +import type { AnyGesture } from '../../v3/types'; +import type { HitSlop } from '../../handlers/gestureHandlerCommon'; +import type React from 'react'; +import type { SharedValue } from 'react-native-reanimated'; export enum SwipeDirection { LEFT = 'left', diff --git a/packages/react-native-gesture-handler/src/components/Text.tsx b/packages/react-native-gesture-handler/src/components/Text.tsx index 9eff0c92b6..e3e98c0647 100644 --- a/packages/react-native-gesture-handler/src/components/Text.tsx +++ b/packages/react-native-gesture-handler/src/components/Text.tsx @@ -1,12 +1,9 @@ -import React, { ComponentRef, Ref, useEffect, useMemo, useRef } from 'react'; -import { - Platform, - Text as RNText, - TextProps as RNTextProps, -} from 'react-native'; - +import type { ComponentRef, Ref } from 'react'; +import { Platform, Text as RNText } from 'react-native'; +import React, { useEffect, useMemo, useRef } from 'react'; import { GestureObjects as Gesture } from '../handlers/gestures/gestureObjects'; import { GestureDetector } from '../handlers/gestures/GestureDetector'; +import type { TextProps as RNTextProps } from 'react-native'; type TextProps = RNTextProps & { ref?: Ref | null>; diff --git a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx index 74e07b7933..4b73733aab 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx @@ -1,16 +1,14 @@ import * as React from 'react'; -import { Component } from 'react'; import { Animated, Platform } from 'react-native'; - -import { State } from '../../State'; -import { LegacyBaseButton } from '../GestureButtons'; - -import { +import type { GestureEvent, HandlerStateChangeEvent, } from '../../handlers/gestureHandlerCommon'; -import type { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload'; +import { Component } from 'react'; import type { GenericTouchableProps } from './GenericTouchableProps'; +import { LegacyBaseButton } from '../GestureButtons'; +import type { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload'; +import { State } from '../../State'; /** * Each touchable is a states' machine which preforms transitions. diff --git a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts index 667acbe36c..ee75e9185b 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts +++ b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchableProps.ts @@ -1,11 +1,11 @@ import type { + Insets, StyleProp, - ViewStyle, TouchableWithoutFeedbackProps, - Insets, + ViewStyle, } from 'react-native'; +import type { ExtraButtonProps } from './ExtraButtonProps'; import type { UserSelect } from '../../handlers/gestureHandlerCommon'; -import { ExtraButtonProps } from './ExtraButtonProps'; export interface GenericTouchableProps extends Omit { diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableHighlight.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableHighlight.tsx index b18419e546..869480a9ef 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableHighlight.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableHighlight.tsx @@ -1,14 +1,13 @@ import * as React from 'react'; -import { Component } from 'react'; -import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; -import type { GenericTouchableProps } from './GenericTouchableProps'; -import { - StyleSheet, - View, - TouchableHighlightProps as RNTouchableHighlightProps, +import type { ColorValue, + TouchableHighlightProps as RNTouchableHighlightProps, ViewProps, } from 'react-native'; +import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; +import { StyleSheet, View } from 'react-native'; +import { Component } from 'react'; +import type { GenericTouchableProps } from './GenericTouchableProps'; interface State { extraChildStyle: null | { diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx index 3c9d90b030..5eb9e47e20 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedback.android.tsx @@ -1,11 +1,12 @@ -import { Platform, ColorValue } from 'react-native'; import * as React from 'react'; -import { Component } from 'react'; -import GenericTouchable from './GenericTouchable'; -import { - TouchableNativeFeedbackProps, +import type { TouchableNativeFeedbackExtraProps, + TouchableNativeFeedbackProps, } from './TouchableNativeFeedbackProps'; +import type { ColorValue } from 'react-native'; +import { Component } from 'react'; +import GenericTouchable from './GenericTouchable'; +import { Platform } from 'react-native'; /** * @deprecated TouchableNativeFeedback will be removed in the future version of Gesture Handler. Use Pressable instead. diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedbackProps.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedbackProps.tsx index f5d12cf14e..7e3801a9c7 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedbackProps.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableNativeFeedbackProps.tsx @@ -1,6 +1,6 @@ -import type { TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps } from 'react-native'; +import type { ExtraButtonProps } from './ExtraButtonProps'; import type { GenericTouchableProps } from './GenericTouchableProps'; -import { ExtraButtonProps } from './ExtraButtonProps'; +import type { TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps } from 'react-native'; export type TouchableNativeFeedbackExtraProps = ExtraButtonProps; /** diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableOpacity.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableOpacity.tsx index c2d2ba6627..c7615ddf54 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableOpacity.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableOpacity.tsx @@ -1,14 +1,9 @@ -import { - Animated, - Easing, - StyleSheet, - View, - TouchableOpacityProps as RNTouchableOpacityProps, -} from 'react-native'; -import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; -import type { GenericTouchableProps } from './GenericTouchableProps'; import * as React from 'react'; +import { Animated, Easing, StyleSheet, View } from 'react-native'; +import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; import { Component } from 'react'; +import type { GenericTouchableProps } from './GenericTouchableProps'; +import type { TouchableOpacityProps as RNTouchableOpacityProps } from 'react-native'; /** * @deprecated TouchableOpacity will be removed in the future version of Gesture Handler. Use Pressable instead. diff --git a/packages/react-native-gesture-handler/src/components/touchables/TouchableWithoutFeedback.tsx b/packages/react-native-gesture-handler/src/components/touchables/TouchableWithoutFeedback.tsx index c24d2be22b..04c97b0666 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/TouchableWithoutFeedback.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/TouchableWithoutFeedback.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; -import { PropsWithChildren } from 'react'; import GenericTouchable from './GenericTouchable'; import type { GenericTouchableProps } from './GenericTouchableProps'; +import type { PropsWithChildren } from 'react'; /** * @deprecated TouchableWithoutFeedback will be removed in the future version of Gesture Handler. Use Pressable instead. diff --git a/packages/react-native-gesture-handler/src/components/utils.ts b/packages/react-native-gesture-handler/src/components/utils.ts index 83387ba51f..21e59d020a 100644 --- a/packages/react-native-gesture-handler/src/components/utils.ts +++ b/packages/react-native-gesture-handler/src/components/utils.ts @@ -1,4 +1,4 @@ -import { BaseGesture, GestureRef } from '../handlers/gestures/gesture'; +import type { BaseGesture, GestureRef } from '../handlers/gestures/gesture'; export type RelationPropName = | 'simultaneousWithExternalGesture' diff --git a/packages/react-native-gesture-handler/src/findNodeHandle.web.ts b/packages/react-native-gesture-handler/src/findNodeHandle.web.ts index cebe84fb32..26b8543640 100644 --- a/packages/react-native-gesture-handler/src/findNodeHandle.web.ts +++ b/packages/react-native-gesture-handler/src/findNodeHandle.web.ts @@ -1,5 +1,5 @@ -import { FlatList } from 'react-native'; import type { GestureHandlerRef, SVGRef } from './web/interfaces'; +import { FlatList } from 'react-native'; import { isRNSVGElement } from './web/utils'; export default function findNodeHandle( diff --git a/packages/react-native-gesture-handler/src/handlers/FlingGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/FlingGestureHandler.ts index 3ef728f7bd..4cfd4cc66b 100644 --- a/packages/react-native-gesture-handler/src/handlers/FlingGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/FlingGestureHandler.ts @@ -1,9 +1,7 @@ +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; import type { FlingGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; import createHandler from './createHandler'; -import { - BaseGestureHandlerProps, - baseGestureHandlerProps, -} from './gestureHandlerCommon'; export const flingGestureHandlerProps = [ 'numberOfPointers', diff --git a/packages/react-native-gesture-handler/src/handlers/ForceTouchGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/ForceTouchGestureHandler.ts index f30c30c39e..22c12297d8 100644 --- a/packages/react-native-gesture-handler/src/handlers/ForceTouchGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/ForceTouchGestureHandler.ts @@ -1,12 +1,11 @@ -import React, { PropsWithChildren } from 'react'; -import { tagMessage } from '../utils'; +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; +import type { ForceTouchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import PlatformConstants from '../PlatformConstants'; +import type { PropsWithChildren } from 'react'; +import React from 'react'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; import createHandler from './createHandler'; -import { - BaseGestureHandlerProps, - baseGestureHandlerProps, -} from './gestureHandlerCommon'; -import type { ForceTouchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import { tagMessage } from '../utils'; export const forceTouchGestureHandlerProps = [ 'minForce', diff --git a/packages/react-native-gesture-handler/src/handlers/GestureHandlerEventPayload.ts b/packages/react-native-gesture-handler/src/handlers/GestureHandlerEventPayload.ts index 6c3e2bcaee..35c0291432 100644 --- a/packages/react-native-gesture-handler/src/handlers/GestureHandlerEventPayload.ts +++ b/packages/react-native-gesture-handler/src/handlers/GestureHandlerEventPayload.ts @@ -1,4 +1,4 @@ -import { StylusData } from './gestureHandlerCommon'; +import type { StylusData } from './gestureHandlerCommon'; export type FlingGestureHandlerEventPayload = { x: number; diff --git a/packages/react-native-gesture-handler/src/handlers/LongPressGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/LongPressGestureHandler.ts index b6116e045f..79f32547d7 100644 --- a/packages/react-native-gesture-handler/src/handlers/LongPressGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/LongPressGestureHandler.ts @@ -1,9 +1,7 @@ -import { LongPressGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; +import type { LongPressGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; import createHandler from './createHandler'; -import { - BaseGestureHandlerProps, - baseGestureHandlerProps, -} from './gestureHandlerCommon'; export const longPressGestureHandlerProps = [ 'minDurationMs', diff --git a/packages/react-native-gesture-handler/src/handlers/NativeViewGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/NativeViewGestureHandler.ts index e7461f9b9b..dac7e67186 100644 --- a/packages/react-native-gesture-handler/src/handlers/NativeViewGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/NativeViewGestureHandler.ts @@ -1,9 +1,7 @@ +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; import type { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; import createHandler from './createHandler'; -import { - BaseGestureHandlerProps, - baseGestureHandlerProps, -} from './gestureHandlerCommon'; export const nativeViewGestureHandlerProps = [ 'shouldActivateOnStart', diff --git a/packages/react-native-gesture-handler/src/handlers/PanGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/PanGestureHandler.ts index c69465adf4..69d89164e0 100644 --- a/packages/react-native-gesture-handler/src/handlers/PanGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/PanGestureHandler.ts @@ -1,9 +1,7 @@ +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; import type { PanGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; import createHandler from './createHandler'; -import { - BaseGestureHandlerProps, - baseGestureHandlerProps, -} from './gestureHandlerCommon'; export const panGestureHandlerProps = [ 'activeOffsetY', diff --git a/packages/react-native-gesture-handler/src/handlers/PinchGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/PinchGestureHandler.ts index 5d5b4ffd05..b2dd6b00a3 100644 --- a/packages/react-native-gesture-handler/src/handlers/PinchGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/PinchGestureHandler.ts @@ -1,9 +1,7 @@ -import { PinchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; +import type { PinchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; import createHandler from './createHandler'; -import { - BaseGestureHandlerProps, - baseGestureHandlerProps, -} from './gestureHandlerCommon'; /** * @deprecated PinchGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Pinch()` instead. diff --git a/packages/react-native-gesture-handler/src/handlers/RotationGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/RotationGestureHandler.ts index c82eddb38e..82eec4629f 100644 --- a/packages/react-native-gesture-handler/src/handlers/RotationGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/RotationGestureHandler.ts @@ -1,9 +1,7 @@ -import { RotationGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; +import type { RotationGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; import createHandler from './createHandler'; -import { - BaseGestureHandlerProps, - baseGestureHandlerProps, -} from './gestureHandlerCommon'; /** * @deprecated RotationGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Rotation()` instead. diff --git a/packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts b/packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts index 80307ffec0..5234ceed47 100644 --- a/packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts @@ -1,9 +1,7 @@ +import type { BaseGestureHandlerProps } from './gestureHandlerCommon'; import type { TapGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import { baseGestureHandlerProps } from './gestureHandlerCommon'; import createHandler from './createHandler'; -import { - BaseGestureHandlerProps, - baseGestureHandlerProps, -} from './gestureHandlerCommon'; export const tapGestureHandlerProps = [ 'maxDurationMs', diff --git a/packages/react-native-gesture-handler/src/handlers/createHandler.tsx b/packages/react-native-gesture-handler/src/handlers/createHandler.tsx index cc0e427e7d..a56e089428 100644 --- a/packages/react-native-gesture-handler/src/handlers/createHandler.tsx +++ b/packages/react-native-gesture-handler/src/handlers/createHandler.tsx @@ -1,34 +1,30 @@ import * as React from 'react'; -import { - Platform, - DeviceEventEmitter, - EmitterSubscription, -} from 'react-native'; -import { customDirectEventTypes } from './customDirectEventTypes'; -import RNGestureHandlerModule from '../RNGestureHandlerModule'; -import { State } from '../State'; -import { - handlerIDToTag, - registerOldGestureHandler, - unregisterOldGestureHandler, -} from './handlersRegistry'; -import { getNextHandlerTag } from './getNextHandlerTag'; - -import { +import type { BaseGestureHandlerProps, GestureEvent, HandlerStateChangeEvent, } from './gestureHandlerCommon'; -import { filterConfig, scheduleFlushOperations } from './utils'; -import findNodeHandle from '../findNodeHandle'; -import { ValueOf } from '../typeUtils'; +import { DeviceEventEmitter, Platform } from 'react-native'; import { deepEqual, isTestEnv, tagMessage } from '../utils'; +import { filterConfig, scheduleFlushOperations } from './utils'; +import { + handlerIDToTag, + registerOldGestureHandler, + unregisterOldGestureHandler, +} from './handlersRegistry'; import { ActionType } from '../ActionType'; -import { PressabilityDebugView } from './PressabilityDebugView'; +import type { EmitterSubscription } from 'react-native'; import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext'; -import { ghQueueMicrotask } from '../ghQueueMicrotask'; import { MountRegistry } from '../mountRegistry'; -import { ReactElement } from 'react'; +import { PressabilityDebugView } from './PressabilityDebugView'; +import RNGestureHandlerModule from '../RNGestureHandlerModule'; +import type { ReactElement } from 'react'; +import { State } from '../State'; +import type { ValueOf } from '../typeUtils'; +import { customDirectEventTypes } from './customDirectEventTypes'; +import findNodeHandle from '../findNodeHandle'; +import { getNextHandlerTag } from './getNextHandlerTag'; +import { ghQueueMicrotask } from '../ghQueueMicrotask'; customDirectEventTypes.topGestureHandlerEvent = { registrationName: 'onGestureHandlerEvent', diff --git a/packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx b/packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx index 2562e458cd..94082ec595 100644 --- a/packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx +++ b/packages/react-native-gesture-handler/src/handlers/createNativeWrapper.tsx @@ -1,11 +1,10 @@ import * as React from 'react'; -import { useImperativeHandle, useRef } from 'react'; - import { NativeViewGestureHandler, - NativeViewGestureHandlerProps, nativeViewProps, } from './NativeViewGestureHandler'; +import { useImperativeHandle, useRef } from 'react'; +import type { NativeViewGestureHandlerProps } from './NativeViewGestureHandler'; /* * This array should consist of: diff --git a/packages/react-native-gesture-handler/src/handlers/gestureHandlerCommon.ts b/packages/react-native-gesture-handler/src/handlers/gestureHandlerCommon.ts index 709dee99e9..bc29bc704c 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestureHandlerCommon.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestureHandlerCommon.ts @@ -2,12 +2,11 @@ // Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof // e.g. React.createRef -> React.createRef. // See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference. -import * as React from 'react'; - -import { State } from '../State'; -import { TouchEventType } from '../TouchEventType'; -import { ValueOf } from '../typeUtils'; -import { PointerType } from '../PointerType'; +import type * as React from 'react'; +import type { PointerType } from '../PointerType'; +import type { State } from '../State'; +import type { TouchEventType } from '../TouchEventType'; +import type { ValueOf } from '../typeUtils'; const commonProps = [ 'id', diff --git a/packages/react-native-gesture-handler/src/handlers/gestureHandlerTypesCompat.ts b/packages/react-native-gesture-handler/src/handlers/gestureHandlerTypesCompat.ts index c4e4ff2506..022a70261d 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestureHandlerTypesCompat.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestureHandlerTypesCompat.ts @@ -1,33 +1,33 @@ -import type { - LegacyBaseButtonProps, - LegacyBorderlessButtonProps, - LegacyRawButtonProps, - LegacyRectButtonProps, -} from '../components/GestureButtonsProps'; -import { - GestureEvent, - GestureEventPayload, - HandlerStateChangeEvent, - HandlerStateChangeEventPayload, -} from './gestureHandlerCommon'; -import type { FlingGestureHandlerProps } from './FlingGestureHandler'; import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, + NativeViewGestureHandlerPayload, PanGestureHandlerEventPayload, PinchGestureHandlerEventPayload, RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, - NativeViewGestureHandlerPayload, } from './GestureHandlerEventPayload'; +import type { + GestureEvent, + GestureEventPayload, + HandlerStateChangeEvent, + HandlerStateChangeEventPayload, +} from './gestureHandlerCommon'; +import type { + LegacyBaseButtonProps, + LegacyBorderlessButtonProps, + LegacyRawButtonProps, + LegacyRectButtonProps, +} from '../components/GestureButtonsProps'; +import type { FlingGestureHandlerProps } from './FlingGestureHandler'; import type { ForceTouchGestureHandlerProps } from './ForceTouchGestureHandler'; import type { LongPressGestureHandlerProps } from './LongPressGestureHandler'; +import type { NativeViewGestureHandlerProps } from './NativeViewGestureHandler'; import type { PanGestureHandlerProps } from './PanGestureHandler'; import type { PinchGestureHandlerProps } from './PinchGestureHandler'; import type { RotationGestureHandlerProps } from './RotationGestureHandler'; import type { TapGestureHandlerProps } from './TapGestureHandler'; -import type { NativeViewGestureHandlerProps } from './NativeViewGestureHandler'; // Events export type GestureHandlerGestureEventNativeEvent = GestureEventPayload; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx index 55329e3447..33c43978e5 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx @@ -1,7 +1,7 @@ -import React, { forwardRef } from 'react'; import type { LegacyRef, PropsWithChildren } from 'react'; -import { tagMessage } from '../../../utils'; +import React, { forwardRef } from 'react'; import { isRNSVGNode } from '../../../web/utils'; +import { tagMessage } from 'packages/react-native-gesture-handler/src/utils'; export const Wrap = forwardRef>( ({ children }, ref) => { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts index 2a29e85037..948f5034f9 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts @@ -1,21 +1,21 @@ -import React from 'react'; -import { GestureType, HandlerCallbacks } from '../gesture'; -import { registerHandler } from '../../handlersRegistry'; -import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; +import { + ALLOWED_PROPS, + checkGestureCallbacksForWorklets, + extractGestureRelations, +} from './utils'; +import type { GestureType, HandlerCallbacks } from '../gesture'; import { filterConfig, scheduleFlushOperations } from '../../utils'; -import { ComposedGesture } from '../gestureComposition'; import { ActionType } from '../../../ActionType'; +import type { AttachedGestureState } from './types'; +import type { ComposedGesture } from '../gestureComposition'; +import { MountRegistry } from '../../../mountRegistry'; import { Platform } from 'react-native'; +import type { PropsRef } from '../../../web/interfaces'; +import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; import type RNGestureHandlerModuleWeb from '../../../RNGestureHandlerModule.web'; +import type React from 'react'; import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; -import { AttachedGestureState } from './types'; -import { - extractGestureRelations, - checkGestureCallbacksForWorklets, - ALLOWED_PROPS, -} from './utils'; -import { MountRegistry } from '../../../mountRegistry'; -import { PropsRef } from '../../../web/interfaces'; +import { registerHandler } from '../../handlersRegistry'; interface AttachHandlersConfig { preparedGesture: AttachedGestureState; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/dropHandlers.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/dropHandlers.ts index 3159d74a5f..29be682f96 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/dropHandlers.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/dropHandlers.ts @@ -1,8 +1,8 @@ -import { unregisterHandler } from '../../handlersRegistry'; +import type { AttachedGestureState } from './types'; +import { MountRegistry } from '../../../mountRegistry'; import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; import { scheduleFlushOperations } from '../../utils'; -import { AttachedGestureState } from './types'; -import { MountRegistry } from '../../../mountRegistry'; +import { unregisterHandler } from '../../handlersRegistry'; export function dropHandlers(preparedGesture: AttachedGestureState) { for (const handler of preparedGesture.attachedGestures) { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx index 52a4d22499..351347f1ea 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/index.tsx @@ -1,20 +1,20 @@ /* eslint-disable react/no-unused-prop-types */ +import { AnimatedWrap, Wrap } from './Wrap'; +import type { AttachedGestureState, GestureDetectorState } from './types'; import React, { useEffect, useMemo, useRef } from 'react'; -import findNodeHandle from '../../../findNodeHandle'; -import { GestureType } from '../gesture'; -import { UserSelect, TouchAction } from '../../gestureHandlerCommon'; -import { ComposedGesture } from '../gestureComposition'; -import { AttachedGestureState, GestureDetectorState } from './types'; -import { useAnimatedGesture } from './useAnimatedGesture'; +import type { TouchAction, UserSelect } from '../../gestureHandlerCommon'; +import type { ComposedGesture } from '../gestureComposition'; +import type { GestureType } from '../gesture'; import { attachHandlers } from './attachHandlers'; -import { needsToReattach } from './needsToReattach'; import { dropHandlers } from './dropHandlers'; -import { useWebEventHandlers } from './utils'; -import { Wrap, AnimatedWrap } from './Wrap'; +import findNodeHandle from '../../../findNodeHandle'; +import { needsToReattach } from './needsToReattach'; +import { useAnimatedGesture } from './useAnimatedGesture'; import { useDetectorUpdater } from './useDetectorUpdater'; -import { useViewRefHandler } from './useViewRefHandler'; -import { useMountReactions } from './useMountReactions'; import { useIsomorphicLayoutEffect } from '../../../useIsomorphicLayoutEffect'; +import { useMountReactions } from './useMountReactions'; +import { useViewRefHandler } from './useViewRefHandler'; +import { useWebEventHandlers } from './utils'; function propagateDetectorConfig( props: GestureDetectorProps, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/needsToReattach.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/needsToReattach.ts index d755f15464..942adc3fa2 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/needsToReattach.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/needsToReattach.ts @@ -1,5 +1,5 @@ -import { GestureType } from '../gesture'; -import { AttachedGestureState } from './types'; +import type { AttachedGestureState } from './types'; +import type { GestureType } from '../gesture'; // Checks whether the gesture should be reattached to the view, this will happen when: // - The number of gestures in the preparedGesture is different than the number of gestures in the gesture diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/types.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/types.ts index a0176b0f1c..e887ab2551 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/types.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/types.ts @@ -1,5 +1,5 @@ -import { SharedValue } from '../../../v3/types'; -import { GestureType, HandlerCallbacks } from '../gesture'; +import type { GestureType, HandlerCallbacks } from '../gesture'; +import type { SharedValue } from '../../../v3/types'; export interface AttachedGestureState { // Array of gestures that should be attached to the view under that gesture detector diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/updateHandlers.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/updateHandlers.ts index c5598e8560..d435d11369 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/updateHandlers.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/updateHandlers.ts @@ -1,15 +1,15 @@ -import { GestureType, HandlerCallbacks } from '../gesture'; -import { registerHandler } from '../../handlersRegistry'; -import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; -import { filterConfig, scheduleFlushOperations } from '../../utils'; -import { ComposedGesture } from '../gestureComposition'; -import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; -import { AttachedGestureState } from './types'; import { - extractGestureRelations, - checkGestureCallbacksForWorklets, ALLOWED_PROPS, + checkGestureCallbacksForWorklets, + extractGestureRelations, } from './utils'; +import type { GestureType, HandlerCallbacks } from '../gesture'; +import { filterConfig, scheduleFlushOperations } from '../../utils'; +import type { AttachedGestureState } from './types'; +import type { ComposedGesture } from '../gestureComposition'; +import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; +import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; +import { registerHandler } from '../../handlersRegistry'; export function updateHandlers( preparedGesture: AttachedGestureState, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts index 2b691f43fb..4900b2cae3 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts @@ -1,18 +1,17 @@ -import { HandlerCallbacks, CALLBACK_TYPE } from '../gesture'; -import { Reanimated } from '../reanimatedWrapper'; -import { +import type { + GestureStateChangeEvent, GestureTouchEvent, GestureUpdateEvent, - GestureStateChangeEvent, } from '../../gestureHandlerCommon'; -import { - GestureStateManager, - GestureStateManagerType, -} from '../gestureStateManager'; +import type { AttachedGestureState } from './types'; +import { CALLBACK_TYPE } from '../gesture'; +import { GestureStateManager } from '../gestureStateManager'; +import type { GestureStateManagerType } from '../gestureStateManager'; +import type { HandlerCallbacks } from '../gesture'; +import { Reanimated } from '../reanimatedWrapper'; import { State } from '../../../State'; import { TouchEventType } from '../../../TouchEventType'; import { tagMessage } from '../../../utils'; -import { AttachedGestureState } from './types'; function getHandler( type: CALLBACK_TYPE, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts index 8fc942532c..51bdb29854 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts @@ -1,15 +1,15 @@ -import React, { useCallback } from 'react'; -import { GestureType } from '../gesture'; -import { ComposedGesture } from '../gestureComposition'; - -import { AttachedGestureState, GestureDetectorState } from './types'; +import type { AttachedGestureState, GestureDetectorState } from './types'; +import { useForceRender, validateDetectorChildren } from './utils'; +import type { ComposedGesture } from '../gestureComposition'; +import type { GestureType } from '../gesture'; +import type { PropsRef } from '../../../web/interfaces'; +import type React from 'react'; import { attachHandlers } from './attachHandlers'; -import { updateHandlers } from './updateHandlers'; -import { needsToReattach } from './needsToReattach'; import { dropHandlers } from './dropHandlers'; -import { useForceRender, validateDetectorChildren } from './utils'; import findNodeHandle from '../../../findNodeHandle'; -import { PropsRef } from '../../../web/interfaces'; +import { needsToReattach } from './needsToReattach'; +import { updateHandlers } from './updateHandlers'; +import { useCallback } from 'react'; // Returns a function that's responsible for updating the attached gestures // If the view has changed, it will reattach the handlers to the new view diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts index 61190d29a9..a34c0409e0 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useMountReactions.ts @@ -1,8 +1,8 @@ -import { transformIntoHandlerTags } from '../../utils'; +import type { AttachedGestureState } from './types'; +import type { GestureRef } from '../gesture'; import { MountRegistry } from '../../../mountRegistry'; -import { AttachedGestureState } from './types'; +import { transformIntoHandlerTags } from '../../utils'; import { useEffect } from 'react'; -import { GestureRef } from '../gesture'; function shouldUpdateDetector( relation: GestureRef[] | undefined, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useViewRefHandler.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useViewRefHandler.ts index 2698368825..1282fcc747 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/useViewRefHandler.ts @@ -1,9 +1,9 @@ -import { tagMessage } from '../../../utils'; -import { getShadowNodeFromRef } from '../../../getShadowNodeFromRef'; - -import { GestureDetectorState } from './types'; -import React, { useCallback } from 'react'; +import type { GestureDetectorState } from './types'; +import type React from 'react'; import findNodeHandle from '../../../findNodeHandle'; +import { getShadowNodeFromRef } from '../../../getShadowNodeFromRef'; +import { tagMessage } from '../../../utils'; +import { useCallback } from 'react'; declare const global: { _isViewFlatteningDisabled: (node: unknown) => boolean | null; // JSI function diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts index 5a802135a2..315abf98af 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/utils.ts @@ -1,28 +1,27 @@ -import { Platform } from 'react-native'; - +import type { + GestureHandlerNativeEvent, + PropsRef, + ResultEvent, +} from '../../../web/interfaces'; +import type { GestureRef, GestureType } from '../gesture'; import { isTestEnv, tagMessage } from '../../../utils'; -import { GestureRef, BaseGesture, GestureType } from '../gesture'; - -import { flingGestureHandlerProps } from '../../FlingGestureHandler'; -import { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler'; -import { longPressGestureHandlerProps } from '../../LongPressGestureHandler'; import { - panGestureHandlerProps, panGestureHandlerCustomNativeProps, + panGestureHandlerProps, } from '../../PanGestureHandler'; -import { tapGestureHandlerProps } from '../../TapGestureHandler'; -import { hoverGestureHandlerProps } from '../hoverGesture'; -import { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler'; -import { baseGestureHandlerWithDetectorProps } from '../../gestureHandlerCommon'; -import { RNRenderer } from '../../../RNRenderer'; import { useCallback, useRef, useState } from 'react'; +import { BaseGesture } from '../gesture'; +import { Platform } from 'react-native'; +import { RNRenderer } from '../../../RNRenderer'; import { Reanimated } from '../reanimatedWrapper'; +import { baseGestureHandlerWithDetectorProps } from '../../gestureHandlerCommon'; +import { flingGestureHandlerProps } from '../../FlingGestureHandler'; +import { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler'; +import { hoverGestureHandlerProps } from '../hoverGesture'; +import { longPressGestureHandlerProps } from '../../LongPressGestureHandler'; +import { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler'; import { onGestureHandlerEvent } from '../eventReceiver'; -import { - GestureHandlerNativeEvent, - PropsRef, - ResultEvent, -} from '../../../web/interfaces'; +import { tapGestureHandlerProps } from '../../TapGestureHandler'; export const ALLOWED_PROPS = [ ...baseGestureHandlerWithDetectorProps, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/eventReceiver.ts b/packages/react-native-gesture-handler/src/handlers/gestures/eventReceiver.ts index 807423bcff..696a484fd9 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/eventReceiver.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/eventReceiver.ts @@ -1,17 +1,16 @@ -import { DeviceEventEmitter, EmitterSubscription } from 'react-native'; -import { State } from '../../State'; -import { TouchEventType } from '../../TouchEventType'; -import { +import type { + GestureStateChangeEvent, GestureTouchEvent, GestureUpdateEvent, - GestureStateChangeEvent, } from '../gestureHandlerCommon'; import { findHandler, findOldGestureHandler } from '../handlersRegistry'; -import { BaseGesture } from './gesture'; -import { - GestureStateManager, - GestureStateManagerType, -} from './gestureStateManager'; +import type { BaseGesture } from './gesture'; +import { DeviceEventEmitter } from 'react-native'; +import type { EmitterSubscription } from 'react-native'; +import { GestureStateManager } from './gestureStateManager'; +import type { GestureStateManagerType } from './gestureStateManager'; +import { State } from '../../State'; +import { TouchEventType } from '../../TouchEventType'; let gestureHandlerEventSubscription: EmitterSubscription | null = null; let gestureHandlerStateChangeEventSubscription: EmitterSubscription | null = diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts index 1147c8f71e..f13c7beb8b 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts @@ -1,5 +1,6 @@ -import { BaseGesture, BaseGestureConfig } from './gesture'; -import { FlingGestureConfig } from '../FlingGestureHandler'; +import { BaseGesture } from './gesture'; +import type { BaseGestureConfig } from './gesture'; +import type { FlingGestureConfig } from '../FlingGestureHandler'; import type { FlingGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class FlingGesture extends BaseGesture { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts index bd09df43d4..8bbd690736 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts @@ -1,7 +1,8 @@ -import { BaseGestureConfig, ContinousBaseGesture } from './gesture'; -import { ForceTouchGestureConfig } from '../ForceTouchGestureHandler'; +import type { BaseGestureConfig } from './gesture'; +import { ContinousBaseGesture } from './gesture'; +import type { ForceTouchGestureConfig } from '../ForceTouchGestureHandler'; import type { ForceTouchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; -import { GestureUpdateEvent } from '../gestureHandlerCommon'; +import type { GestureUpdateEvent } from '../gestureHandlerCommon'; /** * @deprecated ForceTouch gesture is deprecated and will be removed in the future. diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts index 8d6e2982c2..ca306e5d24 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts @@ -1,25 +1,25 @@ -import { - HitSlop, +import type { + ActiveCursor, CommonGestureConfig, - GestureTouchEvent, GestureStateChangeEvent, + GestureTouchEvent, GestureUpdateEvent, - ActiveCursor, + HitSlop, MouseButton, } from '../gestureHandlerCommon'; -import { getNextHandlerTag } from '../getNextHandlerTag'; -import { GestureStateManagerType } from './gestureStateManager'; import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, + HoverGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, + NativeViewGestureHandlerPayload, PanGestureHandlerEventPayload, PinchGestureHandlerEventPayload, RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, - NativeViewGestureHandlerPayload, - HoverGestureHandlerEventPayload, } from '../GestureHandlerEventPayload'; +import type { GestureStateManagerType } from './gestureStateManager'; +import { getNextHandlerTag } from '../getNextHandlerTag'; import { isRemoteDebuggingEnabled } from '../../utils'; export type GestureType = diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts b/packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts index fc4f436943..6e4ab7d7aa 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts @@ -1,4 +1,5 @@ -import { BaseGesture, Gesture, GestureRef, GestureType } from './gesture'; +import { BaseGesture, Gesture } from './gesture'; +import type { GestureRef, GestureType } from './gesture'; function extendRelation( currentRelation: GestureRef[] | undefined, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts b/packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts index 0ed518a164..15e277822f 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts @@ -1,19 +1,19 @@ -import { FlingGesture } from './flingGesture'; -import { ForceTouchGesture } from './forceTouchGesture'; -import { Gesture } from './gesture'; import { ComposedGesture, ExclusiveGesture, SimultaneousGesture, } from './gestureComposition'; +import { FlingGesture } from './flingGesture'; +import { ForceTouchGesture } from './forceTouchGesture'; +import type { Gesture } from './gesture'; +import { HoverGesture } from './hoverGesture'; import { LongPressGesture } from './longPressGesture'; +import { ManualGesture } from './manualGesture'; +import { NativeGesture } from './nativeGesture'; import { PanGesture } from './panGesture'; import { PinchGesture } from './pinchGesture'; import { RotationGesture } from './rotationGesture'; import { TapGesture } from './tapGesture'; -import { NativeGesture } from './nativeGesture'; -import { ManualGesture } from './manualGesture'; -import { HoverGesture } from './hoverGesture'; /** * `Gesture` is the object that allows you to create and compose gestures. diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.web.ts b/packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.web.ts index 5d55723806..9478e0f8b8 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.web.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.web.ts @@ -1,6 +1,6 @@ -import { State } from '../../State'; +import type { GestureStateManagerType } from './gestureStateManager'; import NodeManager from '../../web/tools/NodeManager'; -import { GestureStateManagerType } from './gestureStateManager'; +import { State } from '../../State'; export const GestureStateManager = { create(handlerTag: number): GestureStateManagerType { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts index 8e0036c52c..39b9991afc 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts @@ -1,5 +1,6 @@ -import { BaseGestureConfig, ContinousBaseGesture } from './gesture'; -import { GestureUpdateEvent } from '../gestureHandlerCommon'; +import type { BaseGestureConfig } from './gesture'; +import { ContinousBaseGesture } from './gesture'; +import type { GestureUpdateEvent } from '../gestureHandlerCommon'; import type { HoverGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export type HoverGestureChangeEventPayload = { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts index 52143d0048..9e57c9a32f 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts @@ -1,5 +1,6 @@ -import { BaseGesture, BaseGestureConfig } from './gesture'; -import { LongPressGestureConfig } from '../LongPressGestureHandler'; +import { BaseGesture } from './gesture'; +import type { BaseGestureConfig } from './gesture'; +import type { LongPressGestureConfig } from '../LongPressGestureHandler'; import type { LongPressGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class LongPressGesture extends BaseGesture { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts index aae5826a43..27c54cadbd 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts @@ -1,5 +1,5 @@ -import { GestureUpdateEvent } from '../gestureHandlerCommon'; import { ContinousBaseGesture } from './gesture'; +import type { GestureUpdateEvent } from '../gestureHandlerCommon'; function changeEventCalculator( current: GestureUpdateEvent>, diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts index 87fc068f1c..1427220578 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts @@ -1,5 +1,6 @@ -import { BaseGestureConfig, BaseGesture } from './gesture'; -import { NativeViewGestureConfig } from '../NativeViewGestureHandler'; +import { BaseGesture } from './gesture'; +import type { BaseGestureConfig } from './gesture'; +import type { NativeViewGestureConfig } from '../NativeViewGestureHandler'; import type { NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload'; export class NativeGesture extends BaseGesture { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/panGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/panGesture.ts index 399cff0a3b..0048bdc505 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/panGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/panGesture.ts @@ -1,6 +1,7 @@ -import { BaseGestureConfig, ContinousBaseGesture } from './gesture'; -import { GestureUpdateEvent } from '../gestureHandlerCommon'; -import { PanGestureConfig } from '../PanGestureHandler'; +import type { BaseGestureConfig } from './gesture'; +import { ContinousBaseGesture } from './gesture'; +import type { GestureUpdateEvent } from '../gestureHandlerCommon'; +import type { PanGestureConfig } from '../PanGestureHandler'; import type { PanGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export type PanGestureChangeEventPayload = { diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/pinchGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/pinchGesture.ts index 96976707fb..6d73f6fd8d 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/pinchGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/pinchGesture.ts @@ -1,6 +1,6 @@ import { ContinousBaseGesture } from './gesture'; +import type { GestureUpdateEvent } from '../gestureHandlerCommon'; import type { PinchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; -import { GestureUpdateEvent } from '../gestureHandlerCommon'; export type PinchGestureChangeEventPayload = { scaleChange: number; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts b/packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts index e4ec22a69e..1778347a1a 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts @@ -1,11 +1,11 @@ -import { ComponentClass } from 'react'; -import { tagMessage } from '../../utils'; -import { +import type { GestureCallbacks, GestureUpdateEventWithHandlerData, SharedValue, } from '../../v3/types'; +import type { ComponentClass } from 'react'; import { NativeProxy } from '../../v3/NativeProxy'; +import { tagMessage } from '../../utils'; export type ReanimatedContext = { lastUpdateEvent: GestureUpdateEventWithHandlerData | undefined; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/rotationGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/rotationGesture.ts index cf302eb88c..490ffd02a2 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/rotationGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/rotationGesture.ts @@ -1,6 +1,6 @@ import { ContinousBaseGesture } from './gesture'; +import type { GestureUpdateEvent } from '../gestureHandlerCommon'; import type { RotationGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; -import { GestureUpdateEvent } from '../gestureHandlerCommon'; type RotationGestureChangeEventPayload = { rotationChange: number; diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts b/packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts index 336a6d892b..fcacc4764e 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts +++ b/packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts @@ -1,5 +1,6 @@ -import { BaseGestureConfig, BaseGesture } from './gesture'; -import { TapGestureConfig } from '../TapGestureHandler'; +import { BaseGesture } from './gesture'; +import type { BaseGestureConfig } from './gesture'; +import type { TapGestureConfig } from '../TapGestureHandler'; import type { TapGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class TapGesture extends BaseGesture { diff --git a/packages/react-native-gesture-handler/src/handlers/handlersRegistry.ts b/packages/react-native-gesture-handler/src/handlers/handlersRegistry.ts index f0a1943260..896fe959bd 100644 --- a/packages/react-native-gesture-handler/src/handlers/handlersRegistry.ts +++ b/packages/react-native-gesture-handler/src/handlers/handlersRegistry.ts @@ -1,7 +1,10 @@ +import type { + GestureEvent, + HandlerStateChangeEvent, +} from './gestureHandlerCommon'; +import type { GestureType } from './gestures/gesture'; +import type { SingleGesture } from '../v3/types'; import { isTestEnv } from '../utils'; -import { GestureType } from './gestures/gesture'; -import { GestureEvent, HandlerStateChangeEvent } from './gestureHandlerCommon'; -import { SingleGesture } from '../v3/types'; export const handlerIDToTag: Record = {}; diff --git a/packages/react-native-gesture-handler/src/handlers/utils.ts b/packages/react-native-gesture-handler/src/handlers/utils.ts index 0d07a32289..05e8b25e1c 100644 --- a/packages/react-native-gesture-handler/src/handlers/utils.ts +++ b/packages/react-native-gesture-handler/src/handlers/utils.ts @@ -1,9 +1,9 @@ -import * as React from 'react'; +import type * as React from 'react'; import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native'; -import { handlerIDToTag } from './handlersRegistry'; -import { toArray } from '../utils'; import RNGestureHandlerModule from '../RNGestureHandlerModule'; import { ghQueueMicrotask } from '../ghQueueMicrotask'; +import { handlerIDToTag } from './handlersRegistry'; +import { toArray } from '../utils'; function isConfigParam(param: unknown, name: string) { // param !== Object(param) returns false if `param` is a function diff --git a/packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts b/packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts index ece62c3537..9297ef25f3 100644 --- a/packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts +++ b/packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts @@ -1,33 +1,8 @@ -import invariant from 'invariant'; -import { DeviceEventEmitter } from 'react-native'; -import { ReactTestInstance } from 'react-test-renderer'; -import { - FlingGestureHandler, - flingHandlerName, -} from '../handlers/FlingGestureHandler'; -import { - ForceTouchGestureHandler, - forceTouchHandlerName, -} from '../handlers/ForceTouchGestureHandler'; -import { +import type { BaseGestureHandlerProps, GestureEvent, HandlerStateChangeEvent, } from '../handlers/gestureHandlerCommon'; -import { FlingGesture } from '../handlers/gestures/flingGesture'; -import { ForceTouchGesture } from '../handlers/gestures/forceTouchGesture'; -import { BaseGesture, GestureType } from '../handlers/gestures/gesture'; -import { LongPressGesture } from '../handlers/gestures/longPressGesture'; -import { NativeGesture } from '../handlers/gestures/nativeGesture'; -import { PanGesture } from '../handlers/gestures/panGesture'; -import { PinchGesture } from '../handlers/gestures/pinchGesture'; -import { RotationGesture } from '../handlers/gestures/rotationGesture'; -import { TapGesture } from '../handlers/gestures/tapGesture'; -import { findHandlerByTestID } from '../handlers/handlersRegistry'; -import { - LongPressGestureHandler, - longPressHandlerName, -} from '../handlers/LongPressGestureHandler'; import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, @@ -38,30 +13,40 @@ import type { RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, } from '../handlers/GestureHandlerEventPayload'; -import { - NativeViewGestureHandler, - nativeViewHandlerName, -} from '../handlers/NativeViewGestureHandler'; -import { - PanGestureHandler, - panHandlerName, -} from '../handlers/PanGestureHandler'; -import { - PinchGestureHandler, - pinchHandlerName, -} from '../handlers/PinchGestureHandler'; -import { - RotationGestureHandler, - rotationHandlerName, -} from '../handlers/RotationGestureHandler'; -import { - TapGestureHandler, - tapHandlerName, -} from '../handlers/TapGestureHandler'; -import { State } from '../State'; import { hasProperty, withPrevAndCurrent } from '../utils'; +import { BaseGesture } from '../handlers/gestures/gesture'; +import { DeviceEventEmitter } from 'react-native'; +import type { FlingGesture } from '../handlers/gestures/flingGesture'; +import type { FlingGestureHandler } from '../handlers/FlingGestureHandler'; +import type { ForceTouchGesture } from '../handlers/gestures/forceTouchGesture'; +import type { ForceTouchGestureHandler } from '../handlers/ForceTouchGestureHandler'; +import type { GestureType } from '../handlers/gestures/gesture'; +import type { LongPressGesture } from '../handlers/gestures/longPressGesture'; +import type { LongPressGestureHandler } from '../handlers/LongPressGestureHandler'; +import type { NativeGesture } from '../handlers/gestures/nativeGesture'; +import type { NativeViewGestureHandler } from '../handlers/NativeViewGestureHandler'; +import type { PanGesture } from '../handlers/gestures/panGesture'; +import type { PanGestureHandler } from '../handlers/PanGestureHandler'; +import type { PinchGesture } from '../handlers/gestures/pinchGesture'; +import type { PinchGestureHandler } from '../handlers/PinchGestureHandler'; +import type { ReactTestInstance } from 'react-test-renderer'; +import type { RotationGesture } from '../handlers/gestures/rotationGesture'; +import type { RotationGestureHandler } from '../handlers/RotationGestureHandler'; import type { SingleGesture } from '../v3/types'; +import { State } from '../State'; +import type { TapGesture } from '../handlers/gestures/tapGesture'; +import type { TapGestureHandler } from '../handlers/TapGestureHandler'; +import { findHandlerByTestID } from '../handlers/handlersRegistry'; +import { flingHandlerName } from '../handlers/FlingGestureHandler'; +import { forceTouchHandlerName } from '../handlers/ForceTouchGestureHandler'; +import invariant from 'invariant'; +import { longPressHandlerName } from '../handlers/LongPressGestureHandler'; import { maybeUnpackValue } from '../v3/hooks/utils'; +import { nativeViewHandlerName } from '../handlers/NativeViewGestureHandler'; +import { panHandlerName } from '../handlers/PanGestureHandler'; +import { pinchHandlerName } from '../handlers/PinchGestureHandler'; +import { rotationHandlerName } from '../handlers/RotationGestureHandler'; +import { tapHandlerName } from '../handlers/TapGestureHandler'; // Load fireEvent conditionally, so RNGH may be used in setups without testing-library let fireEvent = ( diff --git a/packages/react-native-gesture-handler/src/mocks/GestureButtons.tsx b/packages/react-native-gesture-handler/src/mocks/GestureButtons.tsx index 6facc5b9b4..20687eac4c 100644 --- a/packages/react-native-gesture-handler/src/mocks/GestureButtons.tsx +++ b/packages/react-native-gesture-handler/src/mocks/GestureButtons.tsx @@ -1,5 +1,5 @@ -import React from 'react'; import { TouchableNativeFeedback, View } from 'react-native'; +import React from 'react'; const RawButton = ({ enabled, children, ...rest }: any) => ( diff --git a/packages/react-native-gesture-handler/src/mountRegistry.ts b/packages/react-native-gesture-handler/src/mountRegistry.ts index e61ba9dd07..5f570e0852 100644 --- a/packages/react-native-gesture-handler/src/mountRegistry.ts +++ b/packages/react-native-gesture-handler/src/mountRegistry.ts @@ -1,4 +1,4 @@ -import { GestureType } from './handlers/gestures/gesture'; +import type { GestureType } from './handlers/gestures/gesture'; interface ReactComponentWithHandlerTag extends React.Component { handlerTag: number; diff --git a/packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts b/packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts index c40798482b..222f61b13a 100644 --- a/packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts +++ b/packages/react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts @@ -1,5 +1,6 @@ -import { TurboModuleRegistry, TurboModule } from 'react-native'; -import { Double } from 'react-native/Libraries/Types/CodegenTypes'; +import type { Double } from 'react-native/Libraries/Types/CodegenTypes'; +import type { TurboModule } from 'react-native'; +import { TurboModuleRegistry } from 'react-native'; export interface Spec extends TurboModule { // This method returns a boolean only to force the codegen to generate diff --git a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts index bd65658e24..37adc5dd4c 100644 --- a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts +++ b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts @@ -1,10 +1,10 @@ -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; +import type { ColorValue, ViewProps } from 'react-native'; import type { + Float, Int32, WithDefault, - Float, } from 'react-native/Libraries/Types/CodegenTypes'; -import type { ViewProps, ColorValue } from 'react-native'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; // @ts-ignore - Redefining pointerEvents with WithDefault for codegen, conflicts with ViewProps type but codegen needs it interface NativeProps extends ViewProps { diff --git a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts index c7f1065f98..80dc00a70f 100644 --- a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts +++ b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerDetectorNativeComponent.ts @@ -1,12 +1,12 @@ -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; import type { - Int32, DirectEventHandler, - UnsafeMixed, Double, + Int32, + UnsafeMixed, WithDefault, } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from 'react-native'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; type GestureHandlerEvent = Readonly<{ handlerTag: Int32; diff --git a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts index bf63ce50c6..d3ce923df0 100644 --- a/packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts +++ b/packages/react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts @@ -1,6 +1,6 @@ -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; import type { Int32 } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps } from 'react-native'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; // Publicly accessible type, moduleId is set internally export interface RootViewNativeProps extends ViewProps { diff --git a/packages/react-native-gesture-handler/src/v3/NativeProxy.ts b/packages/react-native-gesture-handler/src/v3/NativeProxy.ts index 1260273272..1201a4cbd0 100644 --- a/packages/react-native-gesture-handler/src/v3/NativeProxy.ts +++ b/packages/react-native-gesture-handler/src/v3/NativeProxy.ts @@ -1,10 +1,10 @@ -import { scheduleOperationToBeFlushed } from '../handlers/utils'; -import RNGestureHandlerModule from '../RNGestureHandlerModule'; -import { +import type { BaseGestureConfig, GestureRelations, SingleGestureName, } from './types'; +import RNGestureHandlerModule from '../RNGestureHandlerModule'; +import { scheduleOperationToBeFlushed } from '../handlers/utils'; // Destructure functions that can be called on the UI thread to have // a raw HostFunction reference diff --git a/packages/react-native-gesture-handler/src/v3/NativeProxy.web.ts b/packages/react-native-gesture-handler/src/v3/NativeProxy.web.ts index 4a11307097..73f05ba8ae 100644 --- a/packages/react-native-gesture-handler/src/v3/NativeProxy.web.ts +++ b/packages/react-native-gesture-handler/src/v3/NativeProxy.web.ts @@ -1,9 +1,9 @@ -import RNGestureHandlerModule from '../RNGestureHandlerModule'; -import { +import type { BaseGestureConfig, GestureRelations, SingleGestureName, } from './types'; +import RNGestureHandlerModule from '../RNGestureHandlerModule'; export const NativeProxy = { createGestureHandler: >( diff --git a/packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx b/packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx index 7617cb85e0..90b508e9ad 100644 --- a/packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/GestureButtons.tsx @@ -1,16 +1,15 @@ -import React, { useRef } from 'react'; -import { Platform, StyleSheet, Animated } from 'react-native'; -import createNativeWrapper from '../createNativeWrapper'; -import GestureHandlerButton from '../../components/GestureHandlerButton'; +import { Animated, Platform, StyleSheet } from 'react-native'; import type { BaseButtonProps, BorderlessButtonProps, RawButtonProps, RectButtonProps, } from './GestureButtonsProps'; - +import React, { useRef } from 'react'; import type { GestureEvent } from '../types'; +import GestureHandlerButton from '../../components/GestureHandlerButton'; import type { NativeHandlerData } from '../hooks/gestures/native/NativeTypes'; +import createNativeWrapper from '../createNativeWrapper'; type CallbackEventType = GestureEvent; diff --git a/packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts b/packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts index b1a76b0493..5c3c472a2d 100644 --- a/packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts +++ b/packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts @@ -1,8 +1,7 @@ -import { StyleProp, ViewStyle } from 'react-native'; +import type { StyleProp, ViewStyle } from 'react-native'; +import type { ButtonProps } from '../../components/GestureHandlerButton'; +import type GestureHandlerButton from '../../components/GestureHandlerButton'; import type { NativeWrapperProperties } from '../types/NativeWrapperType'; -import GestureHandlerButton, { - ButtonProps, -} from '../../components/GestureHandlerButton'; /** * @deprecated `RawButtonProps` is deprecated, use `ClickableProps` instead diff --git a/packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx b/packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx index a7c7dbdb57..e13764a61e 100644 --- a/packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx @@ -1,23 +1,24 @@ -import React, { PropsWithChildren, ReactElement, useState } from 'react'; +import type { PropsWithChildren, ReactElement } from 'react'; import { + FlatList as RNFlatList, + RefreshControl as RNRefreshControl, ScrollView as RNScrollView, - ScrollViewProps as RNScrollViewProps, Switch as RNSwitch, - SwitchProps as RNSwitchProps, TextInput as RNTextInput, - TextInputProps as RNTextInputProps, - FlatList as RNFlatList, +} from 'react-native'; +import type { FlatListProps as RNFlatListProps, - RefreshControl as RNRefreshControl, RefreshControlProps as RNRefreshControlProps, + ScrollViewProps as RNScrollViewProps, + SwitchProps as RNSwitchProps, + TextInputProps as RNTextInputProps, } from 'react-native'; - -import createNativeWrapper from '../createNativeWrapper'; - -import type { NativeWrapperProperties } from '../types/NativeWrapperType'; -import { NativeWrapperProps } from '../hooks/utils'; +import React, { useState } from 'react'; import { GestureDetectorType } from '../detectors'; import type { NativeGesture } from '../hooks/gestures/native/NativeTypes'; +import type { NativeWrapperProperties } from '../types/NativeWrapperType'; +import { NativeWrapperProps } from '../hooks/utils'; +import createNativeWrapper from '../createNativeWrapper'; import { ghQueueMicrotask } from '../../ghQueueMicrotask'; export const RefreshControl = createNativeWrapper< diff --git a/packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx b/packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx index a9e69cc62d..46395e6526 100644 --- a/packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx @@ -1,13 +1,12 @@ import * as React from 'react'; import { FlatList as RNFlatList, + ScrollView as RNScrollView, Switch as RNSwitch, TextInput as RNTextInput, - ScrollView as RNScrollView, - FlatListProps, View, } from 'react-native'; - +import type { FlatListProps } from 'react-native'; import createNativeWrapper from '../createNativeWrapper'; export const ScrollView = createNativeWrapper(RNScrollView, { diff --git a/packages/react-native-gesture-handler/src/v3/components/Pressable.tsx b/packages/react-native-gesture-handler/src/v3/components/Pressable.tsx index 3d05214f5d..a68b883276 100644 --- a/packages/react-native-gesture-handler/src/v3/components/Pressable.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/Pressable.tsx @@ -1,3 +1,15 @@ +import { INT32_MAX, isTestEnv } from '../../utils'; +import type { + Insets, + LayoutChangeEvent, + StyleProp, + ViewStyle, +} from 'react-native'; +import type { + PressableDimensions, + PressableEvent, + PressableProps, +} from '../../components/Pressable/PressableProps'; import React, { useCallback, useEffect, @@ -6,29 +18,16 @@ import React, { useState, } from 'react'; import { - PressableDimensions, - PressableEvent, - PressableProps, -} from '../../components/Pressable/PressableProps'; -import { - Insets, - LayoutChangeEvent, - Platform, - StyleProp, - ViewStyle, -} from 'react-native'; + StateMachineEvent, + getStatesConfig, +} from '../../components/Pressable/stateDefinitions'; import { addInsets, - numberAsInset, + gestureToPressableEvent, gestureTouchToPressableEvent, isTouchWithinInset, - gestureToPressableEvent, + numberAsInset, } from '../../components/Pressable/utils'; -import { - getStatesConfig, - StateMachineEvent, -} from '../../components/Pressable/stateDefinitions'; -import { PressableStateMachine } from '../../components/Pressable/StateMachine'; import { useHoverGesture, useLongPressGesture, @@ -36,10 +35,10 @@ import { useSimultaneousGestures, } from '../hooks'; import { GestureDetector } from '../detectors'; -import { PureNativeButton } from './GestureButtons'; - +import { Platform } from 'react-native'; import { PressabilityDebugView } from '../../handlers/PressabilityDebugView'; -import { INT32_MAX, isTestEnv } from '../../utils'; +import { PressableStateMachine } from '../../components/Pressable/StateMachine'; +import { PureNativeButton } from './GestureButtons'; import { useIsScreenReaderEnabled } from '../../useIsScreenReaderEnabled'; const DEFAULT_LONG_PRESS_DURATION = 500; diff --git a/packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx b/packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx index 72a6c36d9c..8f4eaaf6b9 100644 --- a/packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx +++ b/packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx @@ -1,9 +1,8 @@ +import type { CallbackEventType, TouchableProps } from './TouchableProps'; import React, { useCallback, useRef } from 'react'; +import type { ButtonProps } from '../../../components/GestureHandlerButton'; +import GestureHandlerButton from '../../../components/GestureHandlerButton'; import { Platform } from 'react-native'; -import GestureHandlerButton, { - ButtonProps, -} from '../../../components/GestureHandlerButton'; -import { CallbackEventType, TouchableProps } from './TouchableProps'; import createNativeWrapper from '../../createNativeWrapper'; const TouchableButton = createNativeWrapper< diff --git a/packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts b/packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts index 5592149865..6c71a71a39 100644 --- a/packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts +++ b/packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts @@ -1,8 +1,8 @@ -import type { PressableAndroidRippleConfig as RNPressableAndroidRippleConfig } from 'react-native'; +import type { BaseButtonProps, RawButtonProps } from '../GestureButtonsProps'; import type { ButtonProps } from '../../../components/GestureHandlerButton'; import type { GestureEvent } from '../../types'; import type { NativeHandlerData } from '../../hooks/gestures/native/NativeTypes'; -import { BaseButtonProps, RawButtonProps } from '../GestureButtonsProps'; +import type { PressableAndroidRippleConfig as RNPressableAndroidRippleConfig } from 'react-native'; export type CallbackEventType = GestureEvent; diff --git a/packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx b/packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx index 139a56e59f..e5eb0b99d2 100644 --- a/packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx +++ b/packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx @@ -1,14 +1,13 @@ -import React, { useEffect } from 'react'; - -import { NativeWrapperProps } from './hooks/utils'; -import { useNativeGesture } from './hooks/gestures'; -import { NativeDetector } from './detectors/NativeDetector'; +import { GestureDetectorType, InterceptingGestureDetector } from './detectors'; import type { NativeWrapperProperties, WrapperSpecificProperties, } from './types/NativeWrapperType'; -import { GestureDetectorType, InterceptingGestureDetector } from './detectors'; +import React, { useEffect } from 'react'; +import { NativeDetector } from './detectors/NativeDetector'; +import { NativeWrapperProps } from './hooks/utils'; import { VirtualDetector } from './detectors/VirtualDetector/VirtualDetector'; +import { useNativeGesture } from './hooks/gestures'; export default function createNativeWrapper( Component: React.ComponentType, diff --git a/packages/react-native-gesture-handler/src/v3/detectors/GestureDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/GestureDetector.tsx index 1e97156e5a..5ccc4fd057 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/GestureDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/GestureDetector.tsx @@ -1,11 +1,9 @@ -import { NativeDetectorProps } from './common'; import { BaseGesture } from '../../handlers/gestures/gesture'; -import { NativeDetector } from './NativeDetector'; import { ComposedGesture } from '../../handlers/gestures/gestureComposition'; -import { - GestureDetectorProps as LegacyGestureDetectorProps, - GestureDetector as LegacyGestureDetector, -} from '../../handlers/gestures/GestureDetector'; +import { GestureDetector as LegacyGestureDetector } from '../../handlers/gestures/GestureDetector'; +import type { GestureDetectorProps as LegacyGestureDetectorProps } from '../../handlers/gestures/GestureDetector'; +import { NativeDetector } from './NativeDetector'; +import type { NativeDetectorProps } from './common'; import { useEnsureGestureHandlerRootView } from './useEnsureGestureHandlerRootView'; export function GestureDetector< diff --git a/packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx b/packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx index 03cc3f3c1c..87188653a0 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx @@ -1,10 +1,14 @@ -import React, { Ref, RefObject, useEffect, useMemo, useRef } from 'react'; -import RNGestureHandlerModule from '../../RNGestureHandlerModule.web'; +import React, { useEffect, useMemo, useRef } from 'react'; +import type { Ref, RefObject } from 'react'; +import type { + TouchAction, + UserSelect, +} from '../../handlers/gestureHandlerCommon'; import { ActionType } from '../../ActionType'; -import { PropsRef } from '../../web/interfaces'; +import type { PropsRef } from '../../web/interfaces'; +import RNGestureHandlerModule from '../../RNGestureHandlerModule.web'; import { View } from 'react-native'; import { tagMessage } from '../../utils'; -import { TouchAction, UserSelect } from '../../handlers/gestureHandlerCommon'; export interface GestureHandlerDetectorProps extends PropsRef { handlerTags: number[]; diff --git a/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx index 37614db708..fa2d8911bd 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/NativeDetector.tsx @@ -1,14 +1,11 @@ +import { AnimatedNativeDetector, nativeDetectorStyles } from './common'; import React, { useMemo } from 'react'; -import HostGestureDetector from './HostGestureDetector'; import { configureRelations, ensureNativeDetectorComponent } from './utils'; -import { isComposedGesture } from '../hooks/utils/relationUtils'; -import { - AnimatedNativeDetector, - NativeDetectorProps, - nativeDetectorStyles, -} from './common'; -import { ReanimatedNativeDetector } from './ReanimatedNativeDetector'; +import HostGestureDetector from './HostGestureDetector'; +import type { NativeDetectorProps } from './common'; import { Platform } from 'react-native'; +import { ReanimatedNativeDetector } from './ReanimatedNativeDetector'; +import { isComposedGesture } from '../hooks/utils/relationUtils'; export function NativeDetector< TConfig, diff --git a/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.tsx index ec84030cf4..56c651c702 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.tsx @@ -1,11 +1,9 @@ -import { useEffect, useMemo, useRef } from 'react'; -import { - NativeEventsManager, - Reanimated, -} from '../../handlers/gestures/reanimatedWrapper'; import HostGestureDetector, { type RNGestureHandlerDetectorNativeComponentProps, } from './HostGestureDetector'; +import { useEffect, useMemo, useRef } from 'react'; +import type { NativeEventsManager } from '../../handlers/gestures/reanimatedWrapper'; +import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; import { findNodeHandle } from 'react-native'; let NativeEventsManagerImpl = Reanimated?.NativeEventsManager; diff --git a/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.web.tsx b/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.web.tsx index 2036bce696..c3a9700dfe 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.web.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/ReanimatedNativeDetector.web.tsx @@ -1,5 +1,5 @@ -import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; import HostGestureDetector from './HostGestureDetector'; +import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; export const ReanimatedNativeDetector = Reanimated?.default.createAnimatedComponent(HostGestureDetector); diff --git a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx index 5056a2bbe6..88c90ca115 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx @@ -1,31 +1,28 @@ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import HostGestureDetector from '../HostGestureDetector'; -import { - VirtualChild, - GestureHandlerEventWithHandlerData, +import { AnimatedNativeDetector, nativeDetectorStyles } from '../common'; +import type { DetectorCallbacks, + GestureHandlerEventWithHandlerData, + VirtualChild, } from '../../types'; import { InterceptingDetectorContext, - InterceptingDetectorContextValue, InterceptingDetectorMode, } from './useInterceptingDetectorContext'; -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import type { + TouchAction, + UserSelect, +} from '../../../handlers/gestureHandlerCommon'; import { configureRelations, ensureNativeDetectorComponent } from '../utils'; +import HostGestureDetector from '../HostGestureDetector'; +import type { InterceptingDetectorContextValue } from './useInterceptingDetectorContext'; +import type { InterceptingGestureDetectorProps } from '../common'; +import { Platform } from 'react-native'; +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import { ReanimatedNativeDetector } from '../ReanimatedNativeDetector'; import { isComposedGesture } from '../../hooks/utils/relationUtils'; -import { - AnimatedNativeDetector, - InterceptingGestureDetectorProps, - nativeDetectorStyles, -} from '../common'; import { tagMessage } from '../../../utils'; import { useEnsureGestureHandlerRootView } from '../useEnsureGestureHandlerRootView'; -import { ReanimatedNativeDetector } from '../ReanimatedNativeDetector'; -import { Platform } from 'react-native'; -import { - TouchAction, - UserSelect, -} from '../../../handlers/gestureHandlerCommon'; interface StrippedVirtualChildren { viewTag: number; diff --git a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx index fae30d2c0e..e1f9d2ca47 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx +++ b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx @@ -1,15 +1,15 @@ -import { useCallback, useEffect, useRef, useState } from 'react'; -import { Wrap } from '../../../handlers/gestures/GestureDetector/Wrap'; -import { findNodeHandle, Platform } from 'react-native'; +import type { DetectorCallbacks, VirtualChild } from '../../types'; import { InterceptingDetectorMode, useInterceptingDetectorContext, } from './useInterceptingDetectorContext'; -import { isComposedGesture } from '../../hooks/utils/relationUtils'; -import { VirtualDetectorProps } from '../common'; +import { Platform, findNodeHandle } from 'react-native'; +import { useCallback, useEffect, useRef, useState } from 'react'; +import type { VirtualDetectorProps } from '../common'; +import { Wrap } from '../../../handlers/gestures/GestureDetector/Wrap'; import { configureRelations } from '../utils'; +import { isComposedGesture } from '../../hooks/utils/relationUtils'; import { tagMessage } from '../../../utils'; -import { DetectorCallbacks, VirtualChild } from '../../types'; function useRequiredInterceptingDetectorContext() { const context = useInterceptingDetectorContext(); diff --git a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/useInterceptingDetectorContext.ts b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/useInterceptingDetectorContext.ts index 105f4aaa75..59d8855ad9 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/useInterceptingDetectorContext.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/useInterceptingDetectorContext.ts @@ -1,5 +1,5 @@ import { createContext, use } from 'react'; -import { VirtualChild } from '../../types'; +import type { VirtualChild } from '../../types'; export enum InterceptingDetectorMode { DEFAULT, diff --git a/packages/react-native-gesture-handler/src/v3/detectors/common.ts b/packages/react-native-gesture-handler/src/v3/detectors/common.ts index 77f036cb6e..152faca5b6 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/common.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/common.ts @@ -1,9 +1,12 @@ -import React from 'react'; -import { Gesture } from '../types'; import { Animated, StyleSheet } from 'react-native'; +import type { + TouchAction, + UserSelect, +} from '../../handlers/gestureHandlerCommon'; +import type { Gesture } from '../types'; import HostGestureDetector from './HostGestureDetector'; -import { GestureDetectorProps as LegacyDetectorProps } from '../../handlers/gestures/GestureDetector'; -import { TouchAction, UserSelect } from '../../handlers/gestureHandlerCommon'; +import type { GestureDetectorProps as LegacyDetectorProps } from '../../handlers/gestures/GestureDetector'; +import type React from 'react'; export enum GestureDetectorType { Native, diff --git a/packages/react-native-gesture-handler/src/v3/detectors/useEnsureGestureHandlerRootView.ts b/packages/react-native-gesture-handler/src/v3/detectors/useEnsureGestureHandlerRootView.ts index 41fdf97698..e5c98b70cf 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/useEnsureGestureHandlerRootView.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/useEnsureGestureHandlerRootView.ts @@ -1,6 +1,6 @@ -import { use } from 'react'; -import { Platform } from 'react-native'; import GestureHandlerRootViewContext from '../../GestureHandlerRootViewContext'; +import { Platform } from 'react-native'; +import { use } from 'react'; export function useEnsureGestureHandlerRootView() { const rootViewContext = use(GestureHandlerRootViewContext); diff --git a/packages/react-native-gesture-handler/src/v3/detectors/utils.ts b/packages/react-native-gesture-handler/src/v3/detectors/utils.ts index 4ffecd7c46..e2f01b0d4d 100644 --- a/packages/react-native-gesture-handler/src/v3/detectors/utils.ts +++ b/packages/react-native-gesture-handler/src/v3/detectors/utils.ts @@ -4,13 +4,14 @@ // For `waitFor` we need array as order of the gestures matters. // For `simultaneousHandlers` we use Set as the order doesn't matter. -import { tagMessage } from '../../utils'; import { isComposedGesture, prepareRelations, } from '../hooks/utils/relationUtils'; +import { ComposedGestureName } from '../types'; +import type { Gesture } from '../types'; import { NativeProxy } from '../NativeProxy'; -import { ComposedGestureName, Gesture } from '../types'; +import { tagMessage } from '../../utils'; // The tree consists of ComposedGestures and NativeGestures. NativeGestures are always leaf nodes. export const traverseAndConfigureRelations = ( diff --git a/packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts b/packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts index 2be501eec2..cc0cabee38 100644 --- a/packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts +++ b/packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts @@ -1,8 +1,8 @@ -import { tagMessage } from '../utils'; -import IGestureHandler from '../web/handlers/IGestureHandler'; import GestureHandlerOrchestrator from '../web/tools/GestureHandlerOrchestrator'; +import type { GestureStateManagerType } from './gestureStateManager'; +import type IGestureHandler from '../web/handlers/IGestureHandler'; import NodeManager from '../web/tools/NodeManager'; -import { GestureStateManagerType } from './gestureStateManager'; +import { tagMessage } from '../utils'; function ensureHandlerAttached(handler: IGestureHandler) { if (!handler.attached) { diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/eventHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/eventHandler.ts index 7e273e8e68..10a9e8fc6d 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/eventHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/eventHandler.ts @@ -1,13 +1,4 @@ -import { - flattenAndFilterEvent, - isEventForHandlerWithTag, - maybeExtractNativeEvent, - runCallback, - touchEventTypeToCallbackType, -} from '../utils'; -import { tagMessage } from '../../../utils'; -import { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; -import { +import type { ChangeCalculatorType, GestureCallbacks, GestureEvent, @@ -15,11 +6,20 @@ import { GestureStateChangeEventWithHandlerData, GestureUpdateEventWithHandlerData, } from '../../types'; +import { + flattenAndFilterEvent, + isEventForHandlerWithTag, + maybeExtractNativeEvent, + runCallback, + touchEventTypeToCallbackType, +} from '../utils'; +import { isStateChangeEvent, isTouchEvent } from '../utils/eventUtils'; import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; +import type { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; +import type { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; import { State } from '../../../State'; import { TouchEventType } from '../../../TouchEventType'; -import { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; -import { isStateChangeEvent, isTouchEvent } from '../utils/eventUtils'; +import { tagMessage } from '../../../utils'; function handleStateChangeEvent< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/stateChangeHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/stateChangeHandler.ts index 10b34d90f5..f47c03a553 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/stateChangeHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/stateChangeHandler.ts @@ -1,7 +1,4 @@ -import { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; -import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; -import { State } from '../../../State'; -import { +import type { GestureCallbacks, GestureStateChangeEventWithHandlerData, StateChangeEventWithHandlerData, @@ -12,6 +9,9 @@ import { maybeExtractNativeEvent, runCallback, } from '../utils'; +import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; +import type { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; +import { State } from '../../../State'; export function getStateChangeHandler< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/touchEventHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/touchEventHandler.ts index f063111cc5..e0af9be510 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/touchEventHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/touchEventHandler.ts @@ -1,12 +1,12 @@ -import { GestureCallbacks, TouchEvent } from '../../types'; +import type { GestureCallbacks, TouchEvent } from '../../types'; import { isEventForHandlerWithTag, maybeExtractNativeEvent, runCallback, touchEventTypeToCallbackType, } from '../utils'; +import type { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; import { TouchEventType } from '../../../TouchEventType'; -import { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; export function getTouchEventHandler< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/updateHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/updateHandler.ts index ae022d968b..788cb080ff 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/updateHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/updateHandler.ts @@ -1,7 +1,4 @@ -import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; -import { tagMessage } from '../../../utils'; -import { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; -import { +import type { ChangeCalculatorType, GestureCallbacks, GestureUpdateEventWithHandlerData, @@ -13,6 +10,9 @@ import { maybeExtractNativeEvent, runCallback, } from '../utils'; +import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; +import type { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; +import { tagMessage } from '../../../utils'; export function getUpdateHandler< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useGestureEventHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useGestureEventHandler.ts index 27b2108a85..0c94138295 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useGestureEventHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useGestureEventHandler.ts @@ -1,11 +1,11 @@ -import { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; -import { +import type { BaseGestureConfig, GestureCallbacks, GestureHandlerEventWithHandlerData, } from '../../types'; -import { useMemo } from 'react'; +import type { ReanimatedContext } from '../../../handlers/gestures/reanimatedWrapper'; import { eventHandler } from './eventHandler'; +import { useMemo } from 'react'; export function useGestureEventHandler< TConfig, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts index dceec0ae2e..941eef0fb3 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts @@ -1,15 +1,13 @@ -import { useMemo } from 'react'; -import { - Reanimated, - ReanimatedHandler, -} from '../../../handlers/gestures/reanimatedWrapper'; -import { +import type { ChangeCalculatorType, GestureCallbacks, GestureEvent, UnpackedGestureHandlerEventWithHandlerData, } from '../../types'; +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import type { ReanimatedHandler } from '../../../handlers/gestures/reanimatedWrapper'; import { eventHandler } from './eventHandler'; +import { useMemo } from 'react'; const workletNOOP = () => { 'worklet'; diff --git a/packages/react-native-gesture-handler/src/v3/hooks/composition/useCompetingGestures.ts b/packages/react-native-gesture-handler/src/v3/hooks/composition/useCompetingGestures.ts index 42751ce6c8..2e89d369e7 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/composition/useCompetingGestures.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/composition/useCompetingGestures.ts @@ -1,4 +1,5 @@ -import { AnyGesture, ComposedGestureName } from '../../types'; +import type { AnyGesture } from '../../types'; +import { ComposedGestureName } from '../../types'; import { useComposedGesture } from './useComposedGesture'; export function useCompetingGestures(...gestures: AnyGesture[]) { diff --git a/packages/react-native-gesture-handler/src/v3/hooks/composition/useComposedGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/composition/useComposedGesture.ts index fa699dca4b..68baac7e07 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/composition/useComposedGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/composition/useComposedGesture.ts @@ -1,13 +1,13 @@ -import { - ComposedGesture, - ComposedGestureName, +import type { AnyGesture, + ComposedGesture, ComposedGestureConfig, + ComposedGestureName, GestureHandlerEventWithHandlerData, } from '../../types'; -import { tagMessage } from '../../../utils'; -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; import { containsDuplicates, isComposedGesture } from '../utils'; +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import { tagMessage } from '../../../utils'; // TODO: Simplify repeated relations (Simultaneous with Simultaneous, Exclusive with Exclusive, etc.) export function useComposedGesture( diff --git a/packages/react-native-gesture-handler/src/v3/hooks/composition/useExclusiveGestures.ts b/packages/react-native-gesture-handler/src/v3/hooks/composition/useExclusiveGestures.ts index 6ce32bf30e..013f932d6b 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/composition/useExclusiveGestures.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/composition/useExclusiveGestures.ts @@ -1,4 +1,5 @@ -import { AnyGesture, ComposedGestureName } from '../../types'; +import type { AnyGesture } from '../../types'; +import { ComposedGestureName } from '../../types'; import { useComposedGesture } from './useComposedGesture'; export function useExclusiveGestures(...gestures: AnyGesture[]) { diff --git a/packages/react-native-gesture-handler/src/v3/hooks/composition/useSimultaneousGestures.ts b/packages/react-native-gesture-handler/src/v3/hooks/composition/useSimultaneousGestures.ts index a6c2d1cdf2..322eae284e 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/composition/useSimultaneousGestures.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/composition/useSimultaneousGestures.ts @@ -1,4 +1,5 @@ -import { AnyGesture, ComposedGestureName } from '../../types'; +import type { AnyGesture } from '../../types'; +import { ComposedGestureName } from '../../types'; import { useComposedGesture } from './useComposedGesture'; export function useSimultaneousGestures(...gestures: AnyGesture[]) { diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/FlingTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/FlingTypes.ts index 617b6b75ca..cf093c3afa 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/FlingTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/FlingTypes.ts @@ -1,4 +1,4 @@ -import { +import type { BaseDiscreteGestureConfig, ExcludeInternalConfigProps, GestureEvent, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts index 8cfbb7c7d3..9fbe85360d 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/fling/useFlingGesture.ts @@ -1,12 +1,12 @@ -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { +import type { FlingGesture, FlingGestureConfig, FlingGestureProperties, FlingHandlerData, } from './FlingTypes'; +import { SingleGestureName } from '../../../types'; +import { useClonedAndRemappedConfig } from '../../utils'; +import { useGesture } from '../../useGesture'; export function useFlingGesture(config: FlingGestureConfig): FlingGesture { const flingConfig = useClonedAndRemappedConfig< diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/HoverTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/HoverTypes.ts index 31d86e6906..5aebc0d6d1 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/HoverTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/HoverTypes.ts @@ -1,12 +1,12 @@ -import { StylusData } from '../../../../handlers/gestureHandlerCommon'; -import { HoverEffect } from '../../../../handlers/gestures/hoverGesture'; -import { +import type { BaseGestureConfig, ExcludeInternalConfigProps, GestureEvent, SingleGesture, WithSharedValue, } from '../../../types'; +import type { HoverEffect } from '../../../../handlers/gestures/hoverGesture'; +import type { StylusData } from '../../../../handlers/gestureHandlerCommon'; export type HoverGestureExternalProperties = { /** diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts index 94c7cb97ce..8c1287d6f1 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/hover/useHoverGesture.ts @@ -1,10 +1,5 @@ -import { GestureEvent, HandlerData, SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { - useClonedAndRemappedConfig, - getChangeEventCalculator, -} from '../../utils'; -import { +import type { GestureEvent, HandlerData } from '../../../types'; +import type { HoverExtendedHandlerData, HoverGesture, HoverGestureConfig, @@ -13,6 +8,12 @@ import { HoverGestureProperties, HoverHandlerData, } from './HoverTypes'; +import { + getChangeEventCalculator, + useClonedAndRemappedConfig, +} from '../../utils'; +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; function diffCalculator( current: HandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/index.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/index.ts index b8d86c237d..0e3f1c84bd 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/index.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/index.ts @@ -1,56 +1,56 @@ import type { - FlingGestureEvent, - FlingGestureActiveEvent, FlingGesture, + FlingGestureActiveEvent, FlingGestureConfig, + FlingGestureEvent, } from './fling/FlingTypes'; import type { - HoverGestureEvent, HoverGesture, HoverGestureActiveEvent, HoverGestureConfig, + HoverGestureEvent, } from './hover/HoverTypes'; import type { - LongPressGestureEvent, - LongPressGestureActiveEvent, LongPressGesture, + LongPressGestureActiveEvent, LongPressGestureConfig, + LongPressGestureEvent, } from './longPress/LongPressTypes'; import type { - ManualGestureEvent, - ManualGestureActiveEvent, ManualGesture, + ManualGestureActiveEvent, ManualGestureConfig, + ManualGestureEvent, } from './manual/ManualTypes'; import type { - NativeGestureEvent, - NativeGestureActiveEvent, NativeGesture, + NativeGestureActiveEvent, NativeGestureConfig, + NativeGestureEvent, } from './native/NativeTypes'; import type { - PanGestureEvent, PanGesture, PanGestureActiveEvent, PanGestureConfig, + PanGestureEvent, } from './pan/PanTypes'; import type { - PinchGestureEvent, PinchGesture, PinchGestureActiveEvent, PinchGestureConfig, + PinchGestureEvent, } from './pinch/PinchTypes'; import type { - RotationGestureEvent, - RotationGestureActiveEvent, RotationGesture, + RotationGestureActiveEvent, RotationGestureConfig, + RotationGestureEvent, } from './rotation/RotationTypes'; import type { - TapGestureEvent, TapGesture, TapGestureActiveEvent, TapGestureConfig, + TapGestureEvent, } from './tap/TapTypes'; export type { diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/LongPressTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/LongPressTypes.ts index db920d2774..5736206cf7 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/LongPressTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/LongPressTypes.ts @@ -1,4 +1,4 @@ -import { +import type { BaseDiscreteGestureConfig, ExcludeInternalConfigProps, GestureEvent, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts index cb6be26d36..4b4846f403 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/longPress/useLongPressGesture.ts @@ -1,7 +1,4 @@ -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { +import type { LongPressGesture, LongPressGestureConfig, LongPressGestureInternalConfig, @@ -9,6 +6,9 @@ import { LongPressGestureProperties, LongPressHandlerData, } from './LongPressTypes'; +import { SingleGestureName } from '../../../types'; +import { useClonedAndRemappedConfig } from '../../utils'; +import { useGesture } from '../../useGesture'; const LongPressPropsMapping = new Map< keyof LongPressGestureProperties, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/ManualTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/ManualTypes.ts index 2059679a7b..81946bcac7 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/ManualTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/ManualTypes.ts @@ -1,4 +1,4 @@ -import { +import type { BaseGestureConfig, ExcludeInternalConfigProps, GestureEvent, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts index c2e520a344..cc84bd2efe 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/manual/useManualGesture.ts @@ -1,12 +1,12 @@ -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { - ManualGestureProperties, - ManualHandlerData, +import type { ManualGesture, ManualGestureConfig, + ManualGestureProperties, + ManualHandlerData, } from './ManualTypes'; +import { SingleGestureName } from '../../../types'; +import { useClonedAndRemappedConfig } from '../../utils'; +import { useGesture } from '../../useGesture'; export function useManualGesture(config: ManualGestureConfig): ManualGesture { const manualConfig = useClonedAndRemappedConfig< diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/NativeTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/NativeTypes.ts index be89910087..8acb6785a4 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/NativeTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/NativeTypes.ts @@ -1,4 +1,4 @@ -import { +import type { BaseGestureConfig, ExcludeInternalConfigProps, GestureEvent, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts index 708e03c5a0..756b866093 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/native/useNativeGesture.ts @@ -1,12 +1,12 @@ -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { +import type { NativeGesture, NativeGestureConfig, NativeGestureProperties, NativeHandlerData, } from './NativeTypes'; +import { SingleGestureName } from '../../../types'; +import { useClonedAndRemappedConfig } from '../../utils'; +import { useGesture } from '../../useGesture'; export function useNativeGesture(config: NativeGestureConfig): NativeGesture { const nativeConfig = useClonedAndRemappedConfig< diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/PanTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/PanTypes.ts index b1c7d42b17..0effa3e1c2 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/PanTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/PanTypes.ts @@ -1,11 +1,11 @@ -import { StylusData } from '../../../../handlers/gestureHandlerCommon'; -import { +import type { BaseGestureConfig, ExcludeInternalConfigProps, GestureEvent, SingleGesture, WithSharedValue, } from '../../../types'; +import type { StylusData } from '../../../../handlers/gestureHandlerCommon'; type CommonPanGestureProperties = { /** diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts index fd62e4b316..be1f920c47 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pan/usePanGesture.ts @@ -1,16 +1,9 @@ -import { +import type { GestureEvent, HandlerData, - SingleGestureName, WithSharedValue, } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { - getChangeEventCalculator, - maybeUnpackValue, - useClonedAndRemappedConfig, -} from '../../utils'; -import { +import type { OffsetProps, PanExtendedHandlerData, PanGesture, @@ -20,6 +13,13 @@ import { PanGestureProperties, PanHandlerData, } from './PanTypes'; +import { + getChangeEventCalculator, + maybeUnpackValue, + useClonedAndRemappedConfig, +} from '../../utils'; +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; const PanPropsMapping = new Map< keyof PanGestureProperties, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/PinchTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/PinchTypes.ts index 325eda0b4c..e6b7aa9877 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/PinchTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/PinchTypes.ts @@ -1,4 +1,4 @@ -import { +import type { BaseGestureConfig, ExcludeInternalConfigProps, GestureEvent, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts index 375990460c..e7013b0d11 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/pinch/usePinchGesture.ts @@ -1,10 +1,5 @@ -import { GestureEvent, HandlerData, SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { - useClonedAndRemappedConfig, - getChangeEventCalculator, -} from '../../utils'; -import { +import type { GestureEvent, HandlerData } from '../../../types'; +import type { PinchExtendedHandlerData, PinchGesture, PinchGestureConfig, @@ -12,6 +7,12 @@ import { PinchGestureProperties, PinchHandlerData, } from './PinchTypes'; +import { + getChangeEventCalculator, + useClonedAndRemappedConfig, +} from '../../utils'; +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; function diffCalculator( current: HandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/RotationTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/RotationTypes.ts index 97741be913..9327ca1d67 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/RotationTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/RotationTypes.ts @@ -1,4 +1,4 @@ -import { +import type { BaseGestureConfig, ExcludeInternalConfigProps, GestureEvent, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts index 9dfbfddc3b..b46fe11ace 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/rotation/useRotationGesture.ts @@ -1,10 +1,5 @@ -import { GestureEvent, HandlerData, SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { - useClonedAndRemappedConfig, - getChangeEventCalculator, -} from '../../utils'; -import { +import type { GestureEvent, HandlerData } from '../../../types'; +import type { RotationExtendedHandlerData, RotationGesture, RotationGestureConfig, @@ -12,6 +7,12 @@ import { RotationGestureProperties, RotationHandlerData, } from './RotationTypes'; +import { + getChangeEventCalculator, + useClonedAndRemappedConfig, +} from '../../utils'; +import { SingleGestureName } from '../../../types'; +import { useGesture } from '../../useGesture'; function diffCalculator( current: HandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/TapTypes.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/TapTypes.ts index 18f085aae0..4c1dfb1fbb 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/TapTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/TapTypes.ts @@ -1,4 +1,4 @@ -import { +import type { BaseDiscreteGestureConfig, DiscreteSingleGesture, ExcludeInternalConfigProps, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts index 8330c0b6de..87985f66f5 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/useTapGesture.ts @@ -1,13 +1,13 @@ -import { SingleGestureName } from '../../../types'; -import { useGesture } from '../../useGesture'; -import { useClonedAndRemappedConfig } from '../../utils'; -import { - TapGestureProperties, +import type { + TapGesture, + TapGestureConfig, TapGestureInternalProperties, + TapGestureProperties, TapHandlerData, - TapGestureConfig, - TapGesture, } from './TapTypes'; +import { SingleGestureName } from '../../../types'; +import { useClonedAndRemappedConfig } from '../../utils'; +import { useGesture } from '../../useGesture'; const TapPropsMapping = new Map< keyof TapGestureProperties, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts b/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts index 45d95363ee..124fe65394 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts @@ -1,21 +1,25 @@ -import { useEffect, useMemo, useRef } from 'react'; -import { getNextHandlerTag } from '../../handlers/getNextHandlerTag'; -import { useGestureCallbacks } from './useGestureCallbacks'; +import type { + BaseGestureConfig, + SingleGesture, + SingleGestureName, +} from '../types'; import { + bindSharedValues, prepareConfig, + prepareConfigForNativeSide, prepareRelations, - bindSharedValues, unbindSharedValues, - prepareConfigForNativeSide, } from './utils'; -import { tagMessage } from '../../utils'; -import { BaseGestureConfig, SingleGesture, SingleGestureName } from '../types'; -import { scheduleFlushOperations } from '../../handlers/utils'; import { registerGesture, unregisterGesture, } from '../../handlers/handlersRegistry'; +import { useEffect, useMemo, useRef } from 'react'; import { NativeProxy } from '../NativeProxy'; +import { getNextHandlerTag } from '../../handlers/getNextHandlerTag'; +import { scheduleFlushOperations } from '../../handlers/utils'; +import { tagMessage } from '../../utils'; +import { useGestureCallbacks } from './useGestureCallbacks'; export function useGesture< TConfig, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/useGestureCallbacks.ts b/packages/react-native-gesture-handler/src/v3/hooks/useGestureCallbacks.ts index a0c02fc63a..a1b0bb4643 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/useGestureCallbacks.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/useGestureCallbacks.ts @@ -1,5 +1,4 @@ -import { useGestureEventHandler } from './callbacks/useGestureEventHandler'; -import { +import type { AnimatedEvent, BaseGestureConfig, GestureUpdateEventWithHandlerData, @@ -9,9 +8,10 @@ import { isNativeAnimatedEvent, useMemoizedGestureCallbacks, } from './utils'; -import { useReanimatedEventHandler } from './callbacks/useReanimatedEventHandler'; -import { tagMessage } from '../../utils'; import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; +import { tagMessage } from '../../utils'; +import { useGestureEventHandler } from './callbacks/useGestureEventHandler'; +import { useReanimatedEventHandler } from './callbacks/useReanimatedEventHandler'; function guardJSAnimatedEvent(handler: (...args: unknown[]) => void) { return (...args: unknown[]) => { diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts index 9db466a05f..5fa4b16dc5 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts @@ -1,18 +1,18 @@ -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; -import { tagMessage } from '../../../utils'; -import { +import type { BaseGestureConfig, ExcludeInternalConfigProps, SingleGestureName, } from '../../types'; -import { hasWorkletEventHandlers, maybeUnpackValue } from './reanimatedUtils'; -import { isNativeAnimatedEvent, shouldHandleTouchEvents } from './eventUtils'; import { - allowedNativeProps, EMPTY_WHITE_LIST, PropsToFilter, PropsWhiteLists, + allowedNativeProps, } from './propsWhiteList'; +import { hasWorkletEventHandlers, maybeUnpackValue } from './reanimatedUtils'; +import { isNativeAnimatedEvent, shouldHandleTouchEvents } from './eventUtils'; +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; +import { tagMessage } from '../../../utils'; import { useMemo } from 'react'; export function prepareConfig< diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts index 58f14bebb1..d194aa488c 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/eventHandlersUtils.ts @@ -1,13 +1,13 @@ -import { useMemo } from 'react'; -import { TouchEventType } from '../../../TouchEventType'; -import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; -import { +import type { GestureCallbacks, GestureEventCallback, GestureEventCallbackWithDidSucceed, GestureTouchEventCallback, UnpackedGestureHandlerEvent, } from '../../types'; +import { CALLBACK_TYPE } from '../../../handlers/gestures/gesture'; +import { TouchEventType } from '../../../TouchEventType'; +import { useMemo } from 'react'; export function useMemoizedGestureCallbacks< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/eventUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/eventUtils.ts index 1c47b7ea94..cf736bf833 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/eventUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/eventUtils.ts @@ -1,15 +1,15 @@ -import { NativeSyntheticEvent } from 'react-native'; -import { +import type { AnimatedEvent, BaseGestureConfig, ChangeCalculatorType, DiffCalculatorType, + GestureEvent, GestureHandlerEventWithHandlerData, GestureStateChangeEventWithHandlerData, GestureUpdateEventWithHandlerData, - GestureEvent, } from '../../types'; -import { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; +import type { GestureTouchEvent } from '../../../handlers/gestureHandlerCommon'; +import type { NativeSyntheticEvent } from 'react-native'; import { tagMessage } from '../../../utils'; function isNativeEvent( diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts index 77d4ab103c..a9110bd0a0 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts @@ -1,18 +1,18 @@ -import { +import type { BaseGestureConfig, CommonGestureConfig, ExternalRelations, GestureCallbacks, HandlersPropsWhiteList, InternalConfigProps, - SingleGestureName, } from '../../types'; -import { NativeWrapperProperties } from '../../types/NativeWrapperType'; import { FlingNativeProperties } from '../gestures/fling/FlingTypes'; import { HoverNativeProperties } from '../gestures/hover/HoverTypes'; import { LongPressNativeProperties } from '../gestures/longPress/LongPressTypes'; import { NativeHandlerNativeProperties } from '../gestures/native/NativeTypes'; +import type { NativeWrapperProperties } from '../../types/NativeWrapperType'; import { PanNativeProperties } from '../gestures/pan/PanTypes'; +import { SingleGestureName } from '../../types'; import { TapNativeProperties } from '../gestures/tap/TapTypes'; const CommonConfig = new Set([ diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts index cd20d11d3f..6ecc7e493f 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts @@ -1,12 +1,12 @@ -import { NativeProxy } from '../../NativeProxy'; -import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; -import { +import type { BaseGestureConfig, GestureCallbacks, SharedValue, SharedValueOrT, } from '../../types'; import { HandlerCallbacks } from './propsWhiteList'; +import { NativeProxy } from '../../NativeProxy'; +import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper'; // Variant of djb2 hash function. // Taken from https://gist.github.com/eplawless/52813b1d8ad9af510d85?permalink_comment_id=3367765#gistcomment-3367765 diff --git a/packages/react-native-gesture-handler/src/v3/hooks/utils/relationUtils.ts b/packages/react-native-gesture-handler/src/v3/hooks/utils/relationUtils.ts index 19dbf7fb0d..55e5f3ee45 100644 --- a/packages/react-native-gesture-handler/src/v3/hooks/utils/relationUtils.ts +++ b/packages/react-native-gesture-handler/src/v3/hooks/utils/relationUtils.ts @@ -1,4 +1,4 @@ -import { +import type { ComposedGesture, ExternalRelations, Gesture, diff --git a/packages/react-native-gesture-handler/src/v3/types/ConfigTypes.ts b/packages/react-native-gesture-handler/src/v3/types/ConfigTypes.ts index a86315788d..a4d8bfda92 100644 --- a/packages/react-native-gesture-handler/src/v3/types/ConfigTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/types/ConfigTypes.ts @@ -1,4 +1,4 @@ -import { +import type { ActiveCursor, GestureTouchEvent, HitSlop, @@ -6,12 +6,12 @@ import { TouchAction, UserSelect, } from '../../handlers/gestureHandlerCommon'; -import { +import type { AnimatedEvent, ChangeCalculatorType, GestureEvent, } from './EventTypes'; -import { WithSharedValue } from './ReanimatedTypes'; +import type { WithSharedValue } from './ReanimatedTypes'; export type GestureEventCallback = ( event: GestureEvent diff --git a/packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts b/packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts index 88d2bb3c06..87624fc789 100644 --- a/packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts @@ -1,9 +1,12 @@ -import { +import type { AnimatedEvent, - GestureUpdateEventWithHandlerData, GestureHandlerEventWithHandlerData, + GestureUpdateEventWithHandlerData, } from './EventTypes'; -import { TouchAction, UserSelect } from '../../handlers/gestureHandlerCommon'; +import type { + TouchAction, + UserSelect, +} from '../../handlers/gestureHandlerCommon'; export type DetectorCallbacks< THandlerData, diff --git a/packages/react-native-gesture-handler/src/v3/types/EventTypes.ts b/packages/react-native-gesture-handler/src/v3/types/EventTypes.ts index 388c7ea02c..18427b91ae 100644 --- a/packages/react-native-gesture-handler/src/v3/types/EventTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/types/EventTypes.ts @@ -1,7 +1,7 @@ -import { Animated, NativeSyntheticEvent } from 'react-native'; -import { GestureTouchEvent } from '../../handlers/gestureHandlerCommon'; -import { PointerType } from '../../PointerType'; -import { State } from '../../State'; +import type { Animated, NativeSyntheticEvent } from 'react-native'; +import type { GestureTouchEvent } from '../../handlers/gestureHandlerCommon'; +import type { PointerType } from '../../PointerType'; +import type { State } from '../../State'; type EventPayload = { handlerTag: number; diff --git a/packages/react-native-gesture-handler/src/v3/types/GestureTypes.ts b/packages/react-native-gesture-handler/src/v3/types/GestureTypes.ts index 9e59c7fa1a..d78e7adc34 100644 --- a/packages/react-native-gesture-handler/src/v3/types/GestureTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/types/GestureTypes.ts @@ -1,12 +1,12 @@ -import { DetectorCallbacks } from './DetectorTypes'; -import { +import type { CommonGestureConfig, ComposedGestureConfig, GestureCallbacks, GestureRelations, InternalConfigProps, } from './ConfigTypes'; -import { FilterNeverProperties } from './UtilityTypes'; +import type { DetectorCallbacks } from './DetectorTypes'; +import type { FilterNeverProperties } from './UtilityTypes'; // Unfortunately, this type cannot be moved into ConfigTypes.ts because of circular dependency export type ExternalRelations = { diff --git a/packages/react-native-gesture-handler/src/v3/types/NativeWrapperType.ts b/packages/react-native-gesture-handler/src/v3/types/NativeWrapperType.ts index 7ffc10ecd8..2e581279b5 100644 --- a/packages/react-native-gesture-handler/src/v3/types/NativeWrapperType.ts +++ b/packages/react-native-gesture-handler/src/v3/types/NativeWrapperType.ts @@ -1,9 +1,13 @@ -import { CommonGestureConfig, ExternalRelations, GestureCallbacks } from '.'; +import type { + CommonGestureConfig, + ExternalRelations, + GestureCallbacks, +} from '.'; -import { +import type { + NativeGesture, NativeGestureNativeProperties, NativeHandlerData, - NativeGesture, } from '../hooks/gestures/native/NativeTypes'; export type WrapperSpecificProperties = { diff --git a/packages/react-native-gesture-handler/src/v3/types/UtilityTypes.ts b/packages/react-native-gesture-handler/src/v3/types/UtilityTypes.ts index 8f95353786..617e77fa73 100644 --- a/packages/react-native-gesture-handler/src/v3/types/UtilityTypes.ts +++ b/packages/react-native-gesture-handler/src/v3/types/UtilityTypes.ts @@ -1,10 +1,10 @@ -import { PanGestureNativeProperties } from '../hooks/gestures/pan/PanTypes'; -import { FlingGestureNativeProperties } from '../hooks/gestures/fling/FlingTypes'; -import { HoverGestureNativeProperties } from '../hooks/gestures/hover/HoverTypes'; -import { LongPressGestureNativeProperties } from '../hooks/gestures/longPress/LongPressTypes'; -import { NativeGestureNativeProperties } from '../hooks/gestures/native/NativeTypes'; -import { TapGestureNativeConfig } from '../hooks/gestures/tap/TapTypes'; -import { InternalConfigProps } from './ConfigTypes'; +import type { FlingGestureNativeProperties } from '../hooks/gestures/fling/FlingTypes'; +import type { HoverGestureNativeProperties } from '../hooks/gestures/hover/HoverTypes'; +import type { InternalConfigProps } from './ConfigTypes'; +import type { LongPressGestureNativeProperties } from '../hooks/gestures/longPress/LongPressTypes'; +import type { NativeGestureNativeProperties } from '../hooks/gestures/native/NativeTypes'; +import type { PanGestureNativeProperties } from '../hooks/gestures/pan/PanTypes'; +import type { TapGestureNativeConfig } from '../hooks/gestures/tap/TapTypes'; export type HandlersPropsWhiteList = | Set diff --git a/packages/react-native-gesture-handler/src/web/Gestures.ts b/packages/react-native-gesture-handler/src/web/Gestures.ts index fb57ba2f90..e83415388d 100644 --- a/packages/react-native-gesture-handler/src/web/Gestures.ts +++ b/packages/react-native-gesture-handler/src/web/Gestures.ts @@ -1,13 +1,13 @@ // Gesture Handlers -import PanGestureHandler from './handlers/PanGestureHandler'; -import TapGestureHandler from './handlers/TapGestureHandler'; +import FlingGestureHandler from './handlers/FlingGestureHandler'; +import HoverGestureHandler from './handlers/HoverGestureHandler'; import LongPressGestureHandler from './handlers/LongPressGestureHandler'; +import ManualGestureHandler from './handlers/ManualGestureHandler'; +import NativeViewGestureHandler from './handlers/NativeViewGestureHandler'; +import PanGestureHandler from './handlers/PanGestureHandler'; import PinchGestureHandler from './handlers/PinchGestureHandler'; import RotationGestureHandler from './handlers/RotationGestureHandler'; -import FlingGestureHandler from './handlers/FlingGestureHandler'; -import NativeViewGestureHandler from './handlers/NativeViewGestureHandler'; -import ManualGestureHandler from './handlers/ManualGestureHandler'; -import HoverGestureHandler from './handlers/HoverGestureHandler'; +import TapGestureHandler from './handlers/TapGestureHandler'; export const Gestures = { NativeViewGestureHandler, diff --git a/packages/react-native-gesture-handler/src/web/detectors/RotationGestureDetector.ts b/packages/react-native-gesture-handler/src/web/detectors/RotationGestureDetector.ts index c294d6f0c8..886cccd25a 100644 --- a/packages/react-native-gesture-handler/src/web/detectors/RotationGestureDetector.ts +++ b/packages/react-native-gesture-handler/src/web/detectors/RotationGestureDetector.ts @@ -1,5 +1,6 @@ -import { AdaptedEvent, EventTypes } from '../interfaces'; -import PointerTracker from '../tools/PointerTracker'; +import type { AdaptedEvent } from '../interfaces'; +import { EventTypes } from '../interfaces'; +import type PointerTracker from '../tools/PointerTracker'; export interface RotationGestureListener { onRotationBegin: (detector: RotationGestureDetector) => boolean; diff --git a/packages/react-native-gesture-handler/src/web/detectors/ScaleGestureDetector.ts b/packages/react-native-gesture-handler/src/web/detectors/ScaleGestureDetector.ts index b214213ee6..bbdd921d63 100644 --- a/packages/react-native-gesture-handler/src/web/detectors/ScaleGestureDetector.ts +++ b/packages/react-native-gesture-handler/src/web/detectors/ScaleGestureDetector.ts @@ -1,7 +1,7 @@ +import type { AdaptedEvent } from '../interfaces'; import { DEFAULT_TOUCH_SLOP } from '../constants'; -import { AdaptedEvent, EventTypes } from '../interfaces'; - -import PointerTracker from '../tools/PointerTracker'; +import { EventTypes } from '../interfaces'; +import type PointerTracker from '../tools/PointerTracker'; export interface ScaleGestureListener { onScaleBegin: (detector: ScaleGestureDetector) => boolean; diff --git a/packages/react-native-gesture-handler/src/web/handlers/FlingGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/FlingGestureHandler.ts index 2d4a80caa8..1d22c73a16 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/FlingGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/FlingGestureHandler.ts @@ -1,13 +1,12 @@ -import { State } from '../../State'; +import type { AdaptedEvent, Config } from '../interfaces'; import { DiagonalDirections, Directions } from '../../Directions'; -import { AdaptedEvent, Config } from '../interfaces'; - import GestureHandler from './GestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type IGestureHandler from './IGestureHandler'; +import { SingleGestureName } from '../../v3/types'; +import { State } from '../../State'; import Vector from '../tools/Vector'; import { coneToDeviation } from '../utils'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; -import IGestureHandler from './IGestureHandler'; -import { SingleGestureName } from '../../v3/types'; const DEFAULT_MAX_DURATION_MS = 800; const DEFAULT_MIN_VELOCITY = 700; diff --git a/packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts index c8588dae4e..71596acd79 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts @@ -1,37 +1,38 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import { State } from '../../State'; -import { - Config, - AdaptedEvent, - PropsRef, - ResultEvent, - PointerData, - EventTypes, - HitSlop, - GestureHandlerNativeEvent, -} from '../interfaces'; -import EventManager from '../tools/EventManager'; -import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator'; -import InteractionManager from '../tools/InteractionManager'; -import PointerTracker, { TrackerElement } from '../tools/PointerTracker'; -import IGestureHandler from './IGestureHandler'; -import { +import { ActionType, usesNativeOrVirtualDetector } from '../../ActionType'; +import type { ActiveCursor, + GestureTouchEvent, TouchAction, UserSelect, - GestureTouchEvent, - MouseButton, } from '../../handlers/gestureHandlerCommon'; -import { PointerType } from '../../PointerType'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; -import { ActionType, usesNativeOrVirtualDetector } from '../../ActionType'; -import { tagMessage } from '../../utils'; -import { +import type { + AdaptedEvent, + Config, + GestureHandlerNativeEvent, + HitSlop, + PointerData, + PropsRef, + ResultEvent, +} from '../interfaces'; +import type { GestureStateChangeEventWithHandlerData, GestureUpdateEventWithHandlerData, SingleGestureName, } from '../../v3/types'; +import type EventManager from '../tools/EventManager'; +import { EventTypes } from '../interfaces'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator'; +import type IGestureHandler from './IGestureHandler'; +import InteractionManager from '../tools/InteractionManager'; +import { MouseButton } from '../../handlers/gestureHandlerCommon'; +import PointerTracker from '../tools/PointerTracker'; +import { PointerType } from '../../PointerType'; +import { State } from '../../State'; import { TouchEventType } from '../../TouchEventType'; +import type { TrackerElement } from '../tools/PointerTracker'; +import { tagMessage } from '../../utils'; export default abstract class GestureHandler implements IGestureHandler { private _name!: SingleGestureName; diff --git a/packages/react-native-gesture-handler/src/web/handlers/HoverGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/HoverGestureHandler.ts index fe6c6a75ee..8866511a66 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/HoverGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/HoverGestureHandler.ts @@ -1,11 +1,11 @@ -import { State } from '../../State'; -import { AdaptedEvent } from '../interfaces'; -import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator'; +import type { AdaptedEvent } from '../interfaces'; import GestureHandler from './GestureHandler'; -import { StylusData } from '../../handlers/gestureHandlerCommon'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; -import IGestureHandler from './IGestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator'; +import type IGestureHandler from './IGestureHandler'; import { SingleGestureName } from '../../v3/types'; +import { State } from '../../State'; +import type { StylusData } from '../../handlers/gestureHandlerCommon'; export default class HoverGestureHandler extends GestureHandler { private stylusData: StylusData | undefined; diff --git a/packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts index f43e50d2e8..b8927f3970 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts @@ -1,16 +1,16 @@ -import type { PointerType } from '../../PointerType'; import type { ActiveCursor, MouseButton, TouchAction, UserSelect, } from '../../handlers/gestureHandlerCommon'; -import type { State } from '../../State'; import type { Config } from '../interfaces'; import type EventManager from '../tools/EventManager'; import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; import type PointerTracker from '../tools/PointerTracker'; -import { SingleGestureName } from '../../v3/types'; +import type { PointerType } from '../../PointerType'; +import type { SingleGestureName } from '../../v3/types'; +import type { State } from '../../State'; export default interface IGestureHandler { attached: boolean; diff --git a/packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts index fe410f8988..598fcda2dc 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts @@ -1,11 +1,10 @@ -import { ActionType } from '../../ActionType'; -import { State } from '../../State'; -import { SingleGestureName } from '../../v3/types'; -import { AdaptedEvent, Config, PropsRef } from '../interfaces'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; - +import type { AdaptedEvent, Config, PropsRef } from '../interfaces'; +import type { ActionType } from '../../ActionType'; import GestureHandler from './GestureHandler'; -import IGestureHandler from './IGestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type IGestureHandler from './IGestureHandler'; +import { SingleGestureName } from '../../v3/types'; +import { State } from '../../State'; const DEFAULT_MIN_DURATION_MS = 500; const DEFAULT_MAX_DIST_DP = 10; diff --git a/packages/react-native-gesture-handler/src/web/handlers/ManualGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/ManualGestureHandler.ts index 512fd7676a..258f2efb67 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/ManualGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/ManualGestureHandler.ts @@ -1,8 +1,8 @@ -import { SingleGestureName } from '../../v3/types'; -import { AdaptedEvent } from '../interfaces'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type { AdaptedEvent } from '../interfaces'; import GestureHandler from './GestureHandler'; -import IGestureHandler from './IGestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type IGestureHandler from './IGestureHandler'; +import { SingleGestureName } from '../../v3/types'; export default class ManualGestureHandler extends GestureHandler { public constructor( diff --git a/packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts index 9527193cdd..8da55feb3c 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts @@ -1,13 +1,12 @@ -import { Platform } from 'react-native'; -import { State } from '../../State'; +import type { AdaptedEvent, Config, PropsRef } from '../interfaces'; +import type { ActionType } from '../../ActionType'; import { DEFAULT_TOUCH_SLOP } from '../constants'; -import { AdaptedEvent, Config, PropsRef } from '../interfaces'; - import GestureHandler from './GestureHandler'; -import { ActionType } from '../../ActionType'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; -import IGestureHandler from './IGestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type IGestureHandler from './IGestureHandler'; +import { Platform } from 'react-native'; import { SingleGestureName } from '../../v3/types'; +import { State } from '../../State'; export default class NativeViewGestureHandler extends GestureHandler { private buttonRole!: boolean; diff --git a/packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts index 46b01b1b14..30f6859a3f 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts @@ -1,12 +1,12 @@ -import { State } from '../../State'; +import type { AdaptedEvent, Config } from '../interfaces'; import { DEFAULT_TOUCH_SLOP } from '../constants'; -import { AdaptedEvent, Config, WheelDevice } from '../interfaces'; -import { StylusData } from '../../handlers/gestureHandlerCommon'; - import GestureHandler from './GestureHandler'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; -import IGestureHandler from './IGestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type IGestureHandler from './IGestureHandler'; import { SingleGestureName } from '../../v3/types'; +import { State } from '../../State'; +import type { StylusData } from '../../handlers/gestureHandlerCommon'; +import { WheelDevice } from '../interfaces'; const DEFAULT_MIN_POINTERS = 1; const DEFAULT_MAX_POINTERS = 10; diff --git a/packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts index d28164fbb9..c5b3c847ff 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts @@ -1,15 +1,13 @@ -import { State } from '../../State'; +import type { AdaptedEvent, PropsRef } from '../interfaces'; +import type { ActionType } from '../../ActionType'; import { DEFAULT_TOUCH_SLOP } from '../constants'; -import { AdaptedEvent, PropsRef } from '../interfaces'; - import GestureHandler from './GestureHandler'; -import ScaleGestureDetector, { - ScaleGestureListener, -} from '../detectors/ScaleGestureDetector'; -import { ActionType } from '../../ActionType'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; -import IGestureHandler from './IGestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type IGestureHandler from './IGestureHandler'; +import ScaleGestureDetector from '../detectors/ScaleGestureDetector'; +import type { ScaleGestureListener } from '../detectors/ScaleGestureDetector'; import { SingleGestureName } from '../../v3/types'; +import { State } from '../../State'; export default class PinchGestureHandler extends GestureHandler { private scale = 1; diff --git a/packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts index a5efcc96ef..d59320f05f 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts @@ -1,14 +1,12 @@ -import { State } from '../../State'; -import { AdaptedEvent, PropsRef } from '../interfaces'; - +import type { AdaptedEvent, PropsRef } from '../interfaces'; +import type { ActionType } from '../../ActionType'; import GestureHandler from './GestureHandler'; -import RotationGestureDetector, { - RotationGestureListener, -} from '../detectors/RotationGestureDetector'; -import { ActionType } from '../../ActionType'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; -import IGestureHandler from './IGestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type IGestureHandler from './IGestureHandler'; +import RotationGestureDetector from '../detectors/RotationGestureDetector'; +import type { RotationGestureListener } from '../detectors/RotationGestureDetector'; import { SingleGestureName } from '../../v3/types'; +import { State } from '../../State'; const ROTATION_RECOGNITION_THRESHOLD = Math.PI / 36; diff --git a/packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts b/packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts index 7a06db4b68..dc3b0a4267 100644 --- a/packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts +++ b/packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts @@ -1,10 +1,10 @@ -import { State } from '../../State'; -import { SingleGestureName } from '../../v3/types'; -import { AdaptedEvent, Config, EventTypes } from '../interfaces'; -import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; - +import type { AdaptedEvent, Config } from '../interfaces'; +import { EventTypes } from '../interfaces'; import GestureHandler from './GestureHandler'; -import IGestureHandler from './IGestureHandler'; +import type { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate'; +import type IGestureHandler from './IGestureHandler'; +import { SingleGestureName } from '../../v3/types'; +import { State } from '../../State'; const DEFAULT_MAX_DURATION_MS = 500; const DEFAULT_MAX_DELAY_MS = 500; diff --git a/packages/react-native-gesture-handler/src/web/interfaces.ts b/packages/react-native-gesture-handler/src/web/interfaces.ts index 0c25e5c9a4..7c60f36af0 100644 --- a/packages/react-native-gesture-handler/src/web/interfaces.ts +++ b/packages/react-native-gesture-handler/src/web/interfaces.ts @@ -1,18 +1,18 @@ -import { - UserSelect, +import type { ActiveCursor, + GestureTouchEvent, MouseButton, - TouchAction, StylusData, - GestureTouchEvent, + TouchAction, + UserSelect, } from '../handlers/gestureHandlerCommon'; -import { Directions } from '../Directions'; -import { PointerType } from '../PointerType'; -import { +import type { GestureStateChangeEventWithHandlerData, GestureUpdateEventWithHandlerData, } from '../v3/types'; -import { State } from '../State'; +import type { Directions } from '../Directions'; +import type { PointerType } from '../PointerType'; +import type { State } from '../State'; export interface HitSlop { left?: number | undefined; diff --git a/packages/react-native-gesture-handler/src/web/tools/EventManager.ts b/packages/react-native-gesture-handler/src/web/tools/EventManager.ts index 95c82b4e1a..c18597f32c 100644 --- a/packages/react-native-gesture-handler/src/web/tools/EventManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/EventManager.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import { AdaptedEvent, EventTypes } from '../interfaces'; +import type { AdaptedEvent, EventTypes } from '../interfaces'; type PointerEventCallback = (event: AdaptedEvent) => void; diff --git a/packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts b/packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts index b0b27d96ec..9ed5b28040 100644 --- a/packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts +++ b/packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts @@ -1,8 +1,7 @@ -import { PointerType } from '../../PointerType'; -import { State } from '../../State'; - import type IGestureHandler from '../handlers/IGestureHandler'; import PointerTracker from './PointerTracker'; +import { PointerType } from '../../PointerType'; +import { State } from '../../State'; export default class GestureHandlerOrchestrator { private static _instance: GestureHandlerOrchestrator; diff --git a/packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts b/packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts index 8bc82f2b2a..7aa46abfad 100644 --- a/packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts +++ b/packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts @@ -1,18 +1,18 @@ -import findNodeHandle from '../../findNodeHandle'; -import type IGestureHandler from '../handlers/IGestureHandler'; -import { +import type { GestureHandlerDelegate, MeasureResult, } from './GestureHandlerDelegate'; +import { getEffectiveBoundingRect, isPointerInBounds } from '../utils'; +import type EventManager from './EventManager'; +import type IGestureHandler from '../handlers/IGestureHandler'; +import KeyboardEventManager from './KeyboardEventManager'; +import { MouseButton } from '../../handlers/gestureHandlerCommon'; import PointerEventManager from './PointerEventManager'; +import { SingleGestureName } from '../../v3/types'; import { State } from '../../State'; -import { isPointerInBounds, getEffectiveBoundingRect } from '../utils'; -import EventManager from './EventManager'; -import { MouseButton } from '../../handlers/gestureHandlerCommon'; -import KeyboardEventManager from './KeyboardEventManager'; import WheelEventManager from './WheelEventManager'; +import findNodeHandle from '../../findNodeHandle'; import { tagMessage } from '../../utils'; -import { SingleGestureName } from '../../v3/types'; interface DefaultViewStyles { userSelect: string; diff --git a/packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts b/packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts index 54999d094f..d09b523c33 100644 --- a/packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts @@ -1,6 +1,7 @@ -import { GestureRelations, SingleGestureName } from '../../v3/types'; +import type { Config, Handler } from '../interfaces'; +import type { GestureRelations } from '../../v3/types'; import type IGestureHandler from '../handlers/IGestureHandler'; -import { Config, Handler } from '../interfaces'; +import { SingleGestureName } from '../../v3/types'; export default class InteractionManager { private static _instance: InteractionManager; diff --git a/packages/react-native-gesture-handler/src/web/tools/KeyboardEventManager.ts b/packages/react-native-gesture-handler/src/web/tools/KeyboardEventManager.ts index ba7cf4cc78..394e39b06f 100644 --- a/packages/react-native-gesture-handler/src/web/tools/KeyboardEventManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/KeyboardEventManager.ts @@ -1,5 +1,6 @@ -import { AdaptedEvent, EventTypes } from '../interfaces'; +import type { AdaptedEvent } from '../interfaces'; import EventManager from './EventManager'; +import { EventTypes } from '../interfaces'; import { PointerType } from '../../PointerType'; export default class KeyboardEventManager extends EventManager { diff --git a/packages/react-native-gesture-handler/src/web/tools/NodeManager.ts b/packages/react-native-gesture-handler/src/web/tools/NodeManager.ts index b5df376613..6d055a4d0d 100644 --- a/packages/react-native-gesture-handler/src/web/tools/NodeManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/NodeManager.ts @@ -1,6 +1,6 @@ -import { ValueOf } from '../../typeUtils'; -import { Gestures } from '../Gestures'; +import type { Gestures } from '../Gestures'; import type IGestureHandler from '../handlers/IGestureHandler'; +import type { ValueOf } from '../../typeUtils'; // eslint-disable-next-line @typescript-eslint/no-extraneous-class export default abstract class NodeManager { diff --git a/packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts b/packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts index 3baabbd639..e081c749fe 100644 --- a/packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/PointerEventManager.ts @@ -1,12 +1,13 @@ -import EventManager from './EventManager'; -import { AdaptedEvent, EventTypes, Point } from '../interfaces'; +import type { AdaptedEvent, Point } from '../interfaces'; import { PointerTypeMapping, calculateViewScale, - tryExtractStylusData, - isPointerInBounds, getEffectiveBoundingRect, + isPointerInBounds, + tryExtractStylusData, } from '../utils'; +import EventManager from './EventManager'; +import { EventTypes } from '../interfaces'; import { PointerType } from '../../PointerType'; const POINTER_CAPTURE_EXCLUDE_LIST = new Set(['SELECT', 'INPUT']); diff --git a/packages/react-native-gesture-handler/src/web/tools/PointerTracker.ts b/packages/react-native-gesture-handler/src/web/tools/PointerTracker.ts index 5b933518a3..74fc5ba122 100644 --- a/packages/react-native-gesture-handler/src/web/tools/PointerTracker.ts +++ b/packages/react-native-gesture-handler/src/web/tools/PointerTracker.ts @@ -1,4 +1,4 @@ -import { AdaptedEvent, Point } from '../interfaces'; +import type { AdaptedEvent, Point } from '../interfaces'; import VelocityTracker from './VelocityTracker'; export interface TrackerElement { diff --git a/packages/react-native-gesture-handler/src/web/tools/Vector.ts b/packages/react-native-gesture-handler/src/web/tools/Vector.ts index c21120d0ed..d0dffce36f 100644 --- a/packages/react-native-gesture-handler/src/web/tools/Vector.ts +++ b/packages/react-native-gesture-handler/src/web/tools/Vector.ts @@ -1,6 +1,6 @@ import { DiagonalDirections, Directions } from '../../Directions'; import { MINIMAL_RECOGNIZABLE_MAGNITUDE } from '../constants'; -import PointerTracker from './PointerTracker'; +import type PointerTracker from './PointerTracker'; export default class Vector { private readonly x; diff --git a/packages/react-native-gesture-handler/src/web/tools/VelocityTracker.ts b/packages/react-native-gesture-handler/src/web/tools/VelocityTracker.ts index 67bd16a7f8..58d45309ea 100644 --- a/packages/react-native-gesture-handler/src/web/tools/VelocityTracker.ts +++ b/packages/react-native-gesture-handler/src/web/tools/VelocityTracker.ts @@ -1,4 +1,4 @@ -import { AdaptedEvent } from '../interfaces'; +import type { AdaptedEvent } from '../interfaces'; import CircularBuffer from './CircularBuffer'; import LeastSquareSolver from './LeastSquareSolver'; diff --git a/packages/react-native-gesture-handler/src/web/tools/WheelEventManager.ts b/packages/react-native-gesture-handler/src/web/tools/WheelEventManager.ts index 1ad6e87985..fa1aff8c98 100644 --- a/packages/react-native-gesture-handler/src/web/tools/WheelEventManager.ts +++ b/packages/react-native-gesture-handler/src/web/tools/WheelEventManager.ts @@ -1,5 +1,6 @@ +import type { AdaptedEvent } from '../interfaces'; import EventManager from './EventManager'; -import { AdaptedEvent, EventTypes } from '../interfaces'; +import { EventTypes } from '../interfaces'; import { PointerType } from '../../PointerType'; export default class WheelEventManager extends EventManager { diff --git a/packages/react-native-gesture-handler/src/web/utils.ts b/packages/react-native-gesture-handler/src/web/utils.ts index d0bce0fc2a..82980756aa 100644 --- a/packages/react-native-gesture-handler/src/web/utils.ts +++ b/packages/react-native-gesture-handler/src/web/utils.ts @@ -1,6 +1,6 @@ -import { PointerType } from '../PointerType'; import type { GestureHandlerRef, Point, SVGRef } from './interfaces'; -import { StylusData } from '../handlers/gestureHandlerCommon'; +import { PointerType } from '../PointerType'; +import type { StylusData } from '../handlers/gestureHandlerCommon'; // For display: contents elements (like the gesture detector wrapper), getBoundingClientRect // returns all zeros since the element has no box. Compute the bounding box from children instead. From f399e47bd821f7c56ba347cfbbc80fce68f1083a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Tue, 14 Apr 2026 14:43:29 +0200 Subject: [PATCH 2/2] Correct import --- .../src/handlers/gestures/GestureDetector/Wrap.web.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx index 33c43978e5..6945950d84 100644 --- a/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx +++ b/packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/Wrap.web.tsx @@ -1,7 +1,7 @@ import type { LegacyRef, PropsWithChildren } from 'react'; import React, { forwardRef } from 'react'; import { isRNSVGNode } from '../../../web/utils'; -import { tagMessage } from 'packages/react-native-gesture-handler/src/utils'; +import { tagMessage } from '../../../utils'; export const Wrap = forwardRef>( ({ children }, ref) => {