Skip to content

Commit 8a8b506

Browse files
authored
Update how Gesture Handler exposes setGestureState to the Reanimated UI runtime (#3207)
## Description Changes how `setGestureState` is exposed to the UI runtime. Instead of the weird conditionally adding Reanimated as a dependency on Android and the weird cast on iOS it uses `_WORKLET_RUNTIME` const injected by Reanimated into the JS runtime. This allows Gesture Handler to decorate the UI runtime without direct dependencies between the libraries. The new approach relies on two methods being added to the global object: - `_setGestureStateAsync` on the JS runtime - `_setGestureStateSync` on the UI runtime which allows for state manipulation also from the JS thread. The basic example has been modified to easily test the new functionality. > [!CAUTION] > This works only on the New Architecture (and breaks the old one) ## Test plan Test the expo example app and the modified basic example app
1 parent ea0d25b commit 8a8b506

File tree

33 files changed

+790
-429
lines changed

33 files changed

+790
-429
lines changed

.lintstagedrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"yarn format:android"
77
],
88
"packages/react-native-gesture-handler/apple/**/*.{h,m,mm,cpp}": "yarn format:apple",
9+
"packages/react-native-gesture-handler/{shared,android/src}/**/*.{h,cpp}": "yarn format:cpp",
910
"packages/react-native-gesture-handler/src/specs/*.ts": "yarn workspace react-native-gesture-handler sync-architectures"
1011
}

apps/basic-example/Gemfile.lock

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ GEM
55
base64
66
nkf
77
rexml
8-
activesupport (7.2.2.1)
8+
activesupport (7.1.4.2)
99
base64
10-
benchmark (>= 0.3)
1110
bigdecimal
12-
concurrent-ruby (~> 1.0, >= 1.3.1)
11+
concurrent-ruby (~> 1.0, >= 1.0.2)
1312
connection_pool (>= 2.2.5)
1413
drb
1514
i18n (>= 1.6, < 2)
16-
logger (>= 1.4.2)
1715
minitest (>= 5.1)
18-
securerandom (>= 0.3)
19-
tzinfo (~> 2.0, >= 2.0.5)
16+
mutex_m
17+
tzinfo (~> 2.0)
2018
addressable (2.8.7)
2119
public_suffix (>= 2.0.2, < 7.0)
2220
algoliasearch (1.27.5)
@@ -91,7 +89,6 @@ GEM
9189
public_suffix (4.0.7)
9290
rexml (3.4.1)
9391
ruby-macho (2.5.1)
94-
securerandom (0.4.1)
9592
typhoeus (1.4.1)
9693
ethon (>= 0.9.0)
9794
tzinfo (2.0.6)
@@ -121,4 +118,4 @@ RUBY VERSION
121118
ruby 3.3.5p100
122119

123120
BUNDLED WITH
124-
2.5.23
121+
2.4.7

apps/basic-example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Specifies the JVM arguments used for the daemon process.
1111
# The setting is particularly useful for tweaking memory settings.
1212
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13-
org.gradle.jvmargs=-Xmx512m -XX:MaxMetaspaceSize=512m
13+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
1414

1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit

apps/basic-example/babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module.exports = {
22
presets: ['module:@react-native/babel-preset'],
3+
plugins: ['react-native-worklets/plugin'],
34
};

apps/basic-example/ios/Podfile.lock

