Skip to content

Commit c6b424f

Browse files
authored
Deprecate builder API (#4103)
## Description The time to deprecate builder API has come. ## Test plan Checked in vsc that v2 related elements are marked as deprecated.
1 parent a116ba8 commit c6b424f

14 files changed

Lines changed: 123 additions & 4 deletions

packages/react-native-gesture-handler/src/handlers/gestures/flingGesture.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import type { FlingGestureHandlerEventPayload } from '../GestureHandlerEventPayl
33
import type { BaseGestureConfig } from './gesture';
44
import { BaseGesture } from './gesture';
55

6+
/**
7+
* @deprecated `FlingGesture` is deprecated and will be removed in the future. Please use `useFlingGesture` instead.
8+
*/
69
export class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {
710
public override config: BaseGestureConfig & FlingGestureConfig = {};
811

@@ -34,4 +37,7 @@ export class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {
3437
}
3538
}
3639

40+
/**
41+
* @deprecated `FlingGestureType` is deprecated and will be removed in the future. Please use `FlingGesture` instead.
42+
*/
3743
export type FlingGestureType = InstanceType<typeof FlingGesture>;

packages/react-native-gesture-handler/src/handlers/gestures/forceTouchGesture.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { BaseGestureConfig } from './gesture';
55
import { ContinousBaseGesture } from './gesture';
66

77
/**
8-
* @deprecated ForceTouch gesture is deprecated and will be removed in the future.
8+
* @deprecated `ForceTouchGestureChangeEventPayload` is deprecated and will be removed in the future.
99
*/
1010
export type ForceTouchGestureChangeEventPayload = {
1111
forceChange: number;
@@ -31,7 +31,7 @@ function changeEventCalculator(
3131
}
3232

3333
/**
34-
* @deprecated ForceTouch gesture is deprecated and will be removed in the future.
34+
* @deprecated `ForceTouchGesture` is deprecated and will be removed in the future.
3535
*/
3636
export class ForceTouchGesture extends ContinousBaseGesture<
3737
ForceTouchGestureHandlerEventPayload,
@@ -91,6 +91,6 @@ export class ForceTouchGesture extends ContinousBaseGesture<
9191
}
9292

9393
/**
94-
* @deprecated ForceTouch gesture is deprecated and will be removed in the future.
94+
* @deprecated `ForceTouchGestureType` is deprecated and will be removed in the future.
9595
*/
9696
export type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;

packages/react-native-gesture-handler/src/handlers/gestures/gesture.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import type {
2222
import { getNextHandlerTag } from '../getNextHandlerTag';
2323
import type { GestureStateManagerType } from './gestureStateManager';
2424

25+
/**
26+
* @deprecated `GestureType` is deprecated and will be removed in the future. Please use `SingleGesture` instead.
27+
*/
2528
export type GestureType =
2629
| BaseGesture<Record<string, unknown>>
2730
| BaseGesture<Record<string, never>>
@@ -35,6 +38,9 @@ export type GestureType =
3538
| BaseGesture<NativeViewGestureHandlerPayload>
3639
| BaseGesture<HoverGestureHandlerEventPayload>;
3740

41+
/**
42+
* @deprecated `GestureRef` is deprecated and will be removed in the future.
43+
*/
3844
export type GestureRef =
3945
| number
4046
| GestureType

packages/react-native-gesture-handler/src/handlers/gestures/gestureComposition.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ function extendRelation(
1212
}
1313
}
1414

15+
/**
16+
* @deprecated `ComposedGesture` is deprecated and will be removed in the future. Please use `useCompetingGestures` instead.
17+
*/
1518
export class ComposedGesture extends Gesture {
1619
protected gestures: Gesture[] = [];
1720
protected simultaneousGestures: GestureType[] = [];
@@ -70,6 +73,9 @@ export class ComposedGesture extends Gesture {
7073
}
7174
}
7275

76+
/**
77+
* @deprecated `SimultaneousGesture` is deprecated and will be removed in the future. Please use `useSimultaneousGestures` instead.
78+
*/
7379
export class SimultaneousGesture extends ComposedGesture {
7480
override prepare() {
7581
// This piece of magic works something like this:
@@ -96,6 +102,9 @@ export class SimultaneousGesture extends ComposedGesture {
96102
}
97103
}
98104

105+
/**
106+
* @deprecated `ExclusiveGesture` is deprecated and will be removed in the future. Please use `useExclusiveGestures` instead.
107+
*/
99108
export class ExclusiveGesture extends ComposedGesture {
100109
override prepare() {
101110
// Transforms the array of gestures into array of grouped raw (not composed) gestures
@@ -119,7 +128,19 @@ export class ExclusiveGesture extends ComposedGesture {
119128
}
120129
}
121130

131+
/**
132+
* @deprecated `ComposedGestureType` is deprecated and will be removed in the future. Please use `ComposedGesture` instead.
133+
*/
122134
export type ComposedGestureType = InstanceType<typeof ComposedGesture>;
135+
/**
136+
* @deprecated `RaceGestureType` is deprecated and will be removed in the future. Please use `ComposedGesture` instead.
137+
*/
123138
export type RaceGestureType = ComposedGestureType;
139+
/**
140+
* @deprecated `SimultaneousGestureType` is deprecated and will be removed in the future. Please use `ComposedGesture` instead.
141+
*/
124142
export type SimultaneousGestureType = InstanceType<typeof SimultaneousGesture>;
143+
/**
144+
* @deprecated `ExclusiveGestureType` is deprecated and will be removed in the future. Please use `ComposedGesture` instead.
145+
*/
125146
export type ExclusiveGestureType = InstanceType<typeof ExclusiveGesture>;

packages/react-native-gesture-handler/src/handlers/gestures/gestureObjects.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { RotationGesture } from './rotationGesture';
1616
import { TapGesture } from './tapGesture';
1717

1818
/**
19+
* @deprecated `Gesture` builder API is deprecated and will be removed in a future version of Gesture Handler. Please migrate to the new, hook-based API.
20+
*
1921
* `Gesture` is the object that allows you to create and compose gestures.
2022
*
2123
* ### Remarks
@@ -25,6 +27,8 @@ import { TapGesture } from './tapGesture';
2527
*/
2628
export const GestureObjects = {
2729
/**
30+
* @deprecated `Gesture.Tap()` is deprecated and will be removed in the future. Please use `useTapGesture` instead.
31+
*
2832
* A discrete gesture that recognizes one or many taps.
2933
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture
3034
*/
@@ -33,6 +37,8 @@ export const GestureObjects = {
3337
},
3438

3539
/**
40+
* @deprecated `Gesture.Pan()` is deprecated and will be removed in the future. Please use `usePanGesture` instead.
41+
*
3642
* A continuous gesture that can recognize a panning (dragging) gesture and track its movement.
3743
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture
3844
*/
@@ -41,6 +47,8 @@ export const GestureObjects = {
4147
},
4248

4349
/**
50+
* @deprecated `Gesture.Pinch()` is deprecated and will be removed in the future. Please use `usePinchGesture` instead.
51+
*
4452
* A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or zoom your content.
4553
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pinch-gesture
4654
*/
@@ -49,6 +57,8 @@ export const GestureObjects = {
4957
},
5058

5159
/**
60+
* @deprecated `Gesture.Rotation()` is deprecated and will be removed in the future. Please use `useRotationGesture` instead.
61+
*
5262
* A continuous gesture that can recognize rotation and track its movement.
5363
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/rotation-gesture
5464
*/
@@ -57,6 +67,8 @@ export const GestureObjects = {
5767
},
5868

5969
/**
70+
* @deprecated `Gesture.Fling()` is deprecated and will be removed in the future. Please use `useFlingGesture` instead.
71+
*
6072
* A discrete gesture that activates when the movement is sufficiently fast.
6173
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture
6274
*/
@@ -65,6 +77,8 @@ export const GestureObjects = {
6577
},
6678

6779
/**
80+
* @deprecated `Gesture.LongPress()` is deprecated and will be removed in the future. Please use `useLongPressGesture` instead.
81+
*
6882
* A discrete gesture that activates when the corresponding view is pressed for a sufficiently long time.
6983
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture
7084
*/
@@ -73,7 +87,7 @@ export const GestureObjects = {
7387
},
7488

7589
/**
76-
* @deprecated ForceTouch gesture is deprecated and will be removed in the future.
90+
* @deprecated `Gesture.ForceTouch()` is deprecated and will be removed in the future.
7791
*
7892
* #### iOS only
7993
* A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
@@ -84,6 +98,8 @@ export const GestureObjects = {
8498
},
8599

86100
/**
101+
* @deprecated `Gesture.Native()` is deprecated and will be removed in the future. Please use `useNativeGesture` instead.
102+
*
87103
* A gesture that allows other touch handling components to participate in RNGH's gesture system.
88104
* When used, the other component should be the direct child of a `GestureDetector`.
89105
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/native-gesture
@@ -93,6 +109,8 @@ export const GestureObjects = {
93109
},
94110

95111
/**
112+
* @deprecated `Gesture.Manual()` is deprecated and will be removed in the future. Please use `useManualGesture` instead.
113+
*
96114
* A plain gesture that has no specific activation criteria nor event data set.
97115
* Its state has to be controlled manually using a state manager.
98116
* It will not fail when all the pointers are lifted from the screen.
@@ -103,6 +121,8 @@ export const GestureObjects = {
103121
},
104122

105123
/**
124+
* @deprecated `Gesture.Hover()` is deprecated and will be removed in the future. Please use `useHoverGesture` instead.
125+
*
106126
* A continuous gesture that can recognize hovering above the view it's attached to.
107127
* The hover effect may be activated by moving a mouse or a stylus over the view.
108128
*
@@ -113,6 +133,8 @@ export const GestureObjects = {
113133
},
114134

115135
/**
136+
* @deprecated `Gesture.Race()` is deprecated and will be removed in the future. Please use `useCompetingGestures` instead.
137+
*
116138
* Builds a composed gesture consisting of gestures provided as parameters.
117139
* The first one that becomes active cancels the rest of gestures.
118140
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#race
@@ -122,6 +144,8 @@ export const GestureObjects = {
122144
},
123145

124146
/**
147+
* @deprecated `Gesture.Simultaneous()` is deprecated and will be removed in the future. Please use `useSimultaneousGestures` instead.
148+
*
125149
* Builds a composed gesture that allows all base gestures to run simultaneously.
126150
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneous
127151
*/
@@ -130,6 +154,8 @@ export const GestureObjects = {
130154
},
131155

132156
/**
157+
* @deprecated `Gesture.Exclusive()` is deprecated and will be removed in the future. Please use `useExclusiveGestures` instead.
158+
*
133159
* Builds a composed gesture where only one of the provided gestures can become active.
134160
* Priority is decided through the order of gestures: the first one has higher priority
135161
* than the second one, second one has higher priority than the third one, and so on.

packages/react-native-gesture-handler/src/handlers/gestures/gestureStateManager.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { State } from '../../State';
22
import { tagMessage } from '../../utils';
33

4+
/**
5+
* @deprecated `LegacyGestureStateManagerType` is deprecated and will be removed in the future. Please use the new, hook-based API instead.
6+
*/
47
export interface GestureStateManagerType {
58
begin: () => void;
69
activate: () => void;
@@ -49,6 +52,9 @@ function create(handlerTag: number): GestureStateManagerType {
4952
};
5053
}
5154

55+
/**
56+
* @deprecated `LegacyGestureStateManager` is deprecated and will be removed in the future. Please use the new, hook-based API instead.
57+
*/
5258
export const GestureStateManager = {
5359
create,
5460
};

packages/react-native-gesture-handler/src/handlers/gestures/hoverGesture.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ function changeEventCalculator(
4141
return { ...current, ...changePayload };
4242
}
4343

44+
/**
45+
* @deprecated `HoverGesture` is deprecated and will be removed in the future. Please use `useHoverGesture` instead.
46+
*/
4447
export class HoverGesture extends ContinousBaseGesture<
4548
HoverGestureHandlerEventPayload,
4649
HoverGestureChangeEventPayload
@@ -75,4 +78,7 @@ export class HoverGesture extends ContinousBaseGesture<
7578
}
7679
}
7780

81+
/**
82+
* @deprecated `HoverGestureType` is deprecated and will be removed in the future. Please use `HoverGesture` instead.
83+
*/
7884
export type HoverGestureType = InstanceType<typeof HoverGesture>;

packages/react-native-gesture-handler/src/handlers/gestures/longPressGesture.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import type { LongPressGestureConfig } from '../LongPressGestureHandler';
33
import type { BaseGestureConfig } from './gesture';
44
import { BaseGesture } from './gesture';
55

6+
/**
7+
* @deprecated `LongPressGesture` is deprecated and will be removed in the future. Please use `useLongPressGesture` instead.
8+
*/
69
export class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPayload> {
710
public override config: BaseGestureConfig & LongPressGestureConfig = {};
811

@@ -43,4 +46,7 @@ export class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPa
4346
}
4447
}
4548

49+
/**
50+
* @deprecated `LongPressGestureType` is deprecated and will be removed in the future. Please use `LongPressGesture` instead.
51+
*/
4652
export type LongPressGestureType = InstanceType<typeof LongPressGesture>;

packages/react-native-gesture-handler/src/handlers/gestures/manualGesture.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ function changeEventCalculator(
99
return current;
1010
}
1111

12+
/**
13+
* @deprecated `ManualGesture` is deprecated and will be removed in the future. Please use `useManualGesture` instead.
14+
*/
1215
export class ManualGesture extends ContinousBaseGesture<
1316
Record<string, never>,
1417
Record<string, never>
@@ -28,4 +31,7 @@ export class ManualGesture extends ContinousBaseGesture<
2831
}
2932
}
3033

34+
/**
35+
* @deprecated `ManualGestureType` is deprecated and will be removed in the future. Please use `ManualGesture` instead.
36+
*/
3137
export type ManualGestureType = InstanceType<typeof ManualGesture>;

packages/react-native-gesture-handler/src/handlers/gestures/nativeGesture.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import type { NativeViewGestureConfig } from '../NativeViewGestureHandler';
33
import type { BaseGestureConfig } from './gesture';
44
import { BaseGesture } from './gesture';
55

6+
/**
7+
* @deprecated `NativeGesture` is deprecated and will be removed in the future. Please use `useNativeGesture` instead.
8+
*/
69
export class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload> {
710
public override config: BaseGestureConfig & NativeViewGestureConfig = {};
811

@@ -31,4 +34,7 @@ export class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload>
3134
}
3235
}
3336

37+
/**
38+
* @deprecated `NativeGestureType` is deprecated and will be removed in the future. Please use `NativeGesture` instead.
39+
*/
3440
export type NativeGestureType = InstanceType<typeof NativeGesture>;

0 commit comments

Comments
 (0)