From 366ecc8e643c98ff51ce97dc394748a2ce4fac93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 28 Jun 2024 13:54:24 +0200 Subject: [PATCH 01/21] resolve circular dependencies in gestureHandlerCommon --- src/handlers/createHandler.tsx | 6 +- src/handlers/gestureCommonUtils.ts | 75 ++++++++++++++++++ src/handlers/gestureHandlerCommon.ts | 76 ------------------- .../GestureDetector/attachHandlers.ts | 2 +- .../gestures/GestureDetector/dropHandlers.ts | 2 +- .../GestureDetector/updateHandlers.ts | 2 +- 6 files changed, 82 insertions(+), 81 deletions(-) create mode 100644 src/handlers/gestureCommonUtils.ts diff --git a/src/handlers/createHandler.tsx b/src/handlers/createHandler.tsx index 9803d32943..0b963546de 100644 --- a/src/handlers/createHandler.tsx +++ b/src/handlers/createHandler.tsx @@ -16,12 +16,14 @@ import { import { BaseGestureHandlerProps, - filterConfig, GestureEvent, HandlerStateChangeEvent, +} from './gestureHandlerCommon'; +import { + filterConfig, findNodeHandle, scheduleFlushOperations, -} from './gestureHandlerCommon'; +} from './gestureCommonUtils'; import { ValueOf } from '../typeUtils'; import { deepEqual, isFabric, isJestEnv, tagMessage } from '../utils'; import { ActionType } from '../ActionType'; diff --git a/src/handlers/gestureCommonUtils.ts b/src/handlers/gestureCommonUtils.ts new file mode 100644 index 0000000000..13fdc488ab --- /dev/null +++ b/src/handlers/gestureCommonUtils.ts @@ -0,0 +1,75 @@ +import * 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'; + +function isConfigParam(param: unknown, name: string) { + // param !== Object(param) returns false if `param` is a function + // or an object and returns true if `param` is null + return ( + param !== undefined && + (param !== Object(param) || + !('__isNative' in (param as Record))) && + name !== 'onHandlerStateChange' && + name !== 'onGestureEvent' + ); +} + +export function filterConfig( + props: Record, + validProps: string[], + defaults: Record = {} +) { + const filteredConfig = { ...defaults }; + for (const key of validProps) { + let value = props[key]; + if (isConfigParam(value, key)) { + if (key === 'simultaneousHandlers' || key === 'waitFor') { + value = transformIntoHandlerTags(props[key]); + } else if (key === 'hitSlop' && typeof value !== 'object') { + value = { top: value, left: value, bottom: value, right: value }; + } + filteredConfig[key] = value; + } + } + return filteredConfig; +} +function transformIntoHandlerTags(handlerIDs: any) { + handlerIDs = toArray(handlerIDs); + + if (Platform.OS === 'web') { + return handlerIDs + .map(({ current }: { current: any }) => current) + .filter((handle: any) => handle); + } + // converts handler string IDs into their numeric tags + return handlerIDs + .map( + (handlerID: any) => + handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1 + ) + .filter((handlerTag: number) => handlerTag > 0); +} + +export function findNodeHandle( + node: null | number | React.Component | React.ComponentClass +): null | number | React.Component | React.ComponentClass { + if (Platform.OS === 'web') { + return node; + } + return findNodeHandleRN(node); +} +let flushOperationsScheduled = false; + +export function scheduleFlushOperations() { + if (!flushOperationsScheduled) { + flushOperationsScheduled = true; + ghQueueMicrotask(() => { + RNGestureHandlerModule.flushOperations(); + + flushOperationsScheduled = false; + }); + } +} diff --git a/src/handlers/gestureHandlerCommon.ts b/src/handlers/gestureHandlerCommon.ts index 9927d852eb..8979375d7a 100644 --- a/src/handlers/gestureHandlerCommon.ts +++ b/src/handlers/gestureHandlerCommon.ts @@ -3,15 +3,10 @@ // 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 { Platform, findNodeHandle as findNodeHandleRN } from 'react-native'; import { State } from '../State'; import { TouchEventType } from '../TouchEventType'; import { ValueOf } from '../typeUtils'; -import { handlerIDToTag } from './handlersRegistry'; -import { toArray } from '../utils'; -import RNGestureHandlerModule from '../RNGestureHandlerModule'; -import { ghQueueMicrotask } from '../ghQueueMicrotask'; import { PointerType } from '../PointerType'; const commonProps = [ @@ -214,74 +209,3 @@ export type BaseGestureHandlerProps< // implicit `children` prop has been removed in @types/react^18.0.0 children?: React.ReactNode; }; - -function isConfigParam(param: unknown, name: string) { - // param !== Object(param) returns false if `param` is a function - // or an object and returns true if `param` is null - return ( - param !== undefined && - (param !== Object(param) || - !('__isNative' in (param as Record))) && - name !== 'onHandlerStateChange' && - name !== 'onGestureEvent' - ); -} - -export function filterConfig( - props: Record, - validProps: string[], - defaults: Record = {} -) { - const filteredConfig = { ...defaults }; - for (const key of validProps) { - let value = props[key]; - if (isConfigParam(value, key)) { - if (key === 'simultaneousHandlers' || key === 'waitFor') { - value = transformIntoHandlerTags(props[key]); - } else if (key === 'hitSlop' && typeof value !== 'object') { - value = { top: value, left: value, bottom: value, right: value }; - } - filteredConfig[key] = value; - } - } - return filteredConfig; -} - -function transformIntoHandlerTags(handlerIDs: any) { - handlerIDs = toArray(handlerIDs); - - if (Platform.OS === 'web') { - return handlerIDs - .map(({ current }: { current: any }) => current) - .filter((handle: any) => handle); - } - // converts handler string IDs into their numeric tags - return handlerIDs - .map( - (handlerID: any) => - handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1 - ) - .filter((handlerTag: number) => handlerTag > 0); -} - -export function findNodeHandle( - node: null | number | React.Component | React.ComponentClass -): null | number | React.Component | React.ComponentClass { - if (Platform.OS === 'web') { - return node; - } - return findNodeHandleRN(node); -} - -let flushOperationsScheduled = false; - -export function scheduleFlushOperations() { - if (!flushOperationsScheduled) { - flushOperationsScheduled = true; - ghQueueMicrotask(() => { - RNGestureHandlerModule.flushOperations(); - - flushOperationsScheduled = false; - }); - } -} diff --git a/src/handlers/gestures/GestureDetector/attachHandlers.ts b/src/handlers/gestures/GestureDetector/attachHandlers.ts index 0ded87eb4e..cfee3947fe 100644 --- a/src/handlers/gestures/GestureDetector/attachHandlers.ts +++ b/src/handlers/gestures/GestureDetector/attachHandlers.ts @@ -5,7 +5,7 @@ import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; import { filterConfig, scheduleFlushOperations, -} from '../../gestureHandlerCommon'; +} from 'src/handlers/gestureCommonUtils'; import { ComposedGesture } from '../gestureComposition'; import { ActionType } from '../../../ActionType'; import { Platform } from 'react-native'; diff --git a/src/handlers/gestures/GestureDetector/dropHandlers.ts b/src/handlers/gestures/GestureDetector/dropHandlers.ts index 94e9a2081b..5cbbe04676 100644 --- a/src/handlers/gestures/GestureDetector/dropHandlers.ts +++ b/src/handlers/gestures/GestureDetector/dropHandlers.ts @@ -1,6 +1,6 @@ import { unregisterHandler } from '../../handlersRegistry'; import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; -import { scheduleFlushOperations } from '../../gestureHandlerCommon'; +import { scheduleFlushOperations } from 'src/handlers/gestureCommonUtils'; import { AttachedGestureState } from './types'; export function dropHandlers(preparedGesture: AttachedGestureState) { diff --git a/src/handlers/gestures/GestureDetector/updateHandlers.ts b/src/handlers/gestures/GestureDetector/updateHandlers.ts index 42bdc0d293..e797b4f87e 100644 --- a/src/handlers/gestures/GestureDetector/updateHandlers.ts +++ b/src/handlers/gestures/GestureDetector/updateHandlers.ts @@ -4,7 +4,7 @@ import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; import { filterConfig, scheduleFlushOperations, -} from '../../gestureHandlerCommon'; +} from 'src/handlers/gestureCommonUtils'; import { ComposedGesture } from '../gestureComposition'; import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; import { AttachedGestureState } from './types'; From b179bb8e75018bbff1f4135880c9ae58c369512d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 28 Jun 2024 14:51:09 +0200 Subject: [PATCH 02/21] move event payloads to separate file to resolve circular dependencies --- src/components/DrawerLayout.tsx | 8 +- src/components/GestureButtons.tsx | 6 +- src/components/ReanimatedSwipeable.tsx | 6 +- src/components/Swipeable.tsx | 6 +- .../touchables/GenericTouchable.tsx | 4 +- src/handlers/FlingGestureHandler.ts | 7 +- src/handlers/ForceTouchGestureHandler.ts | 13 +- src/handlers/GestureHandlerEventPayload.ts | 184 ++++++++++++++++++ src/handlers/LongPressGestureHandler.ts | 41 +--- src/handlers/NativeViewGestureHandler.ts | 8 +- src/handlers/PanGestureHandler.ts | 59 +----- src/handlers/PinchGestureHandler.ts | 28 +-- src/handlers/RotationGestureHandler.ts | 28 +-- src/handlers/TapGestureHandler.ts | 7 +- src/handlers/gestureHandlerTypesCompat.ts | 32 +-- src/handlers/gestures/flingGesture.ts | 6 +- src/handlers/gestures/forceTouchGesture.ts | 6 +- src/handlers/gestures/gesture.ts | 20 +- src/handlers/gestures/longPressGesture.ts | 6 +- src/handlers/gestures/nativeGesture.ts | 6 +- src/handlers/gestures/panGesture.ts | 6 +- src/handlers/gestures/pinchGesture.ts | 2 +- src/handlers/gestures/rotationGesture.ts | 2 +- src/handlers/gestures/tapGesture.ts | 6 +- src/index.ts | 40 ++-- src/jestUtils/jestUtils.ts | 18 +- 26 files changed, 261 insertions(+), 294 deletions(-) create mode 100644 src/handlers/GestureHandlerEventPayload.ts diff --git a/src/components/DrawerLayout.tsx b/src/components/DrawerLayout.tsx index 5ceb54581a..e49c1c8df8 100644 --- a/src/components/DrawerLayout.tsx +++ b/src/components/DrawerLayout.tsx @@ -30,14 +30,12 @@ import { ActiveCursor, MouseButton, } from '../handlers/gestureHandlerCommon'; +import { PanGestureHandler } from '../handlers/PanGestureHandler'; import { - PanGestureHandler, PanGestureHandlerEventPayload, -} from '../handlers/PanGestureHandler'; -import { - TapGestureHandler, TapGestureHandlerEventPayload, -} from '../handlers/TapGestureHandler'; +} from 'src/handlers/GestureHandlerEventPayload'; +import { TapGestureHandler } from '../handlers/TapGestureHandler'; import { State } from '../State'; const DRAG_TOSS = 0.05; diff --git a/src/components/GestureButtons.tsx b/src/components/GestureButtons.tsx index 8c9a867635..095c3fcdec 100644 --- a/src/components/GestureButtons.tsx +++ b/src/components/GestureButtons.tsx @@ -16,10 +16,8 @@ import { GestureEvent, HandlerStateChangeEvent, } from '../handlers/gestureHandlerCommon'; -import { - NativeViewGestureHandlerPayload, - NativeViewGestureHandlerProps, -} from '../handlers/NativeViewGestureHandler'; +import { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; +import { NativeViewGestureHandlerPayload } from 'src/handlers/GestureHandlerEventPayload'; export interface RawButtonProps extends NativeViewGestureHandlerProps { /** diff --git a/src/components/ReanimatedSwipeable.tsx b/src/components/ReanimatedSwipeable.tsx index aee977bb5a..1ac8b9c4d9 100644 --- a/src/components/ReanimatedSwipeable.tsx +++ b/src/components/ReanimatedSwipeable.tsx @@ -15,10 +15,8 @@ import { GestureStateChangeEvent, GestureUpdateEvent, } from '../handlers/gestureHandlerCommon'; -import { - PanGestureHandlerEventPayload, - PanGestureHandlerProps, -} from '../handlers/PanGestureHandler'; +import { PanGestureHandlerProps } from '../handlers/PanGestureHandler'; +import { PanGestureHandlerEventPayload } from 'src/handlers/GestureHandlerEventPayload'; import Animated, { Extrapolation, SharedValue, diff --git a/src/components/Swipeable.tsx b/src/components/Swipeable.tsx index e464540e5a..cdffb7c76c 100644 --- a/src/components/Swipeable.tsx +++ b/src/components/Swipeable.tsx @@ -20,13 +20,13 @@ import { } from '../handlers/gestureHandlerCommon'; import { PanGestureHandler, - PanGestureHandlerEventPayload, PanGestureHandlerProps, } from '../handlers/PanGestureHandler'; import { - TapGestureHandler, + PanGestureHandlerEventPayload, TapGestureHandlerEventPayload, -} from '../handlers/TapGestureHandler'; +} from 'src/handlers/GestureHandlerEventPayload'; +import { TapGestureHandler } from '../handlers/TapGestureHandler'; import { State } from '../State'; const DRAG_TOSS = 0.05; diff --git a/src/components/touchables/GenericTouchable.tsx b/src/components/touchables/GenericTouchable.tsx index b2fbd17afe..f35ef8a32f 100644 --- a/src/components/touchables/GenericTouchable.tsx +++ b/src/components/touchables/GenericTouchable.tsx @@ -17,7 +17,7 @@ import { HandlerStateChangeEvent, UserSelect, } from '../../handlers/gestureHandlerCommon'; -import { NativeViewGestureHandlerPayload } from '../../handlers/NativeViewGestureHandler'; +import { NativeViewGestureHandlerPayload } from 'src/handlers/GestureHandlerEventPayload'; import { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedback.android'; /** @@ -33,7 +33,7 @@ export const TOUCHABLE_STATE = { MOVED_OUTSIDE: 2, } as const; -type TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE]; +type TouchableState = (typeof TOUCHABLE_STATE)[keyof typeof TOUCHABLE_STATE]; export interface GenericTouchableProps extends Omit { diff --git a/src/handlers/FlingGestureHandler.ts b/src/handlers/FlingGestureHandler.ts index 88e0d5521b..68174929dd 100644 --- a/src/handlers/FlingGestureHandler.ts +++ b/src/handlers/FlingGestureHandler.ts @@ -1,3 +1,4 @@ +import { FlingGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, @@ -9,12 +10,6 @@ export const flingGestureHandlerProps = [ 'direction', ] as const; -export type FlingGestureHandlerEventPayload = { - x: number; - y: number; - absoluteX: number; - absoluteY: number; -}; export interface FlingGestureConfig { /** * Expressed allowed direction of movement. It's possible to pass one or many diff --git a/src/handlers/ForceTouchGestureHandler.ts b/src/handlers/ForceTouchGestureHandler.ts index 0de04e9209..775b7c9506 100644 --- a/src/handlers/ForceTouchGestureHandler.ts +++ b/src/handlers/ForceTouchGestureHandler.ts @@ -6,6 +6,7 @@ import { BaseGestureHandlerProps, baseGestureHandlerProps, } from './gestureHandlerCommon'; +import { ForceTouchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; export const forceTouchGestureHandlerProps = [ 'minForce', @@ -28,18 +29,6 @@ class ForceTouchFallback extends React.Component> { } } -export type ForceTouchGestureHandlerEventPayload = { - x: number; - y: number; - absoluteX: number; - absoluteY: number; - - /** - * The pressure of a touch. - */ - force: number; -}; - export interface ForceTouchGestureConfig { /** * diff --git a/src/handlers/GestureHandlerEventPayload.ts b/src/handlers/GestureHandlerEventPayload.ts new file mode 100644 index 0000000000..b6f59c577a --- /dev/null +++ b/src/handlers/GestureHandlerEventPayload.ts @@ -0,0 +1,184 @@ +export type FlingGestureHandlerEventPayload = { + x: number; + y: number; + absoluteX: number; + absoluteY: number; +}; + +export type ForceTouchGestureHandlerEventPayload = { + x: number; + y: number; + absoluteX: number; + absoluteY: number; + + /** + * The pressure of a touch. + */ + force: number; +}; + +export type LongPressGestureHandlerEventPayload = { + /** + * X coordinate, expressed in points, of the current position of the pointer + * (finger or a leading pointer when there are multiple fingers placed) + * relative to the view attached to the handler. + */ + x: number; + + /** + * Y coordinate, expressed in points, of the current position of the pointer + * (finger or a leading pointer when there are multiple fingers placed) + * relative to the view attached to the handler. + */ + y: number; + + /** + * X coordinate, expressed in points, of the current position of the pointer + * (finger or a leading pointer when there are multiple fingers placed) + * relative to the window. It is recommended to use `absoluteX` instead of + * `x` in cases when the view attached to the handler can be transformed as an + * effect of the gesture. + */ + absoluteX: number; + + /** + * Y coordinate, expressed in points, of the current position of the pointer + * (finger or a leading pointer when there are multiple fingers placed) + * relative to the window. It is recommended to use `absoluteY` instead of + * `y` in cases when the view attached to the handler can be transformed as an + * effect of the gesture. + */ + absoluteY: number; + + /** + * Duration of the long press (time since the start of the event), expressed + * in milliseconds. + */ + duration: number; +}; + +export type NativeViewGestureHandlerPayload = { + /** + * True if gesture was performed inside of containing view, false otherwise. + */ + pointerInside: boolean; +}; + +export type PanGestureHandlerEventPayload = { + /** + * X coordinate of the current position of the pointer (finger or a leading + * pointer when there are multiple fingers placed) relative to the view + * attached to the handler. Expressed in point units. + */ + x: number; + + /** + * Y coordinate of the current position of the pointer (finger or a leading + * pointer when there are multiple fingers placed) relative to the view + * attached to the handler. Expressed in point units. + */ + y: number; + + /** + * X coordinate of the current position of the pointer (finger or a leading + * pointer when there are multiple fingers placed) relative to the window. + * The value is expressed in point units. It is recommended to use it instead + * of `x` in cases when the original view can be transformed as an effect of + * the gesture. + */ + absoluteX: number; + + /** + * Y coordinate of the current position of the pointer (finger or a leading + * pointer when there are multiple fingers placed) relative to the window. + * The value is expressed in point units. It is recommended to use it instead + * of `y` in cases when the original view can be transformed as an + * effect of the gesture. + */ + absoluteY: number; + + /** + * Translation of the pan gesture along X axis accumulated over the time of + * the gesture. The value is expressed in the point units. + */ + translationX: number; + + /** + * Translation of the pan gesture along Y axis accumulated over the time of + * the gesture. The value is expressed in the point units. + */ + translationY: number; + + /** + * Velocity of the pan gesture along the X axis in the current moment. The + * value is expressed in point units per second. + */ + velocityX: number; + + /** + * Velocity of the pan gesture along the Y axis in the current moment. The + * value is expressed in point units per second. + */ + velocityY: number; +}; + +export type PinchGestureHandlerEventPayload = { + /** + * The scale factor relative to the points of the two touches in screen + * coordinates. + */ + scale: number; + + /** + * Position expressed in points along X axis of center anchor point of + * gesture. + */ + focalX: number; + + /** + * Position expressed in points along Y axis of center anchor point of + * gesture. + */ + focalY: number; + + /** + * + * Velocity of the pan gesture the current moment. The value is expressed in + * point units per second. + */ + velocity: number; +}; + +export type TapGestureHandlerEventPayload = { + x: number; + y: number; + absoluteX: number; + absoluteY: number; +}; + +export type RotationGestureHandlerEventPayload = { + /** + * Amount rotated, expressed in radians, from the gesture's focal point + * (anchor). + */ + rotation: number; + + /** + * X coordinate, expressed in points, of the gesture's central focal point + * (anchor). + */ + anchorX: number; + + /** + * Y coordinate, expressed in points, of the gesture's central focal point + * (anchor). + */ + anchorY: number; + + /** + * + * Instantaneous velocity, expressed in point units per second, of the + * gesture. + */ + velocity: number; +}; diff --git a/src/handlers/LongPressGestureHandler.ts b/src/handlers/LongPressGestureHandler.ts index 1cfaa7f874..9b888b929a 100644 --- a/src/handlers/LongPressGestureHandler.ts +++ b/src/handlers/LongPressGestureHandler.ts @@ -1,3 +1,4 @@ +import { LongPressGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, @@ -9,46 +10,6 @@ export const longPressGestureHandlerProps = [ 'maxDist', ] as const; -export type LongPressGestureHandlerEventPayload = { - /** - * X coordinate, expressed in points, of the current position of the pointer - * (finger or a leading pointer when there are multiple fingers placed) - * relative to the view attached to the handler. - */ - x: number; - - /** - * Y coordinate, expressed in points, of the current position of the pointer - * (finger or a leading pointer when there are multiple fingers placed) - * relative to the view attached to the handler. - */ - y: number; - - /** - * X coordinate, expressed in points, of the current position of the pointer - * (finger or a leading pointer when there are multiple fingers placed) - * relative to the window. It is recommended to use `absoluteX` instead of - * `x` in cases when the view attached to the handler can be transformed as an - * effect of the gesture. - */ - absoluteX: number; - - /** - * Y coordinate, expressed in points, of the current position of the pointer - * (finger or a leading pointer when there are multiple fingers placed) - * relative to the window. It is recommended to use `absoluteY` instead of - * `y` in cases when the view attached to the handler can be transformed as an - * effect of the gesture. - */ - absoluteY: number; - - /** - * Duration of the long press (time since the start of the event), expressed - * in milliseconds. - */ - duration: number; -}; - export interface LongPressGestureConfig { /** * Minimum time, expressed in milliseconds, that a finger must remain pressed on diff --git a/src/handlers/NativeViewGestureHandler.ts b/src/handlers/NativeViewGestureHandler.ts index acba7908a5..02f3b49efb 100644 --- a/src/handlers/NativeViewGestureHandler.ts +++ b/src/handlers/NativeViewGestureHandler.ts @@ -1,3 +1,4 @@ +import { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, @@ -29,13 +30,6 @@ export interface NativeViewGestureHandlerProps extends BaseGestureHandlerProps, NativeViewGestureConfig {} -export type NativeViewGestureHandlerPayload = { - /** - * True if gesture was performed inside of containing view, false otherwise. - */ - pointerInside: boolean; -}; - export const nativeViewProps = [ ...baseGestureHandlerProps, ...nativeViewGestureHandlerProps, diff --git a/src/handlers/PanGestureHandler.ts b/src/handlers/PanGestureHandler.ts index 416723abae..4669fe09ec 100644 --- a/src/handlers/PanGestureHandler.ts +++ b/src/handlers/PanGestureHandler.ts @@ -1,3 +1,4 @@ +import { PanGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, @@ -31,64 +32,6 @@ export const panGestureHandlerCustomNativeProps = [ 'failOffsetXEnd', ] as const; -export type PanGestureHandlerEventPayload = { - /** - * X coordinate of the current position of the pointer (finger or a leading - * pointer when there are multiple fingers placed) relative to the view - * attached to the handler. Expressed in point units. - */ - x: number; - - /** - * Y coordinate of the current position of the pointer (finger or a leading - * pointer when there are multiple fingers placed) relative to the view - * attached to the handler. Expressed in point units. - */ - y: number; - - /** - * X coordinate of the current position of the pointer (finger or a leading - * pointer when there are multiple fingers placed) relative to the window. - * The value is expressed in point units. It is recommended to use it instead - * of `x` in cases when the original view can be transformed as an effect of - * the gesture. - */ - absoluteX: number; - - /** - * Y coordinate of the current position of the pointer (finger or a leading - * pointer when there are multiple fingers placed) relative to the window. - * The value is expressed in point units. It is recommended to use it instead - * of `y` in cases when the original view can be transformed as an - * effect of the gesture. - */ - absoluteY: number; - - /** - * Translation of the pan gesture along X axis accumulated over the time of - * the gesture. The value is expressed in the point units. - */ - translationX: number; - - /** - * Translation of the pan gesture along Y axis accumulated over the time of - * the gesture. The value is expressed in the point units. - */ - translationY: number; - - /** - * Velocity of the pan gesture along the X axis in the current moment. The - * value is expressed in point units per second. - */ - velocityX: number; - - /** - * Velocity of the pan gesture along the Y axis in the current moment. The - * value is expressed in point units per second. - */ - velocityY: number; -}; - interface CommonPanProperties { /** * Minimum distance the finger (or multiple finger) need to travel before the diff --git a/src/handlers/PinchGestureHandler.ts b/src/handlers/PinchGestureHandler.ts index e588cbc262..a7a7bf9cb6 100644 --- a/src/handlers/PinchGestureHandler.ts +++ b/src/handlers/PinchGestureHandler.ts @@ -1,36 +1,10 @@ +import { PinchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, baseGestureHandlerProps, } from './gestureHandlerCommon'; -export type PinchGestureHandlerEventPayload = { - /** - * The scale factor relative to the points of the two touches in screen - * coordinates. - */ - scale: number; - - /** - * Position expressed in points along X axis of center anchor point of - * gesture. - */ - focalX: number; - - /** - * Position expressed in points along Y axis of center anchor point of - * gesture. - */ - focalY: number; - - /** - * - * Velocity of the pan gesture the current moment. The value is expressed in - * point units per second. - */ - velocity: number; -}; - export interface PinchGestureHandlerProps extends BaseGestureHandlerProps {} diff --git a/src/handlers/RotationGestureHandler.ts b/src/handlers/RotationGestureHandler.ts index 2a62135bf3..d6b35c1ca3 100644 --- a/src/handlers/RotationGestureHandler.ts +++ b/src/handlers/RotationGestureHandler.ts @@ -1,36 +1,10 @@ +import { RotationGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, baseGestureHandlerProps, } from './gestureHandlerCommon'; -export type RotationGestureHandlerEventPayload = { - /** - * Amount rotated, expressed in radians, from the gesture's focal point - * (anchor). - */ - rotation: number; - - /** - * X coordinate, expressed in points, of the gesture's central focal point - * (anchor). - */ - anchorX: number; - - /** - * Y coordinate, expressed in points, of the gesture's central focal point - * (anchor). - */ - anchorY: number; - - /** - * - * Instantaneous velocity, expressed in point units per second, of the - * gesture. - */ - velocity: number; -}; - export interface RotationGestureHandlerProps extends BaseGestureHandlerProps {} diff --git a/src/handlers/TapGestureHandler.ts b/src/handlers/TapGestureHandler.ts index 9ea3a98b9a..097f2cd0b4 100644 --- a/src/handlers/TapGestureHandler.ts +++ b/src/handlers/TapGestureHandler.ts @@ -1,3 +1,4 @@ +import { TapGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, @@ -14,12 +15,6 @@ export const tapGestureHandlerProps = [ 'minPointers', ] as const; -export type TapGestureHandlerEventPayload = { - x: number; - y: number; - absoluteX: number; - absoluteY: number; -}; export interface TapGestureConfig { /** * Minimum number of pointers (fingers) required to be placed before the diff --git a/src/handlers/gestureHandlerTypesCompat.ts b/src/handlers/gestureHandlerTypesCompat.ts index 5065cb3b93..e310af8e32 100644 --- a/src/handlers/gestureHandlerTypesCompat.ts +++ b/src/handlers/gestureHandlerTypesCompat.ts @@ -10,38 +10,24 @@ import { HandlerStateChangeEvent, HandlerStateChangeEventPayload, } from './gestureHandlerCommon'; +import { FlingGestureHandlerProps } from './FlingGestureHandler'; import { FlingGestureHandlerEventPayload, - FlingGestureHandlerProps, -} from './FlingGestureHandler'; -import { ForceTouchGestureHandlerEventPayload, - ForceTouchGestureHandlerProps, -} from './ForceTouchGestureHandler'; -import { LongPressGestureHandlerEventPayload, - LongPressGestureHandlerProps, -} from './LongPressGestureHandler'; -import { PanGestureHandlerEventPayload, - PanGestureHandlerProps, -} from './PanGestureHandler'; -import { PinchGestureHandlerEventPayload, - PinchGestureHandlerProps, -} from './PinchGestureHandler'; -import { RotationGestureHandlerEventPayload, - RotationGestureHandlerProps, -} from './RotationGestureHandler'; -import { TapGestureHandlerEventPayload, - TapGestureHandlerProps, -} from './TapGestureHandler'; -import { NativeViewGestureHandlerPayload, - NativeViewGestureHandlerProps, -} from './NativeViewGestureHandler'; +} from './GestureHandlerEventPayload'; +import { ForceTouchGestureHandlerProps } from './ForceTouchGestureHandler'; +import { LongPressGestureHandlerProps } from './LongPressGestureHandler'; +import { PanGestureHandlerProps } from './PanGestureHandler'; +import { PinchGestureHandlerProps } from './PinchGestureHandler'; +import { RotationGestureHandlerProps } from './RotationGestureHandler'; +import { TapGestureHandlerProps } from './TapGestureHandler'; +import { NativeViewGestureHandlerProps } from './NativeViewGestureHandler'; // events export type GestureHandlerGestureEventNativeEvent = GestureEventPayload; diff --git a/src/handlers/gestures/flingGesture.ts b/src/handlers/gestures/flingGesture.ts index 861b8fe565..ed2318c6e6 100644 --- a/src/handlers/gestures/flingGesture.ts +++ b/src/handlers/gestures/flingGesture.ts @@ -1,8 +1,6 @@ import { BaseGesture, BaseGestureConfig } from './gesture'; -import { - FlingGestureConfig, - FlingGestureHandlerEventPayload, -} from '../FlingGestureHandler'; +import { FlingGestureConfig } from '../FlingGestureHandler'; +import { FlingGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class FlingGesture extends BaseGesture { public config: BaseGestureConfig & FlingGestureConfig = {}; diff --git a/src/handlers/gestures/forceTouchGesture.ts b/src/handlers/gestures/forceTouchGesture.ts index cb75c9ae6c..45168e3e1f 100644 --- a/src/handlers/gestures/forceTouchGesture.ts +++ b/src/handlers/gestures/forceTouchGesture.ts @@ -1,8 +1,6 @@ import { BaseGestureConfig, ContinousBaseGesture } from './gesture'; -import { - ForceTouchGestureConfig, - ForceTouchGestureHandlerEventPayload, -} from '../ForceTouchGestureHandler'; +import { ForceTouchGestureConfig } from '../ForceTouchGestureHandler'; +import { ForceTouchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; import { GestureUpdateEvent } from '../gestureHandlerCommon'; export type ForceTouchGestureChangeEventPayload = { diff --git a/src/handlers/gestures/gesture.ts b/src/handlers/gestures/gesture.ts index c007ea15d7..26b4bdfff0 100644 --- a/src/handlers/gestures/gesture.ts +++ b/src/handlers/gestures/gesture.ts @@ -1,5 +1,3 @@ -import { FlingGestureHandlerEventPayload } from '../FlingGestureHandler'; -import { ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler'; import { HitSlop, CommonGestureConfig, @@ -11,12 +9,16 @@ import { } from '../gestureHandlerCommon'; import { getNextHandlerTag } from '../handlersRegistry'; import { GestureStateManagerType } from './gestureStateManager'; -import { LongPressGestureHandlerEventPayload } from '../LongPressGestureHandler'; -import { PanGestureHandlerEventPayload } from '../PanGestureHandler'; -import { PinchGestureHandlerEventPayload } from '../PinchGestureHandler'; -import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler'; -import { TapGestureHandlerEventPayload } from '../TapGestureHandler'; -import { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler'; +import { + FlingGestureHandlerEventPayload, + ForceTouchGestureHandlerEventPayload, + LongPressGestureHandlerEventPayload, + PanGestureHandlerEventPayload, + PinchGestureHandlerEventPayload, + RotationGestureHandlerEventPayload, + TapGestureHandlerEventPayload, + NativeViewGestureHandlerPayload, +} from '../GestureHandlerEventPayload'; import { isRemoteDebuggingEnabled } from '../../utils'; export type GestureType = @@ -97,7 +99,7 @@ export const CALLBACK_TYPE = { // Allow using CALLBACK_TYPE as object and type // eslint-disable-next-line @typescript-eslint/no-redeclare -export type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE]; +export type CALLBACK_TYPE = (typeof CALLBACK_TYPE)[keyof typeof CALLBACK_TYPE]; export abstract class Gesture { /** diff --git a/src/handlers/gestures/longPressGesture.ts b/src/handlers/gestures/longPressGesture.ts index 808c7d417c..f35c733d92 100644 --- a/src/handlers/gestures/longPressGesture.ts +++ b/src/handlers/gestures/longPressGesture.ts @@ -1,8 +1,6 @@ import { BaseGesture, BaseGestureConfig } from './gesture'; -import { - LongPressGestureConfig, - LongPressGestureHandlerEventPayload, -} from '../LongPressGestureHandler'; +import { LongPressGestureConfig } from '../LongPressGestureHandler'; +import { LongPressGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class LongPressGesture extends BaseGesture { public config: BaseGestureConfig & LongPressGestureConfig = {}; diff --git a/src/handlers/gestures/nativeGesture.ts b/src/handlers/gestures/nativeGesture.ts index 84c9de9b33..6545585e2f 100644 --- a/src/handlers/gestures/nativeGesture.ts +++ b/src/handlers/gestures/nativeGesture.ts @@ -1,8 +1,6 @@ import { BaseGestureConfig, BaseGesture } from './gesture'; -import { - NativeViewGestureConfig, - NativeViewGestureHandlerPayload, -} from '../NativeViewGestureHandler'; +import { NativeViewGestureConfig } from '../NativeViewGestureHandler'; +import { NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload'; export class NativeGesture extends BaseGesture { public config: BaseGestureConfig & NativeViewGestureConfig = {}; diff --git a/src/handlers/gestures/panGesture.ts b/src/handlers/gestures/panGesture.ts index 5149ed5d19..7100c15277 100644 --- a/src/handlers/gestures/panGesture.ts +++ b/src/handlers/gestures/panGesture.ts @@ -1,9 +1,7 @@ import { BaseGestureConfig, ContinousBaseGesture } from './gesture'; import { GestureUpdateEvent } from '../gestureHandlerCommon'; -import { - PanGestureConfig, - PanGestureHandlerEventPayload, -} from '../PanGestureHandler'; +import { PanGestureConfig } from '../PanGestureHandler'; +import { PanGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export type PanGestureChangeEventPayload = { changeX: number; diff --git a/src/handlers/gestures/pinchGesture.ts b/src/handlers/gestures/pinchGesture.ts index 69416bd313..23b49c0297 100644 --- a/src/handlers/gestures/pinchGesture.ts +++ b/src/handlers/gestures/pinchGesture.ts @@ -1,5 +1,5 @@ import { ContinousBaseGesture } from './gesture'; -import { PinchGestureHandlerEventPayload } from '../PinchGestureHandler'; +import { PinchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; import { GestureUpdateEvent } from '../gestureHandlerCommon'; export type PinchGestureChangeEventPayload = { diff --git a/src/handlers/gestures/rotationGesture.ts b/src/handlers/gestures/rotationGesture.ts index 7bac78558e..1c3ea4d80f 100644 --- a/src/handlers/gestures/rotationGesture.ts +++ b/src/handlers/gestures/rotationGesture.ts @@ -1,5 +1,5 @@ import { ContinousBaseGesture } from './gesture'; -import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler'; +import { RotationGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; import { GestureUpdateEvent } from '../gestureHandlerCommon'; type RotationGestureChangeEventPayload = { diff --git a/src/handlers/gestures/tapGesture.ts b/src/handlers/gestures/tapGesture.ts index e592d4b22f..6951e82507 100644 --- a/src/handlers/gestures/tapGesture.ts +++ b/src/handlers/gestures/tapGesture.ts @@ -1,8 +1,6 @@ import { BaseGestureConfig, BaseGesture } from './gesture'; -import { - TapGestureConfig, - TapGestureHandlerEventPayload, -} from '../TapGestureHandler'; +import { TapGestureConfig } from '../TapGestureHandler'; +import { TapGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class TapGesture extends BaseGesture { public config: BaseGestureConfig & TapGestureConfig = {}; diff --git a/src/index.ts b/src/index.ts index 3c21bbe01c..67a046812d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,35 +23,24 @@ export { MouseButton } from './handlers/gestureHandlerCommon'; export type { GestureType } from './handlers/gestures/gesture'; export type { TapGestureHandlerEventPayload, - TapGestureHandlerProps, -} from './handlers/TapGestureHandler'; -export type { ForceTouchGestureHandlerEventPayload, - ForceTouchGestureHandlerProps, -} from './handlers/ForceTouchGestureHandler'; -export type { ForceTouchGestureChangeEventPayload } from './handlers/gestures/forceTouchGesture'; -export type { LongPressGestureHandlerEventPayload, - LongPressGestureHandlerProps, -} from './handlers/LongPressGestureHandler'; -export type { PanGestureHandlerEventPayload, - PanGestureHandlerProps, -} from './handlers/PanGestureHandler'; -export type { PanGestureChangeEventPayload } from './handlers/gestures/panGesture'; -export type { PinchGestureHandlerEventPayload, - PinchGestureHandlerProps, -} from './handlers/PinchGestureHandler'; -export type { PinchGestureChangeEventPayload } from './handlers/gestures/pinchGesture'; -export type { RotationGestureHandlerEventPayload, - RotationGestureHandlerProps, -} from './handlers/RotationGestureHandler'; -export type { + NativeViewGestureHandlerPayload, FlingGestureHandlerEventPayload, - FlingGestureHandlerProps, -} from './handlers/FlingGestureHandler'; +} from './handlers/GestureHandlerEventPayload'; +export type { TapGestureHandlerProps } from './handlers/TapGestureHandler'; +export type { ForceTouchGestureHandlerProps } from './handlers/ForceTouchGestureHandler'; +export type { ForceTouchGestureChangeEventPayload } from './handlers/gestures/forceTouchGesture'; +export type { LongPressGestureHandlerProps } from './handlers/LongPressGestureHandler'; +export type { PanGestureHandlerProps } from './handlers/PanGestureHandler'; +export type { PanGestureChangeEventPayload } from './handlers/gestures/panGesture'; +export type { PinchGestureHandlerProps } from './handlers/PinchGestureHandler'; +export type { PinchGestureChangeEventPayload } from './handlers/gestures/pinchGesture'; +export type { RotationGestureHandlerProps } from './handlers/RotationGestureHandler'; +export type { FlingGestureHandlerProps } from './handlers/FlingGestureHandler'; export { TapGestureHandler } from './handlers/TapGestureHandler'; export { ForceTouchGestureHandler } from './handlers/ForceTouchGestureHandler'; export { LongPressGestureHandler } from './handlers/LongPressGestureHandler'; @@ -60,10 +49,7 @@ export { PinchGestureHandler } from './handlers/PinchGestureHandler'; export { RotationGestureHandler } from './handlers/RotationGestureHandler'; export { FlingGestureHandler } from './handlers/FlingGestureHandler'; export { default as createNativeWrapper } from './handlers/createNativeWrapper'; -export type { - NativeViewGestureHandlerPayload, - NativeViewGestureHandlerProps, -} from './handlers/NativeViewGestureHandler'; +export type { NativeViewGestureHandlerProps } from './handlers/NativeViewGestureHandler'; export { GestureDetector } from './handlers/gestures/GestureDetector'; export { GestureObjects as Gesture } from './handlers/gestures/gestureObjects'; export type { TapGestureType as TapGesture } from './handlers/gestures/tapGesture'; diff --git a/src/jestUtils/jestUtils.ts b/src/jestUtils/jestUtils.ts index 4e7c54d407..a91a2a33f1 100644 --- a/src/jestUtils/jestUtils.ts +++ b/src/jestUtils/jestUtils.ts @@ -3,12 +3,10 @@ import { DeviceEventEmitter } from 'react-native'; import { ReactTestInstance } from 'react-test-renderer'; import { FlingGestureHandler, - FlingGestureHandlerEventPayload, flingHandlerName, } from '../handlers/FlingGestureHandler'; import { ForceTouchGestureHandler, - ForceTouchGestureHandlerEventPayload, forceTouchHandlerName, } from '../handlers/ForceTouchGestureHandler'; import { @@ -28,32 +26,36 @@ import { TapGesture } from '../handlers/gestures/tapGesture'; import { findHandlerByTestID } from '../handlers/handlersRegistry'; import { LongPressGestureHandler, - LongPressGestureHandlerEventPayload, longPressHandlerName, } from '../handlers/LongPressGestureHandler'; import { - NativeViewGestureHandler, + FlingGestureHandlerEventPayload, + ForceTouchGestureHandlerEventPayload, + LongPressGestureHandlerEventPayload, NativeViewGestureHandlerPayload, + PanGestureHandlerEventPayload, + PinchGestureHandlerEventPayload, + RotationGestureHandlerEventPayload, + TapGestureHandlerEventPayload, +} from 'src/handlers/GestureHandlerEventPayload'; +import { + NativeViewGestureHandler, nativeViewHandlerName, } from '../handlers/NativeViewGestureHandler'; import { PanGestureHandler, - PanGestureHandlerEventPayload, panHandlerName, } from '../handlers/PanGestureHandler'; import { PinchGestureHandler, - PinchGestureHandlerEventPayload, pinchHandlerName, } from '../handlers/PinchGestureHandler'; import { RotationGestureHandler, - RotationGestureHandlerEventPayload, rotationHandlerName, } from '../handlers/RotationGestureHandler'; import { TapGestureHandler, - TapGestureHandlerEventPayload, tapHandlerName, } from '../handlers/TapGestureHandler'; import { State } from '../State'; From b5f7b2d8fba437b78d2ef177875d8699126f85c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 09:57:50 +0200 Subject: [PATCH 03/21] resolve button props circ deps --- src/components/GestureButtons.tsx | 126 ++-------------------- src/components/GestureButtonsProps.tsx | 110 +++++++++++++++++++ src/components/GestureHandlerButton.tsx | 2 +- src/handlers/gestureHandlerTypesCompat.ts | 2 +- src/index.ts | 2 +- 5 files changed, 122 insertions(+), 120 deletions(-) create mode 100644 src/components/GestureButtonsProps.tsx diff --git a/src/components/GestureButtons.tsx b/src/components/GestureButtons.tsx index 095c3fcdec..377ddb191d 100644 --- a/src/components/GestureButtons.tsx +++ b/src/components/GestureButtons.tsx @@ -1,12 +1,5 @@ import * as React from 'react'; -import { - Animated, - Platform, - processColor, - StyleSheet, - StyleProp, - ViewStyle, -} from 'react-native'; +import { Animated, Platform, processColor, StyleSheet } from 'react-native'; import createNativeWrapper from '../handlers/createNativeWrapper'; import GestureHandlerButton from './GestureHandlerButton'; @@ -16,116 +9,15 @@ import { GestureEvent, HandlerStateChangeEvent, } from '../handlers/gestureHandlerCommon'; -import { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; import { NativeViewGestureHandlerPayload } from 'src/handlers/GestureHandlerEventPayload'; - -export interface RawButtonProps extends NativeViewGestureHandlerProps { - /** - * Defines if more than one button could be pressed simultaneously. By default - * set true. - */ - exclusive?: boolean; - // TODO: we should transform props in `createNativeWrapper` - - /** - * Android only. - * - * Defines color of native ripple animation used since API level 21. - */ - rippleColor?: any; // it was present in BaseButtonProps before but is used here in code - - /** - * Android only. - * - * Defines radius of native ripple animation used since API level 21. - */ - rippleRadius?: number | null; - - /** - * Android only. - * - * Set this to true if you want the ripple animation to render outside the view bounds. - */ - borderless?: boolean; - - /** - * Android only. - * - * Defines whether the ripple animation should be drawn on the foreground of the view. - */ - foreground?: boolean; - - /** - * Android only. - * - * Set this to true if you don't want the system to play sound when the button is pressed. - */ - touchSoundDisabled?: boolean; -} - -interface ButtonWithRefProps { - innerRef?: React.ForwardedRef>; -} - -export interface BaseButtonProps extends RawButtonProps { - /** - * Called when the button gets pressed (analogous to `onPress` in - * `TouchableHighlight` from RN core). - */ - onPress?: (pointerInside: boolean) => void; - - /** - * Called when the button gets pressed and is held for `delayLongPress` - * milliseconds. - */ - onLongPress?: () => void; - - /** - * Called when button changes from inactive to active and vice versa. It - * passes active state as a boolean variable as a first parameter for that - * method. - */ - onActiveStateChange?: (active: boolean) => void; - style?: StyleProp; - testID?: string; - - /** - * Delay, in milliseconds, after which the `onLongPress` callback gets called. - * Defaults to 600. - */ - delayLongPress?: number; -} - -interface BaseButtonWithRefProps extends BaseButtonProps, ButtonWithRefProps {} - -export interface RectButtonProps extends BaseButtonProps { - /** - * Background color that will be dimmed when button is in active state. - */ - underlayColor?: string; - - /** - * iOS only. - * - * Opacity applied to the underlay when button is in active state. - */ - activeOpacity?: number; -} - -interface RectButtonWithRefProps extends RectButtonProps, ButtonWithRefProps {} - -export interface BorderlessButtonProps extends BaseButtonProps { - /** - * iOS only. - * - * Opacity applied to the button when it is in an active state. - */ - activeOpacity?: number; -} - -interface BorderlessButtonWithRefProps - extends BorderlessButtonProps, - ButtonWithRefProps {} +import { + BaseButtonWithRefProps, + BaseButtonProps, + RectButtonWithRefProps, + RectButtonProps, + BorderlessButtonWithRefProps, + BorderlessButtonProps, +} from './GestureButtonsProps'; export const RawButton = createNativeWrapper(GestureHandlerButton, { shouldCancelWhenOutside: false, diff --git a/src/components/GestureButtonsProps.tsx b/src/components/GestureButtonsProps.tsx new file mode 100644 index 0000000000..7f3265ed46 --- /dev/null +++ b/src/components/GestureButtonsProps.tsx @@ -0,0 +1,110 @@ +import * as React from 'react'; +import { StyleProp, ViewStyle } from 'react-native'; +import { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; + +export interface RawButtonProps extends NativeViewGestureHandlerProps { + /** + * Defines if more than one button could be pressed simultaneously. By default + * set true. + */ + exclusive?: boolean; + // TODO: we should transform props in `createNativeWrapper` + /** + * Android only. + * + * Defines color of native ripple animation used since API level 21. + */ + rippleColor?: any; // it was present in BaseButtonProps before but is used here in code + + /** + * Android only. + * + * Defines radius of native ripple animation used since API level 21. + */ + rippleRadius?: number | null; + + /** + * Android only. + * + * Set this to true if you want the ripple animation to render outside the view bounds. + */ + borderless?: boolean; + + /** + * Android only. + * + * Defines whether the ripple animation should be drawn on the foreground of the view. + */ + foreground?: boolean; + + /** + * Android only. + * + * Set this to true if you don't want the system to play sound when the button is pressed. + */ + touchSoundDisabled?: boolean; +} +interface ButtonWithRefProps { + innerRef?: React.ForwardedRef>; +} + +export interface BaseButtonProps extends RawButtonProps { + /** + * Called when the button gets pressed (analogous to `onPress` in + * `TouchableHighlight` from RN core). + */ + onPress?: (pointerInside: boolean) => void; + + /** + * Called when the button gets pressed and is held for `delayLongPress` + * milliseconds. + */ + onLongPress?: () => void; + + /** + * Called when button changes from inactive to active and vice versa. It + * passes active state as a boolean variable as a first parameter for that + * method. + */ + onActiveStateChange?: (active: boolean) => void; + style?: StyleProp; + testID?: string; + + /** + * Delay, in milliseconds, after which the `onLongPress` callback gets called. + * Defaults to 600. + */ + delayLongPress?: number; +} +export interface BaseButtonWithRefProps + extends BaseButtonProps, + ButtonWithRefProps {} + +export interface RectButtonProps extends BaseButtonProps { + /** + * Background color that will be dimmed when button is in active state. + */ + underlayColor?: string; + + /** + * iOS only. + * + * Opacity applied to the underlay when button is in active state. + */ + activeOpacity?: number; +} +export interface RectButtonWithRefProps + extends RectButtonProps, + ButtonWithRefProps {} + +export interface BorderlessButtonProps extends BaseButtonProps { + /** + * iOS only. + * + * Opacity applied to the button when it is in an active state. + */ + activeOpacity?: number; +} +export interface BorderlessButtonWithRefProps + extends BorderlessButtonProps, + ButtonWithRefProps {} diff --git a/src/components/GestureHandlerButton.tsx b/src/components/GestureHandlerButton.tsx index 1b85c23a30..a1b6a70297 100644 --- a/src/components/GestureHandlerButton.tsx +++ b/src/components/GestureHandlerButton.tsx @@ -1,5 +1,5 @@ import { HostComponent } from 'react-native'; -import { RawButtonProps } from './GestureButtons'; +import { RawButtonProps } from './GestureButtonsProps'; import RNGestureHandlerButtonNativeComponent from '../specs/RNGestureHandlerButtonNativeComponent'; export default RNGestureHandlerButtonNativeComponent as HostComponent; diff --git a/src/handlers/gestureHandlerTypesCompat.ts b/src/handlers/gestureHandlerTypesCompat.ts index e310af8e32..f8a30812bc 100644 --- a/src/handlers/gestureHandlerTypesCompat.ts +++ b/src/handlers/gestureHandlerTypesCompat.ts @@ -3,7 +3,7 @@ import { BorderlessButtonProps, RawButtonProps, RectButtonProps, -} from '../components/GestureButtons'; +} from 'src/components/GestureButtonsProps'; import { GestureEvent, GestureEventPayload, diff --git a/src/index.ts b/src/index.ts index 67a046812d..4a28df0673 100644 --- a/src/index.ts +++ b/src/index.ts @@ -75,7 +75,7 @@ export type { BaseButtonProps, RectButtonProps, BorderlessButtonProps, -} from './components/GestureButtons'; +} from './components/GestureButtonsProps'; export { RawButton, BaseButton, From 736ddef944315b8c688f85d23ca8062cc234c007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 11:37:57 +0200 Subject: [PATCH 04/21] resolve generic and native touchable circ deps --- .../touchables/GenericTouchable.tsx | 33 ++----------------- .../touchables/GenericTouchableProps.tsx | 26 +++++++++++++++ .../touchables/TouchableHighlight.tsx | 6 ++-- .../TouchableNativeFeedback.android.tsx | 22 ++++--------- .../TouchableNativeFeedbackProps.tsx | 12 +++++++ .../touchables/TouchableOpacity.tsx | 6 ++-- .../touchables/TouchableWithoutFeedback.tsx | 3 +- 7 files changed, 53 insertions(+), 55 deletions(-) create mode 100644 src/components/touchables/GenericTouchableProps.tsx create mode 100644 src/components/touchables/TouchableNativeFeedbackProps.tsx diff --git a/src/components/touchables/GenericTouchable.tsx b/src/components/touchables/GenericTouchable.tsx index f35ef8a32f..b35369d497 100644 --- a/src/components/touchables/GenericTouchable.tsx +++ b/src/components/touchables/GenericTouchable.tsx @@ -1,13 +1,6 @@ import * as React from 'react'; import { Component } from 'react'; -import { - Animated, - Platform, - StyleProp, - ViewStyle, - TouchableWithoutFeedbackProps, - Insets, -} from 'react-native'; +import { Animated, Platform } from 'react-native'; import { State } from '../../State'; import { BaseButton } from '../GestureButtons'; @@ -15,10 +8,10 @@ import { BaseButton } from '../GestureButtons'; import { GestureEvent, HandlerStateChangeEvent, - UserSelect, } from '../../handlers/gestureHandlerCommon'; import { NativeViewGestureHandlerPayload } from 'src/handlers/GestureHandlerEventPayload'; -import { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedback.android'; +import { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedbackProps'; +import { GenericTouchableProps } from './GenericTouchableProps'; /** * Each touchable is a states' machine which preforms transitions. @@ -35,26 +28,6 @@ export const TOUCHABLE_STATE = { type TouchableState = (typeof TOUCHABLE_STATE)[keyof typeof TOUCHABLE_STATE]; -export interface GenericTouchableProps - extends Omit { - // Decided to drop not used fields from RN's implementation. - // e.g. onBlur and onFocus as well as deprecated props. - TODO: this comment may be unuseful in this moment - - // TODO: in RN these events get native event parameter, which prolly could be used in our implementation too - onPress?: () => void; - onPressIn?: () => void; - onPressOut?: () => void; - onLongPress?: () => void; - - nativeID?: string; - shouldActivateOnStart?: boolean; - disallowInterruption?: boolean; - - containerStyle?: StyleProp; - hitSlop?: Insets | number; - userSelect?: UserSelect; -} - interface InternalProps { extraButtonProps: TouchableNativeFeedbackExtraProps; onStateChange?: (oldState: TouchableState, newState: TouchableState) => void; diff --git a/src/components/touchables/GenericTouchableProps.tsx b/src/components/touchables/GenericTouchableProps.tsx new file mode 100644 index 0000000000..81bfe1de21 --- /dev/null +++ b/src/components/touchables/GenericTouchableProps.tsx @@ -0,0 +1,26 @@ +import { + StyleProp, + ViewStyle, + TouchableWithoutFeedbackProps, + Insets, +} from 'react-native'; +import { UserSelect } from '../../handlers/gestureHandlerCommon'; + +export interface GenericTouchableProps + extends Omit { + // Decided to drop not used fields from RN's implementation. + // e.g. onBlur and onFocus as well as deprecated props. - TODO: this comment may be unuseful in this moment + // TODO: in RN these events get native event parameter, which prolly could be used in our implementation too + onPress?: () => void; + onPressIn?: () => void; + onPressOut?: () => void; + onLongPress?: () => void; + + nativeID?: string; + shouldActivateOnStart?: boolean; + disallowInterruption?: boolean; + + containerStyle?: StyleProp; + hitSlop?: Insets | number; + userSelect?: UserSelect; +} diff --git a/src/components/touchables/TouchableHighlight.tsx b/src/components/touchables/TouchableHighlight.tsx index 774a3885a5..9d16a2eb00 100644 --- a/src/components/touchables/TouchableHighlight.tsx +++ b/src/components/touchables/TouchableHighlight.tsx @@ -1,9 +1,7 @@ import * as React from 'react'; import { Component } from 'react'; -import GenericTouchable, { - GenericTouchableProps, - TOUCHABLE_STATE, -} from './GenericTouchable'; +import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; +import { GenericTouchableProps } from './GenericTouchableProps'; import { StyleSheet, View, diff --git a/src/components/touchables/TouchableNativeFeedback.android.tsx b/src/components/touchables/TouchableNativeFeedback.android.tsx index f96b453421..57d45882d7 100644 --- a/src/components/touchables/TouchableNativeFeedback.android.tsx +++ b/src/components/touchables/TouchableNativeFeedback.android.tsx @@ -1,21 +1,11 @@ -import { - Platform, - TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps, - ColorValue, -} from 'react-native'; +import { Platform, ColorValue } from 'react-native'; import * as React from 'react'; import { Component } from 'react'; -import GenericTouchable, { GenericTouchableProps } from './GenericTouchable'; - -export type TouchableNativeFeedbackExtraProps = { - borderless?: boolean; - rippleColor?: number | null; - rippleRadius?: number | null; - foreground?: boolean; -}; - -export type TouchableNativeFeedbackProps = RNTouchableNativeFeedbackProps & - GenericTouchableProps; +import GenericTouchable from './GenericTouchable'; +import { + TouchableNativeFeedbackProps, + TouchableNativeFeedbackExtraProps, +} from './TouchableNativeFeedbackProps'; /** * TouchableNativeFeedback behaves slightly different than RN's TouchableNativeFeedback. diff --git a/src/components/touchables/TouchableNativeFeedbackProps.tsx b/src/components/touchables/TouchableNativeFeedbackProps.tsx new file mode 100644 index 0000000000..a06d2e8ee3 --- /dev/null +++ b/src/components/touchables/TouchableNativeFeedbackProps.tsx @@ -0,0 +1,12 @@ +import { TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps } from 'react-native'; +import { GenericTouchableProps } from './GenericTouchableProps'; + +export type TouchableNativeFeedbackExtraProps = { + borderless?: boolean; + rippleColor?: number | null; + rippleRadius?: number | null; + foreground?: boolean; +}; + +export type TouchableNativeFeedbackProps = RNTouchableNativeFeedbackProps & + GenericTouchableProps; diff --git a/src/components/touchables/TouchableOpacity.tsx b/src/components/touchables/TouchableOpacity.tsx index 7c0f20cfae..e33808c84e 100644 --- a/src/components/touchables/TouchableOpacity.tsx +++ b/src/components/touchables/TouchableOpacity.tsx @@ -5,10 +5,8 @@ import { View, TouchableOpacityProps as RNTouchableOpacityProps, } from 'react-native'; -import GenericTouchable, { - TOUCHABLE_STATE, - GenericTouchableProps, -} from './GenericTouchable'; +import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; +import { GenericTouchableProps } from './GenericTouchableProps'; import * as React from 'react'; import { Component } from 'react'; diff --git a/src/components/touchables/TouchableWithoutFeedback.tsx b/src/components/touchables/TouchableWithoutFeedback.tsx index 577e568a8a..42e1bc1ae0 100644 --- a/src/components/touchables/TouchableWithoutFeedback.tsx +++ b/src/components/touchables/TouchableWithoutFeedback.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { PropsWithChildren } from 'react'; -import GenericTouchable, { GenericTouchableProps } from './GenericTouchable'; +import GenericTouchable from './GenericTouchable'; +import { GenericTouchableProps } from './GenericTouchableProps'; export type TouchableWithoutFeedbackProps = GenericTouchableProps; From 188622dac25f0d1e160eff64ad5d5ab74e90c6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 12:00:33 +0200 Subject: [PATCH 05/21] fix handler registry circ dep --- src/handlers/createHandler.tsx | 7 ++----- src/handlers/gestures/gesture.ts | 2 +- src/handlers/handlerTag.ts | 5 +++++ src/handlers/handlersRegistry.ts | 6 ------ 4 files changed, 8 insertions(+), 12 deletions(-) create mode 100644 src/handlers/handlerTag.ts diff --git a/src/handlers/createHandler.tsx b/src/handlers/createHandler.tsx index 0b963546de..7d112d8c45 100644 --- a/src/handlers/createHandler.tsx +++ b/src/handlers/createHandler.tsx @@ -8,11 +8,8 @@ import { import { customDirectEventTypes } from './customDirectEventTypes'; import RNGestureHandlerModule from '../RNGestureHandlerModule'; import { State } from '../State'; -import { - handlerIDToTag, - getNextHandlerTag, - registerOldGestureHandler, -} from './handlersRegistry'; +import { handlerIDToTag, registerOldGestureHandler } from './handlersRegistry'; +import { getNextHandlerTag } from './handlerTag'; import { BaseGestureHandlerProps, diff --git a/src/handlers/gestures/gesture.ts b/src/handlers/gestures/gesture.ts index 26b4bdfff0..e7db513ba5 100644 --- a/src/handlers/gestures/gesture.ts +++ b/src/handlers/gestures/gesture.ts @@ -7,7 +7,7 @@ import { ActiveCursor, MouseButton, } from '../gestureHandlerCommon'; -import { getNextHandlerTag } from '../handlersRegistry'; +import { getNextHandlerTag } from '../handlerTag'; import { GestureStateManagerType } from './gestureStateManager'; import { FlingGestureHandlerEventPayload, diff --git a/src/handlers/handlerTag.ts b/src/handlers/handlerTag.ts new file mode 100644 index 0000000000..9820900190 --- /dev/null +++ b/src/handlers/handlerTag.ts @@ -0,0 +1,5 @@ +let handlerTag = 1; + +export function getNextHandlerTag(): number { + return handlerTag++; +} diff --git a/src/handlers/handlersRegistry.ts b/src/handlers/handlersRegistry.ts index 87f13fda50..3a19447edf 100644 --- a/src/handlers/handlersRegistry.ts +++ b/src/handlers/handlersRegistry.ts @@ -7,12 +7,6 @@ const gestures = new Map(); const oldHandlers = new Map(); const testIDs = new Map(); -let handlerTag = 1; - -export function getNextHandlerTag(): number { - return handlerTag++; -} - export function registerHandler( handlerTag: number, handler: GestureType, From b65d4781e702debc664ea45d3401e5f2a3578114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 12:13:27 +0200 Subject: [PATCH 06/21] fix invalid autolinter suggestion --- src/components/touchables/GenericTouchable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/touchables/GenericTouchable.tsx b/src/components/touchables/GenericTouchable.tsx index b35369d497..65fb9cd732 100644 --- a/src/components/touchables/GenericTouchable.tsx +++ b/src/components/touchables/GenericTouchable.tsx @@ -26,7 +26,7 @@ export const TOUCHABLE_STATE = { MOVED_OUTSIDE: 2, } as const; -type TouchableState = (typeof TOUCHABLE_STATE)[keyof typeof TOUCHABLE_STATE]; +type TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE]; interface InternalProps { extraButtonProps: TouchableNativeFeedbackExtraProps; From ce2c30a4cfcfd2ad2f968ecacb0d7ab2003c46e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 12:13:27 +0200 Subject: [PATCH 07/21] fix invalid autolinter suggestion --- src/components/touchables/GenericTouchable.tsx | 2 +- src/handlers/gestures/gesture.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/touchables/GenericTouchable.tsx b/src/components/touchables/GenericTouchable.tsx index b35369d497..65fb9cd732 100644 --- a/src/components/touchables/GenericTouchable.tsx +++ b/src/components/touchables/GenericTouchable.tsx @@ -26,7 +26,7 @@ export const TOUCHABLE_STATE = { MOVED_OUTSIDE: 2, } as const; -type TouchableState = (typeof TOUCHABLE_STATE)[keyof typeof TOUCHABLE_STATE]; +type TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE]; interface InternalProps { extraButtonProps: TouchableNativeFeedbackExtraProps; diff --git a/src/handlers/gestures/gesture.ts b/src/handlers/gestures/gesture.ts index e7db513ba5..7ea7210be3 100644 --- a/src/handlers/gestures/gesture.ts +++ b/src/handlers/gestures/gesture.ts @@ -99,7 +99,7 @@ export const CALLBACK_TYPE = { // Allow using CALLBACK_TYPE as object and type // eslint-disable-next-line @typescript-eslint/no-redeclare -export type CALLBACK_TYPE = (typeof CALLBACK_TYPE)[keyof typeof CALLBACK_TYPE]; +export type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE]; export abstract class Gesture { /** From 129258b5ff74465f5bad9d51c27d6e4de5884fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 14:15:23 +0200 Subject: [PATCH 08/21] fix invalid package imports --- src/components/DrawerLayout.tsx | 2 +- src/components/GestureButtons.tsx | 2 +- src/components/ReanimatedSwipeable.tsx | 2 +- src/components/Swipeable.tsx | 2 +- src/components/touchables/GenericTouchable.tsx | 2 +- src/handlers/gestures/GestureDetector/attachHandlers.ts | 2 +- src/handlers/gestures/GestureDetector/dropHandlers.ts | 2 +- src/handlers/gestures/GestureDetector/updateHandlers.ts | 2 +- src/jestUtils/jestUtils.ts | 2 +- src/web/Gestures.ts | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/DrawerLayout.tsx b/src/components/DrawerLayout.tsx index e49c1c8df8..40245f1e56 100644 --- a/src/components/DrawerLayout.tsx +++ b/src/components/DrawerLayout.tsx @@ -34,7 +34,7 @@ import { PanGestureHandler } from '../handlers/PanGestureHandler'; import { PanGestureHandlerEventPayload, TapGestureHandlerEventPayload, -} from 'src/handlers/GestureHandlerEventPayload'; +} from '../handlers/GestureHandlerEventPayload'; import { TapGestureHandler } from '../handlers/TapGestureHandler'; import { State } from '../State'; diff --git a/src/components/GestureButtons.tsx b/src/components/GestureButtons.tsx index 377ddb191d..79ede81070 100644 --- a/src/components/GestureButtons.tsx +++ b/src/components/GestureButtons.tsx @@ -9,7 +9,7 @@ import { GestureEvent, HandlerStateChangeEvent, } from '../handlers/gestureHandlerCommon'; -import { NativeViewGestureHandlerPayload } from 'src/handlers/GestureHandlerEventPayload'; +import { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload'; import { BaseButtonWithRefProps, BaseButtonProps, diff --git a/src/components/ReanimatedSwipeable.tsx b/src/components/ReanimatedSwipeable.tsx index 1ac8b9c4d9..96b6d7e02f 100644 --- a/src/components/ReanimatedSwipeable.tsx +++ b/src/components/ReanimatedSwipeable.tsx @@ -16,7 +16,7 @@ import { GestureUpdateEvent, } from '../handlers/gestureHandlerCommon'; import { PanGestureHandlerProps } from '../handlers/PanGestureHandler'; -import { PanGestureHandlerEventPayload } from 'src/handlers/GestureHandlerEventPayload'; +import { PanGestureHandlerEventPayload } from '../handlers/GestureHandlerEventPayload'; import Animated, { Extrapolation, SharedValue, diff --git a/src/components/Swipeable.tsx b/src/components/Swipeable.tsx index cdffb7c76c..e3ce909e8b 100644 --- a/src/components/Swipeable.tsx +++ b/src/components/Swipeable.tsx @@ -25,7 +25,7 @@ import { import { PanGestureHandlerEventPayload, TapGestureHandlerEventPayload, -} from 'src/handlers/GestureHandlerEventPayload'; +} from '../handlers/GestureHandlerEventPayload'; import { TapGestureHandler } from '../handlers/TapGestureHandler'; import { State } from '../State'; diff --git a/src/components/touchables/GenericTouchable.tsx b/src/components/touchables/GenericTouchable.tsx index 65fb9cd732..6ed79314bf 100644 --- a/src/components/touchables/GenericTouchable.tsx +++ b/src/components/touchables/GenericTouchable.tsx @@ -9,7 +9,7 @@ import { GestureEvent, HandlerStateChangeEvent, } from '../../handlers/gestureHandlerCommon'; -import { NativeViewGestureHandlerPayload } from 'src/handlers/GestureHandlerEventPayload'; +import { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload'; import { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedbackProps'; import { GenericTouchableProps } from './GenericTouchableProps'; diff --git a/src/handlers/gestures/GestureDetector/attachHandlers.ts b/src/handlers/gestures/GestureDetector/attachHandlers.ts index cfee3947fe..8645af3d14 100644 --- a/src/handlers/gestures/GestureDetector/attachHandlers.ts +++ b/src/handlers/gestures/GestureDetector/attachHandlers.ts @@ -5,7 +5,7 @@ import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; import { filterConfig, scheduleFlushOperations, -} from 'src/handlers/gestureCommonUtils'; +} from '../../gestureCommonUtils'; import { ComposedGesture } from '../gestureComposition'; import { ActionType } from '../../../ActionType'; import { Platform } from 'react-native'; diff --git a/src/handlers/gestures/GestureDetector/dropHandlers.ts b/src/handlers/gestures/GestureDetector/dropHandlers.ts index 5cbbe04676..8695e40957 100644 --- a/src/handlers/gestures/GestureDetector/dropHandlers.ts +++ b/src/handlers/gestures/GestureDetector/dropHandlers.ts @@ -1,6 +1,6 @@ import { unregisterHandler } from '../../handlersRegistry'; import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; -import { scheduleFlushOperations } from 'src/handlers/gestureCommonUtils'; +import { scheduleFlushOperations } from '../../gestureCommonUtils'; import { AttachedGestureState } from './types'; export function dropHandlers(preparedGesture: AttachedGestureState) { diff --git a/src/handlers/gestures/GestureDetector/updateHandlers.ts b/src/handlers/gestures/GestureDetector/updateHandlers.ts index e797b4f87e..d5c3c28bb9 100644 --- a/src/handlers/gestures/GestureDetector/updateHandlers.ts +++ b/src/handlers/gestures/GestureDetector/updateHandlers.ts @@ -4,7 +4,7 @@ import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; import { filterConfig, scheduleFlushOperations, -} from 'src/handlers/gestureCommonUtils'; +} from '../../gestureCommonUtils'; import { ComposedGesture } from '../gestureComposition'; import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; import { AttachedGestureState } from './types'; diff --git a/src/jestUtils/jestUtils.ts b/src/jestUtils/jestUtils.ts index a91a2a33f1..679ea99d8c 100644 --- a/src/jestUtils/jestUtils.ts +++ b/src/jestUtils/jestUtils.ts @@ -37,7 +37,7 @@ import { PinchGestureHandlerEventPayload, RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, -} from 'src/handlers/GestureHandlerEventPayload'; +} from '../handlers/GestureHandlerEventPayload'; import { NativeViewGestureHandler, nativeViewHandlerName, diff --git a/src/web/Gestures.ts b/src/web/Gestures.ts index c939a210b0..279b1152d1 100644 --- a/src/web/Gestures.ts +++ b/src/web/Gestures.ts @@ -9,7 +9,7 @@ import NativeViewGestureHandler from './handlers/NativeViewGestureHandler'; import ManualGestureHandler from './handlers/ManualGestureHandler'; import HoverGestureHandler from './handlers/HoverGestureHandler'; -//Hammer Handlers +// Hammer Handlers import HammerNativeViewGestureHandler from '../web_hammer/NativeViewGestureHandler'; import HammerPanGestureHandler from '../web_hammer/PanGestureHandler'; import HammerTapGestureHandler from '../web_hammer/TapGestureHandler'; From ccd6e5915b454c5dd797b5035f596f5842fe422d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 14:20:50 +0200 Subject: [PATCH 09/21] fix missed invalid import --- src/handlers/gestureHandlerTypesCompat.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/gestureHandlerTypesCompat.ts b/src/handlers/gestureHandlerTypesCompat.ts index f8a30812bc..469789f096 100644 --- a/src/handlers/gestureHandlerTypesCompat.ts +++ b/src/handlers/gestureHandlerTypesCompat.ts @@ -3,7 +3,7 @@ import { BorderlessButtonProps, RawButtonProps, RectButtonProps, -} from 'src/components/GestureButtonsProps'; +} from '../components/GestureButtonsProps'; import { GestureEvent, GestureEventPayload, From fafec8f319e0c2704b5c7ebf349690192d2de8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 15:03:27 +0200 Subject: [PATCH 10/21] resolve last hammer circ dep --- src/RNGestureHandlerModule.web.ts | 5 +-- src/web_hammer/NodeManager.ts | 31 +------------------ .../modifyGestureHandlerRegistry.ts | 26 ++++++++++++++++ 3 files changed, 30 insertions(+), 32 deletions(-) create mode 100644 src/web_hammer/modifyGestureHandlerRegistry.ts diff --git a/src/RNGestureHandlerModule.web.ts b/src/RNGestureHandlerModule.web.ts index bdf885f988..158ba162a2 100644 --- a/src/RNGestureHandlerModule.web.ts +++ b/src/RNGestureHandlerModule.web.ts @@ -7,6 +7,7 @@ import type { Config } from './web/interfaces'; import InteractionManager from './web/tools/InteractionManager'; import NodeManager from './web/tools/NodeManager'; import * as HammerNodeManager from './web_hammer/NodeManager'; +import * as createGestureHandler from './web_hammer/modifyGestureHandlerRegistry'; import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate'; export default { @@ -48,7 +49,7 @@ export default { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const GestureClass = HammerGestures[handlerName]; // eslint-disable-next-line @typescript-eslint/no-unsafe-call - HammerNodeManager.createGestureHandler(handlerTag, new GestureClass()); + createGestureHandler.createGestureHandler(handlerTag, new GestureClass()); } this.updateGestureHandler(handlerTag, config as unknown as Config); @@ -97,7 +98,7 @@ export default { if (isNewWebImplementationEnabled()) { NodeManager.dropGestureHandler(handlerTag); } else { - HammerNodeManager.dropGestureHandler(handlerTag); + createGestureHandler.dropGestureHandler(handlerTag); } }, // eslint-disable-next-line @typescript-eslint/no-empty-function diff --git a/src/web_hammer/NodeManager.ts b/src/web_hammer/NodeManager.ts index 664d874938..1dce3c3e29 100644 --- a/src/web_hammer/NodeManager.ts +++ b/src/web_hammer/NodeManager.ts @@ -1,10 +1,4 @@ -import { ValueOf } from '../typeUtils'; -import { HammerGestures } from '../web/Gestures'; - -const gestures: Record< - number, - InstanceType> -> = {}; +export const gestures: Record = {}; export function getHandler(tag: number) { if (tag in gestures) { @@ -14,29 +8,6 @@ export function getHandler(tag: number) { throw new Error(`No handler for tag ${tag}`); } -export function createGestureHandler( - handlerTag: number, - handler: InstanceType> -) { - if (handlerTag in gestures) { - throw new Error(`Handler with tag ${handlerTag} already exists`); - } - gestures[handlerTag] = handler; - // @ts-ignore no types for web handlers yet - gestures[handlerTag].handlerTag = handlerTag; -} - -export function dropGestureHandler(handlerTag: number) { - // Since React 18, there are cases where componentWillUnmount gets called twice in a row - // so skip this if the tag was already removed. - if (!(handlerTag in gestures)) { - return; - } - getHandler(handlerTag).destroy(); - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete - delete gestures[handlerTag]; -} - export function getNodes() { return { ...gestures }; } diff --git a/src/web_hammer/modifyGestureHandlerRegistry.ts b/src/web_hammer/modifyGestureHandlerRegistry.ts new file mode 100644 index 0000000000..37d8455347 --- /dev/null +++ b/src/web_hammer/modifyGestureHandlerRegistry.ts @@ -0,0 +1,26 @@ +import { ValueOf } from '../typeUtils'; +import { HammerGestures } from '../web/Gestures'; +import { gestures, getHandler } from './NodeManager'; + +export function createGestureHandler( + handlerTag: number, + handler: InstanceType> +) { + if (handlerTag in gestures) { + throw new Error(`Handler with tag ${handlerTag} already exists`); + } + gestures[handlerTag] = handler; + // @ts-ignore no types for web handlers yet + gestures[handlerTag].handlerTag = handlerTag; +} + +export function dropGestureHandler(handlerTag: number) { + // Since React 18, there are cases where componentWillUnmount gets called twice in a row + // so skip this if the tag was already removed. + if (!(handlerTag in gestures)) { + return; + } + getHandler(handlerTag).destroy(); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete gestures[handlerTag]; +} From 8ecf756978986cb57241c6b69567371f71e326cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Mon, 1 Jul 2024 17:48:07 +0200 Subject: [PATCH 11/21] roll back node manager split --- src/RNGestureHandlerModule.web.ts | 5 ++-- src/web_hammer/NodeManager.ts | 22 +++++++++++++++- .../modifyGestureHandlerRegistry.ts | 26 ------------------- 3 files changed, 23 insertions(+), 30 deletions(-) delete mode 100644 src/web_hammer/modifyGestureHandlerRegistry.ts diff --git a/src/RNGestureHandlerModule.web.ts b/src/RNGestureHandlerModule.web.ts index 158ba162a2..bdf885f988 100644 --- a/src/RNGestureHandlerModule.web.ts +++ b/src/RNGestureHandlerModule.web.ts @@ -7,7 +7,6 @@ import type { Config } from './web/interfaces'; import InteractionManager from './web/tools/InteractionManager'; import NodeManager from './web/tools/NodeManager'; import * as HammerNodeManager from './web_hammer/NodeManager'; -import * as createGestureHandler from './web_hammer/modifyGestureHandlerRegistry'; import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate'; export default { @@ -49,7 +48,7 @@ export default { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const GestureClass = HammerGestures[handlerName]; // eslint-disable-next-line @typescript-eslint/no-unsafe-call - createGestureHandler.createGestureHandler(handlerTag, new GestureClass()); + HammerNodeManager.createGestureHandler(handlerTag, new GestureClass()); } this.updateGestureHandler(handlerTag, config as unknown as Config); @@ -98,7 +97,7 @@ export default { if (isNewWebImplementationEnabled()) { NodeManager.dropGestureHandler(handlerTag); } else { - createGestureHandler.dropGestureHandler(handlerTag); + HammerNodeManager.dropGestureHandler(handlerTag); } }, // eslint-disable-next-line @typescript-eslint/no-empty-function diff --git a/src/web_hammer/NodeManager.ts b/src/web_hammer/NodeManager.ts index 1dce3c3e29..c912527323 100644 --- a/src/web_hammer/NodeManager.ts +++ b/src/web_hammer/NodeManager.ts @@ -1,4 +1,4 @@ -export const gestures: Record = {}; +const gestures: Record = {}; export function getHandler(tag: number) { if (tag in gestures) { @@ -8,6 +8,26 @@ export function getHandler(tag: number) { throw new Error(`No handler for tag ${tag}`); } +export function createGestureHandler(handlerTag: number, handler: any) { + if (handlerTag in gestures) { + throw new Error(`Handler with tag ${handlerTag} already exists`); + } + gestures[handlerTag] = handler; + // @ts-ignore no types for web handlers yet + gestures[handlerTag].handlerTag = handlerTag; +} + +export function dropGestureHandler(handlerTag: number) { + // Since React 18, there are cases where componentWillUnmount gets called twice in a row + // so skip this if the tag was already removed. + if (!(handlerTag in gestures)) { + return; + } + getHandler(handlerTag).destroy(); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete gestures[handlerTag]; +} + export function getNodes() { return { ...gestures }; } diff --git a/src/web_hammer/modifyGestureHandlerRegistry.ts b/src/web_hammer/modifyGestureHandlerRegistry.ts deleted file mode 100644 index 37d8455347..0000000000 --- a/src/web_hammer/modifyGestureHandlerRegistry.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ValueOf } from '../typeUtils'; -import { HammerGestures } from '../web/Gestures'; -import { gestures, getHandler } from './NodeManager'; - -export function createGestureHandler( - handlerTag: number, - handler: InstanceType> -) { - if (handlerTag in gestures) { - throw new Error(`Handler with tag ${handlerTag} already exists`); - } - gestures[handlerTag] = handler; - // @ts-ignore no types for web handlers yet - gestures[handlerTag].handlerTag = handlerTag; -} - -export function dropGestureHandler(handlerTag: number) { - // Since React 18, there are cases where componentWillUnmount gets called twice in a row - // so skip this if the tag was already removed. - if (!(handlerTag in gestures)) { - return; - } - getHandler(handlerTag).destroy(); - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete - delete gestures[handlerTag]; -} From 2e3d27150e03a617fa7f7dc7fe7001ca36f9f770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 09:24:24 +0200 Subject: [PATCH 12/21] change gestureButtonProps from tsx to ts --- .../{GestureButtonsProps.tsx => GestureButtonsProps.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/components/{GestureButtonsProps.tsx => GestureButtonsProps.ts} (100%) diff --git a/src/components/GestureButtonsProps.tsx b/src/components/GestureButtonsProps.ts similarity index 100% rename from src/components/GestureButtonsProps.tsx rename to src/components/GestureButtonsProps.ts From 58f8d3e225498d5ab872b445f741f99a9e790059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 09:25:35 +0200 Subject: [PATCH 13/21] optimize imports for prop files --- src/components/GestureButtons.tsx | 2 +- src/components/GestureHandlerButton.tsx | 2 +- src/components/touchables/GenericTouchable.tsx | 4 ++-- src/components/touchables/TouchableHighlight.tsx | 2 +- src/components/touchables/TouchableNativeFeedbackProps.tsx | 2 +- src/components/touchables/TouchableOpacity.tsx | 2 +- src/components/touchables/TouchableWithoutFeedback.tsx | 2 +- src/handlers/gestureHandlerTypesCompat.ts | 2 +- src/web_hammer/NodeManager.ts | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/GestureButtons.tsx b/src/components/GestureButtons.tsx index 79ede81070..2aae32875d 100644 --- a/src/components/GestureButtons.tsx +++ b/src/components/GestureButtons.tsx @@ -10,7 +10,7 @@ import { HandlerStateChangeEvent, } from '../handlers/gestureHandlerCommon'; import { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload'; -import { +import type { BaseButtonWithRefProps, BaseButtonProps, RectButtonWithRefProps, diff --git a/src/components/GestureHandlerButton.tsx b/src/components/GestureHandlerButton.tsx index a1b6a70297..b6f0c391c0 100644 --- a/src/components/GestureHandlerButton.tsx +++ b/src/components/GestureHandlerButton.tsx @@ -1,5 +1,5 @@ import { HostComponent } from 'react-native'; -import { RawButtonProps } from './GestureButtonsProps'; +import type { RawButtonProps } from './GestureButtonsProps'; import RNGestureHandlerButtonNativeComponent from '../specs/RNGestureHandlerButtonNativeComponent'; export default RNGestureHandlerButtonNativeComponent as HostComponent; diff --git a/src/components/touchables/GenericTouchable.tsx b/src/components/touchables/GenericTouchable.tsx index 6ed79314bf..94a1e6a007 100644 --- a/src/components/touchables/GenericTouchable.tsx +++ b/src/components/touchables/GenericTouchable.tsx @@ -10,8 +10,8 @@ import { HandlerStateChangeEvent, } from '../../handlers/gestureHandlerCommon'; import { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload'; -import { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedbackProps'; -import { GenericTouchableProps } from './GenericTouchableProps'; +import type { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedbackProps'; +import type { GenericTouchableProps } from './GenericTouchableProps'; /** * Each touchable is a states' machine which preforms transitions. diff --git a/src/components/touchables/TouchableHighlight.tsx b/src/components/touchables/TouchableHighlight.tsx index 9d16a2eb00..4222950646 100644 --- a/src/components/touchables/TouchableHighlight.tsx +++ b/src/components/touchables/TouchableHighlight.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { Component } from 'react'; import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; -import { GenericTouchableProps } from './GenericTouchableProps'; +import type { GenericTouchableProps } from './GenericTouchableProps'; import { StyleSheet, View, diff --git a/src/components/touchables/TouchableNativeFeedbackProps.tsx b/src/components/touchables/TouchableNativeFeedbackProps.tsx index a06d2e8ee3..457df4a14a 100644 --- a/src/components/touchables/TouchableNativeFeedbackProps.tsx +++ b/src/components/touchables/TouchableNativeFeedbackProps.tsx @@ -1,5 +1,5 @@ import { TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps } from 'react-native'; -import { GenericTouchableProps } from './GenericTouchableProps'; +import type { GenericTouchableProps } from './GenericTouchableProps'; export type TouchableNativeFeedbackExtraProps = { borderless?: boolean; diff --git a/src/components/touchables/TouchableOpacity.tsx b/src/components/touchables/TouchableOpacity.tsx index e33808c84e..f0d87338a1 100644 --- a/src/components/touchables/TouchableOpacity.tsx +++ b/src/components/touchables/TouchableOpacity.tsx @@ -6,7 +6,7 @@ import { TouchableOpacityProps as RNTouchableOpacityProps, } from 'react-native'; import GenericTouchable, { TOUCHABLE_STATE } from './GenericTouchable'; -import { GenericTouchableProps } from './GenericTouchableProps'; +import type { GenericTouchableProps } from './GenericTouchableProps'; import * as React from 'react'; import { Component } from 'react'; diff --git a/src/components/touchables/TouchableWithoutFeedback.tsx b/src/components/touchables/TouchableWithoutFeedback.tsx index 42e1bc1ae0..ddc2ad211d 100644 --- a/src/components/touchables/TouchableWithoutFeedback.tsx +++ b/src/components/touchables/TouchableWithoutFeedback.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { PropsWithChildren } from 'react'; import GenericTouchable from './GenericTouchable'; -import { GenericTouchableProps } from './GenericTouchableProps'; +import type { GenericTouchableProps } from './GenericTouchableProps'; export type TouchableWithoutFeedbackProps = GenericTouchableProps; diff --git a/src/handlers/gestureHandlerTypesCompat.ts b/src/handlers/gestureHandlerTypesCompat.ts index 469789f096..0dbecf6c1d 100644 --- a/src/handlers/gestureHandlerTypesCompat.ts +++ b/src/handlers/gestureHandlerTypesCompat.ts @@ -1,4 +1,4 @@ -import { +import type { BaseButtonProps, BorderlessButtonProps, RawButtonProps, diff --git a/src/web_hammer/NodeManager.ts b/src/web_hammer/NodeManager.ts index c912527323..f5ec70a43b 100644 --- a/src/web_hammer/NodeManager.ts +++ b/src/web_hammer/NodeManager.ts @@ -1,4 +1,4 @@ -const gestures: Record = {}; +export const gestures: Record = {}; export function getHandler(tag: number) { if (tag in gestures) { From 3221b968e02542468edf56ba62393d69432d7d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 09:30:11 +0200 Subject: [PATCH 14/21] optimize imports for type importing --- src/components/GestureButtons.tsx | 2 +- src/components/ReanimatedSwipeable.tsx | 2 +- src/components/touchables/GenericTouchable.tsx | 2 +- src/handlers/FlingGestureHandler.ts | 2 +- src/handlers/ForceTouchGestureHandler.ts | 2 +- src/handlers/PanGestureHandler.ts | 2 +- src/handlers/TapGestureHandler.ts | 2 +- src/handlers/gestureHandlerTypesCompat.ts | 4 ++-- src/handlers/gestures/flingGesture.ts | 2 +- src/handlers/gestures/forceTouchGesture.ts | 2 +- src/handlers/gestures/gesture.ts | 2 +- src/handlers/gestures/longPressGesture.ts | 2 +- src/handlers/gestures/nativeGesture.ts | 2 +- src/handlers/gestures/panGesture.ts | 2 +- src/handlers/gestures/pinchGesture.ts | 2 +- src/handlers/gestures/rotationGesture.ts | 2 +- src/handlers/gestures/tapGesture.ts | 2 +- src/jestUtils/jestUtils.ts | 2 +- 18 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/GestureButtons.tsx b/src/components/GestureButtons.tsx index 2aae32875d..875568e73d 100644 --- a/src/components/GestureButtons.tsx +++ b/src/components/GestureButtons.tsx @@ -9,7 +9,7 @@ import { GestureEvent, HandlerStateChangeEvent, } from '../handlers/gestureHandlerCommon'; -import { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload'; +import type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload'; import type { BaseButtonWithRefProps, BaseButtonProps, diff --git a/src/components/ReanimatedSwipeable.tsx b/src/components/ReanimatedSwipeable.tsx index 96b6d7e02f..75e8061422 100644 --- a/src/components/ReanimatedSwipeable.tsx +++ b/src/components/ReanimatedSwipeable.tsx @@ -16,7 +16,7 @@ import { GestureUpdateEvent, } from '../handlers/gestureHandlerCommon'; import { PanGestureHandlerProps } from '../handlers/PanGestureHandler'; -import { PanGestureHandlerEventPayload } from '../handlers/GestureHandlerEventPayload'; +import type { PanGestureHandlerEventPayload } from '../handlers/GestureHandlerEventPayload'; import Animated, { Extrapolation, SharedValue, diff --git a/src/components/touchables/GenericTouchable.tsx b/src/components/touchables/GenericTouchable.tsx index 94a1e6a007..20b235d347 100644 --- a/src/components/touchables/GenericTouchable.tsx +++ b/src/components/touchables/GenericTouchable.tsx @@ -9,7 +9,7 @@ import { GestureEvent, HandlerStateChangeEvent, } from '../../handlers/gestureHandlerCommon'; -import { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload'; +import type { NativeViewGestureHandlerPayload } from '../../handlers/GestureHandlerEventPayload'; import type { TouchableNativeFeedbackExtraProps } from './TouchableNativeFeedbackProps'; import type { GenericTouchableProps } from './GenericTouchableProps'; diff --git a/src/handlers/FlingGestureHandler.ts b/src/handlers/FlingGestureHandler.ts index 68174929dd..a202123dd7 100644 --- a/src/handlers/FlingGestureHandler.ts +++ b/src/handlers/FlingGestureHandler.ts @@ -1,4 +1,4 @@ -import { FlingGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import type { FlingGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, diff --git a/src/handlers/ForceTouchGestureHandler.ts b/src/handlers/ForceTouchGestureHandler.ts index 775b7c9506..4df1a72fda 100644 --- a/src/handlers/ForceTouchGestureHandler.ts +++ b/src/handlers/ForceTouchGestureHandler.ts @@ -6,7 +6,7 @@ import { BaseGestureHandlerProps, baseGestureHandlerProps, } from './gestureHandlerCommon'; -import { ForceTouchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import type { ForceTouchGestureHandlerEventPayload } from './GestureHandlerEventPayload'; export const forceTouchGestureHandlerProps = [ 'minForce', diff --git a/src/handlers/PanGestureHandler.ts b/src/handlers/PanGestureHandler.ts index 4669fe09ec..aa86bcb498 100644 --- a/src/handlers/PanGestureHandler.ts +++ b/src/handlers/PanGestureHandler.ts @@ -1,4 +1,4 @@ -import { PanGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import type { PanGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, diff --git a/src/handlers/TapGestureHandler.ts b/src/handlers/TapGestureHandler.ts index 097f2cd0b4..4fb2e3a615 100644 --- a/src/handlers/TapGestureHandler.ts +++ b/src/handlers/TapGestureHandler.ts @@ -1,4 +1,4 @@ -import { TapGestureHandlerEventPayload } from './GestureHandlerEventPayload'; +import type { TapGestureHandlerEventPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, diff --git a/src/handlers/gestureHandlerTypesCompat.ts b/src/handlers/gestureHandlerTypesCompat.ts index 0dbecf6c1d..c8ee8a5512 100644 --- a/src/handlers/gestureHandlerTypesCompat.ts +++ b/src/handlers/gestureHandlerTypesCompat.ts @@ -10,8 +10,8 @@ import { HandlerStateChangeEvent, HandlerStateChangeEventPayload, } from './gestureHandlerCommon'; -import { FlingGestureHandlerProps } from './FlingGestureHandler'; -import { +import type { FlingGestureHandlerProps } from './FlingGestureHandler'; +import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, diff --git a/src/handlers/gestures/flingGesture.ts b/src/handlers/gestures/flingGesture.ts index ed2318c6e6..abf6edbe74 100644 --- a/src/handlers/gestures/flingGesture.ts +++ b/src/handlers/gestures/flingGesture.ts @@ -1,6 +1,6 @@ import { BaseGesture, BaseGestureConfig } from './gesture'; import { FlingGestureConfig } from '../FlingGestureHandler'; -import { FlingGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { FlingGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class FlingGesture extends BaseGesture { public config: BaseGestureConfig & FlingGestureConfig = {}; diff --git a/src/handlers/gestures/forceTouchGesture.ts b/src/handlers/gestures/forceTouchGesture.ts index 45168e3e1f..7bd1ed73a7 100644 --- a/src/handlers/gestures/forceTouchGesture.ts +++ b/src/handlers/gestures/forceTouchGesture.ts @@ -1,6 +1,6 @@ import { BaseGestureConfig, ContinousBaseGesture } from './gesture'; import { ForceTouchGestureConfig } from '../ForceTouchGestureHandler'; -import { ForceTouchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { ForceTouchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; import { GestureUpdateEvent } from '../gestureHandlerCommon'; export type ForceTouchGestureChangeEventPayload = { diff --git a/src/handlers/gestures/gesture.ts b/src/handlers/gestures/gesture.ts index 7ea7210be3..d73e9c8b66 100644 --- a/src/handlers/gestures/gesture.ts +++ b/src/handlers/gestures/gesture.ts @@ -9,7 +9,7 @@ import { } from '../gestureHandlerCommon'; import { getNextHandlerTag } from '../handlerTag'; import { GestureStateManagerType } from './gestureStateManager'; -import { +import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, diff --git a/src/handlers/gestures/longPressGesture.ts b/src/handlers/gestures/longPressGesture.ts index f35c733d92..4fe555a39d 100644 --- a/src/handlers/gestures/longPressGesture.ts +++ b/src/handlers/gestures/longPressGesture.ts @@ -1,6 +1,6 @@ import { BaseGesture, BaseGestureConfig } from './gesture'; import { LongPressGestureConfig } from '../LongPressGestureHandler'; -import { LongPressGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { LongPressGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class LongPressGesture extends BaseGesture { public config: BaseGestureConfig & LongPressGestureConfig = {}; diff --git a/src/handlers/gestures/nativeGesture.ts b/src/handlers/gestures/nativeGesture.ts index 6545585e2f..b8b00abe44 100644 --- a/src/handlers/gestures/nativeGesture.ts +++ b/src/handlers/gestures/nativeGesture.ts @@ -1,6 +1,6 @@ import { BaseGestureConfig, BaseGesture } from './gesture'; import { NativeViewGestureConfig } from '../NativeViewGestureHandler'; -import { NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload'; +import type { NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload'; export class NativeGesture extends BaseGesture { public config: BaseGestureConfig & NativeViewGestureConfig = {}; diff --git a/src/handlers/gestures/panGesture.ts b/src/handlers/gestures/panGesture.ts index 7100c15277..366a2725a0 100644 --- a/src/handlers/gestures/panGesture.ts +++ b/src/handlers/gestures/panGesture.ts @@ -1,7 +1,7 @@ import { BaseGestureConfig, ContinousBaseGesture } from './gesture'; import { GestureUpdateEvent } from '../gestureHandlerCommon'; import { PanGestureConfig } from '../PanGestureHandler'; -import { PanGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { PanGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export type PanGestureChangeEventPayload = { changeX: number; diff --git a/src/handlers/gestures/pinchGesture.ts b/src/handlers/gestures/pinchGesture.ts index 23b49c0297..d001b09889 100644 --- a/src/handlers/gestures/pinchGesture.ts +++ b/src/handlers/gestures/pinchGesture.ts @@ -1,5 +1,5 @@ import { ContinousBaseGesture } from './gesture'; -import { PinchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { PinchGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; import { GestureUpdateEvent } from '../gestureHandlerCommon'; export type PinchGestureChangeEventPayload = { diff --git a/src/handlers/gestures/rotationGesture.ts b/src/handlers/gestures/rotationGesture.ts index 1c3ea4d80f..6a53b4a643 100644 --- a/src/handlers/gestures/rotationGesture.ts +++ b/src/handlers/gestures/rotationGesture.ts @@ -1,5 +1,5 @@ import { ContinousBaseGesture } from './gesture'; -import { RotationGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { RotationGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; import { GestureUpdateEvent } from '../gestureHandlerCommon'; type RotationGestureChangeEventPayload = { diff --git a/src/handlers/gestures/tapGesture.ts b/src/handlers/gestures/tapGesture.ts index 6951e82507..2126714fd9 100644 --- a/src/handlers/gestures/tapGesture.ts +++ b/src/handlers/gestures/tapGesture.ts @@ -1,6 +1,6 @@ import { BaseGestureConfig, BaseGesture } from './gesture'; import { TapGestureConfig } from '../TapGestureHandler'; -import { TapGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; +import type { TapGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; export class TapGesture extends BaseGesture { public config: BaseGestureConfig & TapGestureConfig = {}; diff --git a/src/jestUtils/jestUtils.ts b/src/jestUtils/jestUtils.ts index 679ea99d8c..61d0f07f3f 100644 --- a/src/jestUtils/jestUtils.ts +++ b/src/jestUtils/jestUtils.ts @@ -28,7 +28,7 @@ import { LongPressGestureHandler, longPressHandlerName, } from '../handlers/LongPressGestureHandler'; -import { +import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, From 35eee5c9180d562e33ec8c7167783c69c9865798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 09:35:22 +0200 Subject: [PATCH 15/21] optimize prop imports for type importing --- src/components/DrawerLayout.tsx | 2 +- src/components/GestureButtonsProps.ts | 2 +- src/components/ReanimatedSwipeable.tsx | 2 +- .../touchables/TouchableNativeFeedbackProps.tsx | 2 +- src/handlers/NativeViewGestureHandler.ts | 2 +- src/handlers/gestureHandlerTypesCompat.ts | 14 +++++++------- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/DrawerLayout.tsx b/src/components/DrawerLayout.tsx index 40245f1e56..a1079679e7 100644 --- a/src/components/DrawerLayout.tsx +++ b/src/components/DrawerLayout.tsx @@ -31,7 +31,7 @@ import { MouseButton, } from '../handlers/gestureHandlerCommon'; import { PanGestureHandler } from '../handlers/PanGestureHandler'; -import { +import type { PanGestureHandlerEventPayload, TapGestureHandlerEventPayload, } from '../handlers/GestureHandlerEventPayload'; diff --git a/src/components/GestureButtonsProps.ts b/src/components/GestureButtonsProps.ts index 7f3265ed46..a79c779830 100644 --- a/src/components/GestureButtonsProps.ts +++ b/src/components/GestureButtonsProps.ts @@ -1,6 +1,6 @@ import * as React from 'react'; import { StyleProp, ViewStyle } from 'react-native'; -import { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; +import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler'; export interface RawButtonProps extends NativeViewGestureHandlerProps { /** diff --git a/src/components/ReanimatedSwipeable.tsx b/src/components/ReanimatedSwipeable.tsx index 75e8061422..c6b4600712 100644 --- a/src/components/ReanimatedSwipeable.tsx +++ b/src/components/ReanimatedSwipeable.tsx @@ -15,7 +15,7 @@ import { GestureStateChangeEvent, GestureUpdateEvent, } from '../handlers/gestureHandlerCommon'; -import { PanGestureHandlerProps } from '../handlers/PanGestureHandler'; +import type { PanGestureHandlerProps } from '../handlers/PanGestureHandler'; import type { PanGestureHandlerEventPayload } from '../handlers/GestureHandlerEventPayload'; import Animated, { Extrapolation, diff --git a/src/components/touchables/TouchableNativeFeedbackProps.tsx b/src/components/touchables/TouchableNativeFeedbackProps.tsx index 457df4a14a..00cb8eb718 100644 --- a/src/components/touchables/TouchableNativeFeedbackProps.tsx +++ b/src/components/touchables/TouchableNativeFeedbackProps.tsx @@ -1,4 +1,4 @@ -import { TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps } from 'react-native'; +import type { TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps } from 'react-native'; import type { GenericTouchableProps } from './GenericTouchableProps'; export type TouchableNativeFeedbackExtraProps = { diff --git a/src/handlers/NativeViewGestureHandler.ts b/src/handlers/NativeViewGestureHandler.ts index 02f3b49efb..f80f90f210 100644 --- a/src/handlers/NativeViewGestureHandler.ts +++ b/src/handlers/NativeViewGestureHandler.ts @@ -1,4 +1,4 @@ -import { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload'; +import type { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload'; import createHandler from './createHandler'; import { BaseGestureHandlerProps, diff --git a/src/handlers/gestureHandlerTypesCompat.ts b/src/handlers/gestureHandlerTypesCompat.ts index c8ee8a5512..8843a96eae 100644 --- a/src/handlers/gestureHandlerTypesCompat.ts +++ b/src/handlers/gestureHandlerTypesCompat.ts @@ -21,13 +21,13 @@ import type { TapGestureHandlerEventPayload, NativeViewGestureHandlerPayload, } from './GestureHandlerEventPayload'; -import { ForceTouchGestureHandlerProps } from './ForceTouchGestureHandler'; -import { LongPressGestureHandlerProps } from './LongPressGestureHandler'; -import { PanGestureHandlerProps } from './PanGestureHandler'; -import { PinchGestureHandlerProps } from './PinchGestureHandler'; -import { RotationGestureHandlerProps } from './RotationGestureHandler'; -import { TapGestureHandlerProps } from './TapGestureHandler'; -import { NativeViewGestureHandlerProps } from './NativeViewGestureHandler'; +import type { ForceTouchGestureHandlerProps } from './ForceTouchGestureHandler'; +import type { LongPressGestureHandlerProps } from './LongPressGestureHandler'; +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; From 71eccccae6b901029a9b4c6c88d790617128125a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 09:40:46 +0200 Subject: [PATCH 16/21] rename file as per suggestion --- src/handlers/createHandler.tsx | 6 +----- src/handlers/gestures/GestureDetector/attachHandlers.ts | 5 +---- src/handlers/gestures/GestureDetector/dropHandlers.ts | 2 +- src/handlers/gestures/GestureDetector/updateHandlers.ts | 5 +---- src/handlers/{gestureCommonUtils.ts => utils.ts} | 0 5 files changed, 4 insertions(+), 14 deletions(-) rename src/handlers/{gestureCommonUtils.ts => utils.ts} (100%) diff --git a/src/handlers/createHandler.tsx b/src/handlers/createHandler.tsx index 7d112d8c45..e26ea54a3e 100644 --- a/src/handlers/createHandler.tsx +++ b/src/handlers/createHandler.tsx @@ -16,11 +16,7 @@ import { GestureEvent, HandlerStateChangeEvent, } from './gestureHandlerCommon'; -import { - filterConfig, - findNodeHandle, - scheduleFlushOperations, -} from './gestureCommonUtils'; +import { filterConfig, findNodeHandle, scheduleFlushOperations } from './utils'; import { ValueOf } from '../typeUtils'; import { deepEqual, isFabric, isJestEnv, tagMessage } from '../utils'; import { ActionType } from '../ActionType'; diff --git a/src/handlers/gestures/GestureDetector/attachHandlers.ts b/src/handlers/gestures/GestureDetector/attachHandlers.ts index 8645af3d14..760f4af8f0 100644 --- a/src/handlers/gestures/GestureDetector/attachHandlers.ts +++ b/src/handlers/gestures/GestureDetector/attachHandlers.ts @@ -2,10 +2,7 @@ import React from 'react'; import { GestureType, HandlerCallbacks } from '../gesture'; import { registerHandler } from '../../handlersRegistry'; import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; -import { - filterConfig, - scheduleFlushOperations, -} from '../../gestureCommonUtils'; +import { filterConfig, scheduleFlushOperations } from '../../utils'; import { ComposedGesture } from '../gestureComposition'; import { ActionType } from '../../../ActionType'; import { Platform } from 'react-native'; diff --git a/src/handlers/gestures/GestureDetector/dropHandlers.ts b/src/handlers/gestures/GestureDetector/dropHandlers.ts index 8695e40957..2f8510c5c2 100644 --- a/src/handlers/gestures/GestureDetector/dropHandlers.ts +++ b/src/handlers/gestures/GestureDetector/dropHandlers.ts @@ -1,6 +1,6 @@ import { unregisterHandler } from '../../handlersRegistry'; import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; -import { scheduleFlushOperations } from '../../gestureCommonUtils'; +import { scheduleFlushOperations } from '../../utils'; import { AttachedGestureState } from './types'; export function dropHandlers(preparedGesture: AttachedGestureState) { diff --git a/src/handlers/gestures/GestureDetector/updateHandlers.ts b/src/handlers/gestures/GestureDetector/updateHandlers.ts index d5c3c28bb9..83552105cd 100644 --- a/src/handlers/gestures/GestureDetector/updateHandlers.ts +++ b/src/handlers/gestures/GestureDetector/updateHandlers.ts @@ -1,10 +1,7 @@ import { GestureType, HandlerCallbacks } from '../gesture'; import { registerHandler } from '../../handlersRegistry'; import RNGestureHandlerModule from '../../../RNGestureHandlerModule'; -import { - filterConfig, - scheduleFlushOperations, -} from '../../gestureCommonUtils'; +import { filterConfig, scheduleFlushOperations } from '../../utils'; import { ComposedGesture } from '../gestureComposition'; import { ghQueueMicrotask } from '../../../ghQueueMicrotask'; import { AttachedGestureState } from './types'; diff --git a/src/handlers/gestureCommonUtils.ts b/src/handlers/utils.ts similarity index 100% rename from src/handlers/gestureCommonUtils.ts rename to src/handlers/utils.ts From b3ed53a73529e39418613a331481b5d4cac5504d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 09:42:13 +0200 Subject: [PATCH 17/21] rename one-function file as per suggestion --- src/handlers/createHandler.tsx | 2 +- src/handlers/gestures/gesture.ts | 2 +- src/handlers/{handlerTag.ts => getNextHandlerTag.ts} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/handlers/{handlerTag.ts => getNextHandlerTag.ts} (100%) diff --git a/src/handlers/createHandler.tsx b/src/handlers/createHandler.tsx index e26ea54a3e..2559d26372 100644 --- a/src/handlers/createHandler.tsx +++ b/src/handlers/createHandler.tsx @@ -9,7 +9,7 @@ import { customDirectEventTypes } from './customDirectEventTypes'; import RNGestureHandlerModule from '../RNGestureHandlerModule'; import { State } from '../State'; import { handlerIDToTag, registerOldGestureHandler } from './handlersRegistry'; -import { getNextHandlerTag } from './handlerTag'; +import { getNextHandlerTag } from './getNextHandlerTag'; import { BaseGestureHandlerProps, diff --git a/src/handlers/gestures/gesture.ts b/src/handlers/gestures/gesture.ts index d73e9c8b66..cf5382a880 100644 --- a/src/handlers/gestures/gesture.ts +++ b/src/handlers/gestures/gesture.ts @@ -7,7 +7,7 @@ import { ActiveCursor, MouseButton, } from '../gestureHandlerCommon'; -import { getNextHandlerTag } from '../handlerTag'; +import { getNextHandlerTag } from '../getNextHandlerTag'; import { GestureStateManagerType } from './gestureStateManager'; import type { FlingGestureHandlerEventPayload, diff --git a/src/handlers/handlerTag.ts b/src/handlers/getNextHandlerTag.ts similarity index 100% rename from src/handlers/handlerTag.ts rename to src/handlers/getNextHandlerTag.ts From df5e728265f09917a8333033a2582805d3957204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 09:45:01 +0200 Subject: [PATCH 18/21] rename and optimize file as per suggestion --- .../{GenericTouchableProps.tsx => GenericTouchableProps.ts} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/components/touchables/{GenericTouchableProps.tsx => GenericTouchableProps.ts} (90%) diff --git a/src/components/touchables/GenericTouchableProps.tsx b/src/components/touchables/GenericTouchableProps.ts similarity index 90% rename from src/components/touchables/GenericTouchableProps.tsx rename to src/components/touchables/GenericTouchableProps.ts index 81bfe1de21..b51a2f228f 100644 --- a/src/components/touchables/GenericTouchableProps.tsx +++ b/src/components/touchables/GenericTouchableProps.ts @@ -1,10 +1,10 @@ -import { +import type { StyleProp, ViewStyle, TouchableWithoutFeedbackProps, Insets, } from 'react-native'; -import { UserSelect } from '../../handlers/gestureHandlerCommon'; +import type { UserSelect } from '../../handlers/gestureHandlerCommon'; export interface GenericTouchableProps extends Omit { From 045fd6681f8c1e64ab4546f46783c7e20237e13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 12:30:58 +0200 Subject: [PATCH 19/21] add yarn madge workflow --- .github/workflows/static-root-checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/static-root-checks.yml b/.github/workflows/static-root-checks.yml index e406967d14..8884fe8677 100644 --- a/.github/workflows/static-root-checks.yml +++ b/.github/workflows/static-root-checks.yml @@ -29,3 +29,5 @@ jobs: run: yarn tsc --noEmit - name: Lint run: yarn lint:js-root + - name: Check for circular dependencies + run: yarn madge --extensions js,ts,tsx --circular src From 52a970b69b6ab07ecc7ccd3b92252ecee14078dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 13:03:55 +0200 Subject: [PATCH 20/21] simplify workflow --- .github/workflows/static-root-checks.yml | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static-root-checks.yml b/.github/workflows/static-root-checks.yml index 8884fe8677..5ecb4aa5be 100644 --- a/.github/workflows/static-root-checks.yml +++ b/.github/workflows/static-root-checks.yml @@ -30,4 +30,4 @@ jobs: - name: Lint run: yarn lint:js-root - name: Check for circular dependencies - run: yarn madge --extensions js,ts,tsx --circular src + run: yarn checkForCircularDependencies diff --git a/package.json b/package.json index 42a3e66dd2..e20fc3bf69 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "lint:js": "eslint --ext '.js,.ts,.tsx' src/ example/src FabricExample/src MacOSExample/src && yarn prettier --check './{src,example,FabricExample,MacOSExample}/**/*.{js,jsx,ts,tsx}'", "lint:js-root": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'", "lint:android": "./android/gradlew -p android spotlessCheck -q", - "checkIntegrity": "(cd ./FabricExample/android && ./gradlew generateCodegenArtifactsFromSchema -PskipCodegenCopyTask) && (cd ./android && ./gradlew checkIntegrityBetweenArchitectures)" + "checkIntegrity": "(cd ./FabricExample/android && ./gradlew generateCodegenArtifactsFromSchema -PskipCodegenCopyTask) && (cd ./android && ./gradlew checkIntegrityBetweenArchitectures)", + "checkForCircularDependencies": "yarn madge --extensions js,ts,tsx --circular src" }, "react-native": "src/index.ts", "main": "lib/commonjs/index.js", From c8cc98263307714d863993a3be6d822e06fc4a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Tue, 2 Jul 2024 13:38:08 +0200 Subject: [PATCH 21/21] update function name as per request --- .github/workflows/static-root-checks.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static-root-checks.yml b/.github/workflows/static-root-checks.yml index 5ecb4aa5be..eda476ecb1 100644 --- a/.github/workflows/static-root-checks.yml +++ b/.github/workflows/static-root-checks.yml @@ -30,4 +30,4 @@ jobs: - name: Lint run: yarn lint:js-root - name: Check for circular dependencies - run: yarn checkForCircularDependencies + run: yarn circularDependencyCheck diff --git a/package.json b/package.json index e20fc3bf69..f8161ba3f8 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint:js-root": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'", "lint:android": "./android/gradlew -p android spotlessCheck -q", "checkIntegrity": "(cd ./FabricExample/android && ./gradlew generateCodegenArtifactsFromSchema -PskipCodegenCopyTask) && (cd ./android && ./gradlew checkIntegrityBetweenArchitectures)", - "checkForCircularDependencies": "yarn madge --extensions js,ts,tsx --circular src" + "circularDependencyCheck": "yarn madge --extensions js,ts,tsx --circular src" }, "react-native": "src/index.ts", "main": "lib/commonjs/index.js",