Lines changed: 223 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,218 @@ PODS:
21512151
- ReactCommon/turbomodule/core
21522152
- SocketRocket
21532153
- Yoga
2154+
- RNReanimated (4.0.0-beta.5):
2155+
- boost
2156+
- DoubleConversion
2157+
- fast_float
2158+
- fmt
2159+
- glog
2160+
- hermes-engine
2161+
- RCT-Folly
2162+
- RCT-Folly/Fabric
2163+
- RCTRequired
2164+
- RCTTypeSafety
2165+
- React-Core
2166+
- React-debug
2167+
- React-Fabric
2168+
- React-featureflags
2169+
- React-graphics
2170+
- React-hermes
2171+
- React-ImageManager
2172+
- React-jsi
2173+
- React-NativeModulesApple
2174+
- React-RCTFabric
2175+
- React-renderercss
2176+
- React-rendererdebug
2177+
- React-utils
2178+
- ReactCodegen
2179+
- ReactCommon/turbomodule/bridging
2180+
- ReactCommon/turbomodule/core
2181+
- RNReanimated/reanimated (= 4.0.0-beta.5)
2182+
- RNWorklets
2183+
- SocketRocket
2184+
- Yoga
2185+
- RNReanimated/reanimated (4.0.0-beta.5):
2186+
- boost
2187+
- DoubleConversion
2188+
- fast_float
2189+
- fmt
2190+
- glog
2191+
- hermes-engine
2192+
- RCT-Folly
2193+
- RCT-Folly/Fabric
2194+
- RCTRequired
2195+
- RCTTypeSafety
2196+
- React-Core
2197+
- React-debug
2198+
- React-Fabric
2199+
- React-featureflags
2200+
- React-graphics
2201+
- React-hermes
2202+
- React-ImageManager
2203+
- React-jsi
2204+
- React-NativeModulesApple
2205+
- React-RCTFabric
2206+
- React-renderercss
2207+
- React-rendererdebug
2208+
- React-utils
2209+
- ReactCodegen
2210+
- ReactCommon/turbomodule/bridging
2211+
- ReactCommon/turbomodule/core
2212+
- RNReanimated/reanimated/apple (= 4.0.0-beta.5)
2213+
- RNReanimated/reanimated/view (= 4.0.0-beta.5)
2214+
- RNWorklets
2215+
- SocketRocket
2216+
- Yoga
2217+
- RNReanimated/reanimated/apple (4.0.0-beta.5):
2218+
- boost
2219+
- DoubleConversion
2220+
- fast_float
2221+
- fmt
2222+
- glog
2223+
- hermes-engine
2224+
- RCT-Folly
2225+
- RCT-Folly/Fabric
2226+
- RCTRequired
2227+
- RCTTypeSafety
2228+
- React-Core
2229+
- React-debug
2230+
- React-Fabric
2231+
- React-featureflags
2232+
- React-graphics
2233+
- React-hermes
2234+
- React-ImageManager
2235+
- React-jsi
2236+
- React-NativeModulesApple
2237+
- React-RCTFabric
2238+
- React-renderercss
2239+
- React-rendererdebug
2240+
- React-utils
2241+
- ReactCodegen
2242+
- ReactCommon/turbomodule/bridging
2243+
- ReactCommon/turbomodule/core
2244+
- RNWorklets
2245+
- SocketRocket
2246+
- Yoga
2247+
- RNReanimated/reanimated/view (4.0.0-beta.5):
2248+
- boost
2249+
- DoubleConversion
2250+
- fast_float
2251+
- fmt
2252+
- glog
2253+
- hermes-engine
2254+
- RCT-Folly
2255+
- RCT-Folly/Fabric
2256+
- RCTRequired
2257+
- RCTTypeSafety
2258+
- React-Core
2259+
- React-debug
2260+
- React-Fabric
2261+
- React-featureflags
2262+
- React-graphics
2263+
- React-hermes
2264+
- React-ImageManager
2265+
- React-jsi
2266+
- React-NativeModulesApple
2267+
- React-RCTFabric
2268+
- React-renderercss
2269+
- React-rendererdebug
2270+
- React-utils
2271+
- ReactCodegen
2272+
- ReactCommon/turbomodule/bridging
2273+
- ReactCommon/turbomodule/core
2274+
- RNWorklets
2275+
- SocketRocket
2276+
- Yoga
2277+
- RNWorklets (0.3.0):
2278+
- boost
2279+
- DoubleConversion
2280+
- fast_float
2281+
- fmt
2282+
- glog
2283+
- hermes-engine
2284+
- RCT-Folly
2285+
- RCT-Folly/Fabric
2286+
- RCTRequired
2287+
- RCTTypeSafety
2288+
- React-Core
2289+
- React-debug
2290+
- React-Fabric
2291+
- React-featureflags
2292+
- React-graphics
2293+
- React-hermes
2294+
- React-ImageManager
2295+
- React-jsi
2296+
- React-NativeModulesApple
2297+
- React-RCTFabric
2298+
- React-renderercss
2299+
- React-rendererdebug
2300+
- React-utils
2301+
- ReactCodegen
2302+
- ReactCommon/turbomodule/bridging
2303+
- ReactCommon/turbomodule/core
2304+
- RNWorklets/worklets (= 0.3.0)
2305+
- SocketRocket
2306+
- Yoga
2307+
- RNWorklets/worklets (0.3.0):
2308+
- boost
2309+
- DoubleConversion
2310+
- fast_float
2311+
- fmt
2312+
- glog
2313+
- hermes-engine
2314+
- RCT-Folly
2315+
- RCT-Folly/Fabric
2316+
- RCTRequired
2317+
- RCTTypeSafety
2318+
- React-Core
2319+
- React-debug
2320+
- React-Fabric
2321+
- React-featureflags
2322+
- React-graphics
2323+
- React-hermes
2324+
- React-ImageManager
2325+
- React-jsi
2326+
- React-NativeModulesApple
2327+
- React-RCTFabric
2328+
- React-renderercss
2329+
- React-rendererdebug
2330+
- React-utils
2331+
- ReactCodegen
2332+
- ReactCommon/turbomodule/bridging
2333+
- ReactCommon/turbomodule/core
2334+
- RNWorklets/worklets/apple (= 0.3.0)
2335+
- SocketRocket
2336+
- Yoga
2337+
- RNWorklets/worklets/apple (0.3.0):
2338+
- boost
2339+
- DoubleConversion
2340+
- fast_float
2341+
- fmt
2342+
- glog
2343+
- hermes-engine
2344+
- RCT-Folly
2345+
- RCT-Folly/Fabric
2346+
- RCTRequired
2347+
- RCTTypeSafety
2348+
- React-Core
2349+
- React-debug
2350+
- React-Fabric
2351+
- React-featureflags
2352+
- React-graphics
2353+
- React-hermes
2354+
- React-ImageManager
2355+
- React-jsi
2356+
- React-NativeModulesApple
2357+
- React-RCTFabric
2358+
- React-renderercss
2359+
- React-rendererdebug
2360+
- React-utils
2361+
- ReactCodegen
2362+
- ReactCommon/turbomodule/bridging
2363+
- ReactCommon/turbomodule/core
2364+
- SocketRocket
2365+
- Yoga
21542366
- SocketRocket (0.7.1)
21552367
- Yoga (0.0.0)
21562368

@@ -2228,6 +2440,8 @@ DEPENDENCIES:
22282440
- ReactCodegen (from `build/generated/ios`)
22292441
- ReactCommon/turbomodule/core (from `../../../node_modules/react-native/ReactCommon`)
22302442
- RNGestureHandler (from `../../../node_modules/react-native-gesture-handler`)
2443+
- RNReanimated (from `../node_modules/react-native-reanimated`)
2444+
- RNWorklets (from `../../../node_modules/react-native-worklets`)
22312445
- SocketRocket (~> 0.7.1)
22322446
- Yoga (from `../../../node_modules/react-native/ReactCommon/yoga`)
22332447

@@ -2381,6 +2595,10 @@ EXTERNAL SOURCES:
23812595
:path: "../../../node_modules/react-native/ReactCommon"
23822596
RNGestureHandler:
23832597
:path: "../../../node_modules/react-native-gesture-handler"
2598+
RNReanimated:
2599+
:path: "../node_modules/react-native-reanimated"
2600+
RNWorklets:
2601+
:path: "../../../node_modules/react-native-worklets"
23842602
Yoga:
23852603
:path: "../../../node_modules/react-native/ReactCommon/yoga"
23862604

@@ -2392,7 +2610,7 @@ SPEC CHECKSUMS:
23922610
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
23932611
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
23942612
hermes-engine: 7068e976238b29e97b3bafd09a994542af7d5c0b
2395-
RCT-Folly: 59ec0ac1f2f39672a0c6e6cecdd39383b764646f
2613+
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
23962614
RCTDeprecation: ff787f6c860a1b97dd1bc27264b61d23ad1994da
23972615
RCTRequired: 664eb8399ed8a83e26ab65af7c2ad390f7e61696
23982616
RCTTypeSafety: a5cf7a7e80baf972e331dc028e5d5c19bb2535a4
@@ -2456,10 +2674,12 @@ SPEC CHECKSUMS:
24562674
ReactAppDependencyProvider: 3267432b637c9b38e86961b287f784ee1b08dde0
24572675
ReactCodegen: d82f538f70f00484d418803f74b5a0ea09cc8689
24582676
ReactCommon: b028d09a66e60ebd83ca59d8cc9a1216360db147
2459-
RNGestureHandler: 042bf47f34946da9ae3c15a8d28b2ffb22c1000d
2677+
RNGestureHandler: f867857acbb6a519c2d6651c7a8fdb7f7d2ae8f4
2678+
RNReanimated: 25060745a200605462ff56cf488411db066631ce
2679+
RNWorklets: 9bb08cb0ef718ce063f61ca18f95f57aec9b9673
24602680
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
24612681
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb
24622682

24632683
PODFILE CHECKSUM: d05778d3a61b8d49242579ea0aa864580fbb1f64
24642684

2465-
COCOAPODS: 1.16.2
2685+
COCOAPODS: 1.15.2

apps/basic-example/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"dependencies": {
2020
"react": "19.1.0",
2121
"react-native": "0.80.0",
22-
"react-native-gesture-handler": "workspace:*"
22+
"react-native-gesture-handler": "workspace:*",
23+
"react-native-reanimated": "4.0.0-beta.5",
24+
"react-native-worklets": "^0.3.0"
2325
},
2426
"devDependencies": {
2527
"@babel/core": "^7.25.2",

0 commit comments

Comments
 (0)