react-native-gtkx 0.2.0-alpha.2 → 0.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/README.md +5 -2
  2. package/dist/aliases/index.d.ts +84 -0
  3. package/dist/aliases/index.js +208 -0
  4. package/dist/aliases/index.js.map +1 -0
  5. package/dist/animated/index.d.ts +2 -0
  6. package/dist/animated/index.js +5 -0
  7. package/dist/animated/index.js.map +1 -1
  8. package/dist/animated/types.d.ts +1 -0
  9. package/dist/animated/types.js.map +1 -1
  10. package/dist/animated/value-animation.js +17 -4
  11. package/dist/animated/value-animation.js.map +1 -1
  12. package/dist/apis/host.gtkx.js +9 -12
  13. package/dist/apis/host.gtkx.js.map +1 -1
  14. package/dist/apis/index.d.ts +4 -2
  15. package/dist/apis/index.js +2 -0
  16. package/dist/apis/index.js.map +1 -1
  17. package/dist/apis/keyboard.d.ts +60 -0
  18. package/dist/apis/keyboard.js +63 -0
  19. package/dist/apis/keyboard.js.map +1 -0
  20. package/dist/apis/log-box.d.ts +15 -0
  21. package/dist/apis/log-box.js +46 -0
  22. package/dist/apis/log-box.js.map +1 -0
  23. package/dist/apis/platform.d.ts +18 -1
  24. package/dist/apis/platform.js.map +1 -1
  25. package/dist/common/index.d.ts +0 -1
  26. package/dist/common/index.js +24 -1
  27. package/dist/common/index.js.map +1 -1
  28. package/dist/components/animated.d.ts +70 -6
  29. package/dist/components/animated.js +559 -46
  30. package/dist/components/animated.js.map +1 -1
  31. package/dist/components/driven-size.d.ts +27 -0
  32. package/dist/components/driven-size.js +85 -0
  33. package/dist/components/driven-size.js.map +1 -0
  34. package/dist/components/find-node-handle.d.ts +11 -0
  35. package/dist/components/find-node-handle.js +53 -0
  36. package/dist/components/find-node-handle.js.map +1 -0
  37. package/dist/components/flat-list.d.ts +3 -2
  38. package/dist/components/flat-list.js.map +1 -1
  39. package/dist/components/frame-scheduler.d.ts +16 -0
  40. package/dist/components/frame-scheduler.js +37 -0
  41. package/dist/components/frame-scheduler.js.map +1 -0
  42. package/dist/components/image.d.ts +6 -1
  43. package/dist/components/image.js +15 -4
  44. package/dist/components/image.js.map +1 -1
  45. package/dist/components/index.d.ts +7 -5
  46. package/dist/components/index.js +5 -3
  47. package/dist/components/index.js.map +1 -1
  48. package/dist/components/measure.d.ts +51 -1
  49. package/dist/components/measure.js +101 -2
  50. package/dist/components/measure.js.map +1 -1
  51. package/dist/components/pressable.d.ts +61 -1
  52. package/dist/components/pressable.js +151 -4
  53. package/dist/components/pressable.js.map +1 -1
  54. package/dist/components/rect-store.d.ts +58 -0
  55. package/dist/components/rect-store.js +124 -3
  56. package/dist/components/rect-store.js.map +1 -1
  57. package/dist/components/root.js +6 -1
  58. package/dist/components/root.js.map +1 -1
  59. package/dist/components/scroll-phase.d.ts +35 -0
  60. package/dist/components/scroll-phase.js +26 -0
  61. package/dist/components/scroll-phase.js.map +1 -0
  62. package/dist/components/scroll-view.d.ts +39 -3
  63. package/dist/components/scroll-view.js +378 -43
  64. package/dist/components/scroll-view.js.map +1 -1
  65. package/dist/components/text-input.js +9 -25
  66. package/dist/components/text-input.js.map +1 -1
  67. package/dist/components/text.d.ts +6 -2
  68. package/dist/components/text.js +43 -8
  69. package/dist/components/text.js.map +1 -1
  70. package/dist/components/use-focus.d.ts +27 -0
  71. package/dist/components/use-focus.js +116 -0
  72. package/dist/components/use-focus.js.map +1 -0
  73. package/dist/components/use-layout-child.d.ts +13 -1
  74. package/dist/components/use-layout-child.js +188 -5
  75. package/dist/components/use-layout-child.js.map +1 -1
  76. package/dist/components/view.d.ts +5 -2
  77. package/dist/components/view.js +18 -13
  78. package/dist/components/view.js.map +1 -1
  79. package/dist/components/virtualized-list.d.ts +45 -5
  80. package/dist/components/virtualized-list.js +90 -24
  81. package/dist/components/virtualized-list.js.map +1 -1
  82. package/dist/components/wheel-scroll-session.d.ts +7 -0
  83. package/dist/components/wheel-scroll-session.js +53 -0
  84. package/dist/components/wheel-scroll-session.js.map +1 -0
  85. package/dist/components/widget-retention.d.ts +35 -0
  86. package/dist/components/widget-retention.js +169 -0
  87. package/dist/components/widget-retention.js.map +1 -0
  88. package/dist/contracts.d.ts +4 -0
  89. package/dist/contracts.js.map +1 -1
  90. package/dist/dnd/context.d.ts +69 -0
  91. package/dist/dnd/context.js +149 -0
  92. package/dist/dnd/context.js.map +1 -0
  93. package/dist/dnd/draggable.d.ts +59 -0
  94. package/dist/dnd/draggable.js +149 -0
  95. package/dist/dnd/draggable.js.map +1 -0
  96. package/dist/dnd/droppable.d.ts +24 -0
  97. package/dist/dnd/droppable.js +74 -0
  98. package/dist/dnd/droppable.js.map +1 -0
  99. package/dist/dnd/gtk-controllers.d.ts +39 -0
  100. package/dist/dnd/gtk-controllers.js +110 -0
  101. package/dist/dnd/gtk-controllers.js.map +1 -0
  102. package/dist/dnd/index.d.ts +6 -0
  103. package/dist/dnd/index.js +31 -0
  104. package/dist/dnd/index.js.map +1 -0
  105. package/dist/dnd/order.d.ts +7 -0
  106. package/dist/dnd/order.js +20 -0
  107. package/dist/dnd/order.js.map +1 -0
  108. package/dist/dnd/payload.d.ts +14 -0
  109. package/dist/dnd/payload.js +41 -0
  110. package/dist/dnd/payload.js.map +1 -0
  111. package/dist/dnd/sortable.d.ts +49 -0
  112. package/dist/dnd/sortable.js +307 -0
  113. package/dist/dnd/sortable.js.map +1 -0
  114. package/dist/dnd/types.d.ts +290 -0
  115. package/dist/dnd/types.js +25 -0
  116. package/dist/dnd/types.js.map +1 -0
  117. package/dist/gesture-handler-compat/builder.d.ts +251 -0
  118. package/dist/gesture-handler-compat/builder.js +513 -0
  119. package/dist/gesture-handler-compat/builder.js.map +1 -0
  120. package/dist/gesture-handler-compat/composition.d.ts +23 -0
  121. package/dist/gesture-handler-compat/composition.js +111 -0
  122. package/dist/gesture-handler-compat/composition.js.map +1 -0
  123. package/dist/gesture-handler-compat/deciders.d.ts +3 -0
  124. package/dist/gesture-handler-compat/deciders.js +47 -0
  125. package/dist/gesture-handler-compat/deciders.js.map +1 -0
  126. package/dist/gesture-handler-compat/detector-runtime.d.ts +44 -0
  127. package/dist/gesture-handler-compat/detector-runtime.js +374 -0
  128. package/dist/gesture-handler-compat/detector-runtime.js.map +1 -0
  129. package/dist/gesture-handler-compat/detector.d.ts +22 -0
  130. package/dist/gesture-handler-compat/detector.js +104 -0
  131. package/dist/gesture-handler-compat/detector.js.map +1 -0
  132. package/dist/gesture-handler-compat/fling.d.ts +24 -0
  133. package/dist/gesture-handler-compat/fling.js +123 -0
  134. package/dist/gesture-handler-compat/fling.js.map +1 -0
  135. package/dist/gesture-handler-compat/force-touch.d.ts +13 -0
  136. package/dist/gesture-handler-compat/force-touch.js +40 -0
  137. package/dist/gesture-handler-compat/force-touch.js.map +1 -0
  138. package/dist/gesture-handler-compat/hooks.d.ts +157 -0
  139. package/dist/gesture-handler-compat/hooks.js +268 -0
  140. package/dist/gesture-handler-compat/hooks.js.map +1 -0
  141. package/dist/gesture-handler-compat/hover.d.ts +2 -0
  142. package/dist/gesture-handler-compat/hover.js +22 -0
  143. package/dist/gesture-handler-compat/hover.js.map +1 -0
  144. package/dist/gesture-handler-compat/index.d.ts +98 -0
  145. package/dist/gesture-handler-compat/index.js +255 -0
  146. package/dist/gesture-handler-compat/index.js.map +1 -0
  147. package/dist/gesture-handler-compat/long-press.d.ts +6 -0
  148. package/dist/gesture-handler-compat/long-press.js +21 -0
  149. package/dist/gesture-handler-compat/long-press.js.map +1 -0
  150. package/dist/gesture-handler-compat/manual.d.ts +2 -0
  151. package/dist/gesture-handler-compat/manual.js +18 -0
  152. package/dist/gesture-handler-compat/manual.js.map +1 -0
  153. package/dist/gesture-handler-compat/native.d.ts +7 -0
  154. package/dist/gesture-handler-compat/native.js +34 -0
  155. package/dist/gesture-handler-compat/native.js.map +1 -0
  156. package/dist/gesture-handler-compat/orchestrator.d.ts +77 -0
  157. package/dist/gesture-handler-compat/orchestrator.js +284 -0
  158. package/dist/gesture-handler-compat/orchestrator.js.map +1 -0
  159. package/dist/gesture-handler-compat/pan.d.ts +23 -0
  160. package/dist/gesture-handler-compat/pan.js +116 -0
  161. package/dist/gesture-handler-compat/pan.js.map +1 -0
  162. package/dist/gesture-handler-compat/recognizer.d.ts +268 -0
  163. package/dist/gesture-handler-compat/recognizer.js +1056 -0
  164. package/dist/gesture-handler-compat/recognizer.js.map +1 -0
  165. package/dist/gesture-handler-compat/relations.d.ts +43 -0
  166. package/dist/gesture-handler-compat/relations.js +128 -0
  167. package/dist/gesture-handler-compat/relations.js.map +1 -0
  168. package/dist/gesture-handler-compat/tap.d.ts +6 -0
  169. package/dist/gesture-handler-compat/tap.js +29 -0
  170. package/dist/gesture-handler-compat/tap.js.map +1 -0
  171. package/dist/gesture-handler-compat/touchpad.d.ts +41 -0
  172. package/dist/gesture-handler-compat/touchpad.js +64 -0
  173. package/dist/gesture-handler-compat/touchpad.js.map +1 -0
  174. package/dist/gesture-handler-compat/types.d.ts +441 -0
  175. package/dist/gesture-handler-compat/types.js +167 -0
  176. package/dist/gesture-handler-compat/types.js.map +1 -0
  177. package/dist/gtk/controllers.d.ts +39 -0
  178. package/dist/gtk/controllers.js +92 -0
  179. package/dist/gtk/controllers.js.map +1 -0
  180. package/dist/gtk/index.d.ts +2 -1
  181. package/dist/gtk/index.js +7 -1
  182. package/dist/gtk/index.js.map +1 -1
  183. package/dist/gtkx/bridge/geometry.js +6 -4
  184. package/dist/gtkx/bridge/geometry.js.map +1 -1
  185. package/dist/gtkx/bridge/index.d.ts +5 -3
  186. package/dist/gtkx/bridge/index.js +6 -3
  187. package/dist/gtkx/bridge/index.js.map +1 -1
  188. package/dist/gtkx/bridge/slot-portal.js.map +1 -1
  189. package/dist/gtkx/bridge/use-signal.js +1 -1
  190. package/dist/gtkx/bridge/use-signal.js.map +1 -1
  191. package/dist/gtkx/bridge/view-box.d.ts +56 -0
  192. package/dist/gtkx/bridge/view-box.js +394 -9
  193. package/dist/gtkx/bridge/view-box.js.map +1 -1
  194. package/dist/gtkx/bridge/widget-css.d.ts +17 -0
  195. package/dist/gtkx/bridge/widget-css.js +72 -0
  196. package/dist/gtkx/bridge/widget-css.js.map +1 -0
  197. package/dist/index.d.ts +3 -3
  198. package/dist/index.js +2 -2
  199. package/dist/index.js.map +1 -1
  200. package/dist/layout/driven-size.d.ts +12 -0
  201. package/dist/layout/driven-size.js +70 -0
  202. package/dist/layout/driven-size.js.map +1 -0
  203. package/dist/layout/engine.d.ts +17 -1
  204. package/dist/layout/engine.js +3 -20
  205. package/dist/layout/engine.js.map +1 -1
  206. package/dist/layout/node.d.ts +13 -0
  207. package/dist/layout/node.js +14 -0
  208. package/dist/layout/node.js.map +1 -1
  209. package/dist/layout/yoga.d.ts +3 -2
  210. package/dist/layout/yoga.js +5 -2
  211. package/dist/layout/yoga.js.map +1 -1
  212. package/dist/mcp/data/generated.d.ts +257 -60
  213. package/dist/mcp/data/generated.js +306 -62
  214. package/dist/mcp/data/generated.js.map +1 -1
  215. package/dist/metro/index.d.ts +10 -0
  216. package/dist/metro/index.js +21 -12
  217. package/dist/metro/index.js.map +1 -1
  218. package/dist/navigation/sidebar.d.ts +16 -0
  219. package/dist/navigation/sidebar.js +65 -1
  220. package/dist/navigation/sidebar.js.map +1 -1
  221. package/dist/reanimated-compat/animated-ref.d.ts +32 -0
  222. package/dist/reanimated-compat/animated-ref.js +57 -0
  223. package/dist/reanimated-compat/animated-ref.js.map +1 -0
  224. package/dist/reanimated-compat/animation.d.ts +177 -0
  225. package/dist/reanimated-compat/animation.js +540 -0
  226. package/dist/reanimated-compat/animation.js.map +1 -0
  227. package/dist/reanimated-compat/color.d.ts +28 -0
  228. package/dist/reanimated-compat/color.js +249 -0
  229. package/dist/reanimated-compat/color.js.map +1 -0
  230. package/dist/reanimated-compat/decay.d.ts +39 -0
  231. package/dist/reanimated-compat/decay.js +96 -0
  232. package/dist/reanimated-compat/decay.js.map +1 -0
  233. package/dist/reanimated-compat/easing.d.ts +30 -0
  234. package/dist/reanimated-compat/easing.js +76 -0
  235. package/dist/reanimated-compat/easing.js.map +1 -0
  236. package/dist/reanimated-compat/hooks.d.ts +14 -0
  237. package/dist/reanimated-compat/hooks.js +217 -0
  238. package/dist/reanimated-compat/hooks.js.map +1 -0
  239. package/dist/reanimated-compat/index.d.ts +258 -0
  240. package/dist/reanimated-compat/index.js +464 -0
  241. package/dist/reanimated-compat/index.js.map +1 -0
  242. package/dist/reanimated-compat/interpolation.d.ts +18 -0
  243. package/dist/reanimated-compat/interpolation.js +122 -0
  244. package/dist/reanimated-compat/interpolation.js.map +1 -0
  245. package/dist/reanimated-compat/layout-animation-config.d.ts +43 -0
  246. package/dist/reanimated-compat/layout-animation-config.js +78 -0
  247. package/dist/reanimated-compat/layout-animation-config.js.map +1 -0
  248. package/dist/reanimated-compat/layout-animation-presets.d.ts +117 -0
  249. package/dist/reanimated-compat/layout-animation-presets.js +498 -0
  250. package/dist/reanimated-compat/layout-animation-presets.js.map +1 -0
  251. package/dist/reanimated-compat/layout-animation-runtime.d.ts +21 -0
  252. package/dist/reanimated-compat/layout-animation-runtime.js +311 -0
  253. package/dist/reanimated-compat/layout-animation-runtime.js.map +1 -0
  254. package/dist/reanimated-compat/layout-animation-view.d.ts +27 -0
  255. package/dist/reanimated-compat/layout-animation-view.js +266 -0
  256. package/dist/reanimated-compat/layout-animation-view.js.map +1 -0
  257. package/dist/reanimated-compat/layout-animation.d.ts +171 -0
  258. package/dist/reanimated-compat/layout-animation.js +469 -0
  259. package/dist/reanimated-compat/layout-animation.js.map +1 -0
  260. package/dist/reanimated-compat/layout-transitions.d.ts +83 -0
  261. package/dist/reanimated-compat/layout-transitions.js +350 -0
  262. package/dist/reanimated-compat/layout-transitions.js.map +1 -0
  263. package/dist/reanimated-compat/mutable.d.ts +29 -0
  264. package/dist/reanimated-compat/mutable.js +139 -0
  265. package/dist/reanimated-compat/mutable.js.map +1 -0
  266. package/dist/reanimated-compat/props.d.ts +18 -0
  267. package/dist/reanimated-compat/props.js +111 -0
  268. package/dist/reanimated-compat/props.js.map +1 -0
  269. package/dist/reanimated-compat/scroll-handler.d.ts +119 -0
  270. package/dist/reanimated-compat/scroll-handler.js +274 -0
  271. package/dist/reanimated-compat/scroll-handler.js.map +1 -0
  272. package/dist/reanimated-compat/scroll-offset.d.ts +12 -0
  273. package/dist/reanimated-compat/scroll-offset.js +104 -0
  274. package/dist/reanimated-compat/scroll-offset.js.map +1 -0
  275. package/dist/reanimated-compat/style.d.ts +90 -0
  276. package/dist/reanimated-compat/style.js +452 -0
  277. package/dist/reanimated-compat/style.js.map +1 -0
  278. package/dist/reanimated-compat/test-timers.d.ts +28 -0
  279. package/dist/reanimated-compat/test-timers.js +136 -0
  280. package/dist/reanimated-compat/test-timers.js.map +1 -0
  281. package/dist/reanimated-compat/threads.d.ts +13 -0
  282. package/dist/reanimated-compat/threads.js +41 -0
  283. package/dist/reanimated-compat/threads.js.map +1 -0
  284. package/dist/reanimated-compat/tracking.d.ts +41 -0
  285. package/dist/reanimated-compat/tracking.js +106 -0
  286. package/dist/reanimated-compat/tracking.js.map +1 -0
  287. package/dist/reanimated-compat/updater-animations.d.ts +36 -0
  288. package/dist/reanimated-compat/updater-animations.js +273 -0
  289. package/dist/reanimated-compat/updater-animations.js.map +1 -0
  290. package/dist/responder/system.d.ts +80 -7
  291. package/dist/responder/system.js +143 -23
  292. package/dist/responder/system.js.map +1 -1
  293. package/dist/responder/use-responder.d.ts +11 -0
  294. package/dist/responder/use-responder.js +225 -6
  295. package/dist/responder/use-responder.js.map +1 -1
  296. package/dist/runner/host-dev.js +1 -1
  297. package/dist/runner/host-dev.js.map +1 -1
  298. package/dist/runner/host.js +1 -1
  299. package/dist/runner/host.js.map +1 -1
  300. package/dist/runner/index.js +3 -3
  301. package/dist/runner/index.js.map +1 -1
  302. package/dist/sea/gtkx-config-module.js +1 -1
  303. package/dist/sea/gtkx-config-module.js.map +1 -1
  304. package/dist/style/absolute-insets.d.ts +26 -0
  305. package/dist/style/absolute-insets.js +113 -0
  306. package/dist/style/absolute-insets.js.map +1 -0
  307. package/dist/style/animated-size.d.ts +25 -0
  308. package/dist/style/animated-size.js +225 -0
  309. package/dist/style/animated-size.js.map +1 -0
  310. package/dist/style/colors.d.ts +17 -0
  311. package/dist/style/colors.js +25 -6
  312. package/dist/style/colors.js.map +1 -1
  313. package/dist/style/imperative-css.d.ts +21 -0
  314. package/dist/style/imperative-css.js +63 -0
  315. package/dist/style/imperative-css.js.map +1 -0
  316. package/dist/style/index.d.ts +2 -1
  317. package/dist/style/index.js +2 -1
  318. package/dist/style/index.js.map +1 -1
  319. package/dist/style/split-style.js +5 -0
  320. package/dist/style/split-style.js.map +1 -1
  321. package/dist/testing/index.js.map +1 -1
  322. package/dist/unsupported-export.d.ts +8 -0
  323. package/dist/unsupported-export.js +66 -0
  324. package/dist/unsupported-export.js.map +1 -0
  325. package/dist/vite/index.d.ts +21 -8
  326. package/dist/vite/index.js +127 -82
  327. package/dist/vite/index.js.map +1 -1
  328. package/dist/vitest/index.d.ts +2 -2
  329. package/dist/vitest/index.js.map +1 -1
  330. package/dist/worklets-compat/index.d.ts +4 -0
  331. package/dist/worklets-compat/index.js +28 -0
  332. package/dist/worklets-compat/index.js.map +1 -0
  333. package/dist/worklets-compat/surface.d.ts +110 -0
  334. package/dist/worklets-compat/surface.js +153 -0
  335. package/dist/worklets-compat/surface.js.map +1 -0
  336. package/package.json +25 -9
  337. package/types.d.ts +9 -0
  338. package/dist/common/list.d.ts +0 -82
  339. package/dist/common/list.js +0 -166
  340. package/dist/common/list.js.map +0 -1
@@ -0,0 +1,441 @@
1
+ /**
2
+ * RNGH's gesture states, as numbers, because its event payloads carry `state`
3
+ * and consumers compare it.
4
+ *
5
+ * Exported from the package entry as `State`, which is the name upstream uses
6
+ * — see ./index. The numbers are `react-native-gesture-handler` 3.1.0's own
7
+ * (`src/State.ts`) and a test pins every one of them, because a silently
8
+ * different number is the failure mode: `state === State.ACTIVE` would just
9
+ * quietly answer wrong.
10
+ */
11
+ export declare const GESTURE_STATE: {
12
+ readonly UNDETERMINED: 0;
13
+ readonly FAILED: 1;
14
+ readonly BEGAN: 2;
15
+ readonly CANCELLED: 3;
16
+ readonly ACTIVE: 4;
17
+ readonly END: 5;
18
+ };
19
+ export type GestureStateValue = (typeof GESTURE_STATE)[keyof typeof GESTURE_STATE];
20
+ /** RNGH's `TouchEventType`, for the `onTouches*` callbacks. */
21
+ export declare const TOUCH_EVENT_TYPE: {
22
+ readonly UNDETERMINED: 0;
23
+ readonly TOUCHES_DOWN: 1;
24
+ readonly TOUCHES_MOVE: 2;
25
+ readonly TOUCHES_UP: 3;
26
+ readonly TOUCHES_CANCEL: 4;
27
+ };
28
+ export type TouchEventTypeValue = (typeof TOUCH_EVENT_TYPE)[keyof typeof TOUCH_EVENT_TYPE];
29
+ /**
30
+ * RNGH's `PointerType`. Every event here is `MOUSE`: the responder system
31
+ * fabricates one touch per pointer and this platform has no touch input to
32
+ * distinguish it from (`docs/research/gestures.md` — wlroots offers no
33
+ * virtual-touch protocol, so there is nothing to test a `TOUCH` path with).
34
+ *
35
+ * `STYLUS` is the one exception and `ForceTouch` is why: a pressure reading
36
+ * only ever comes from a tablet tool, so the recognizer fed by
37
+ * `GtkGestureStylus` reports the pointer type that is actually true rather
38
+ * than the platform default.
39
+ */
40
+ export declare const POINTER_TYPE: {
41
+ readonly TOUCH: 0;
42
+ readonly STYLUS: 1;
43
+ readonly MOUSE: 2;
44
+ readonly KEY: 3;
45
+ readonly OTHER: 4;
46
+ };
47
+ /**
48
+ * RNGH's `Directions`, which `Gesture.Fling().direction()` takes.
49
+ *
50
+ * A BITMASK, and that is the whole of its API: `Directions.LEFT |
51
+ * Directions.RIGHT` is a fling that accepts either. The four numbers are
52
+ * `react-native-gesture-handler` 3.1.0's own (`src/Directions.ts`) and a test
53
+ * pins them, for the same reason `State`'s six are pinned — a silently
54
+ * different bit would go on compiling and quietly accept the wrong direction.
55
+ */
56
+ export declare const DIRECTIONS: {
57
+ readonly RIGHT: 1;
58
+ readonly LEFT: 2;
59
+ readonly UP: 4;
60
+ readonly DOWN: 8;
61
+ };
62
+ /**
63
+ * The four diagonals, which upstream keeps INTERNAL — they are not on the
64
+ * public `Directions` object and an app never names one.
65
+ *
66
+ * They are reachable all the same, and that is the point: a config of
67
+ * `UP | RIGHT` sets both bits, so `(UP_RIGHT & direction) === UP_RIGHT` holds
68
+ * and the diagonal is tested too, with a wider cone. Naming them here is what
69
+ * makes ./fling's alignment loop read like upstream's.
70
+ */
71
+ export declare const DIAGONAL_DIRECTIONS: {
72
+ readonly UP_RIGHT: 5;
73
+ readonly DOWN_RIGHT: 9;
74
+ readonly UP_LEFT: 6;
75
+ readonly DOWN_LEFT: 10;
76
+ };
77
+ /**
78
+ * RNGH's `HoverEffect` — iOS's own pointer effects, and inert everywhere else
79
+ * including in upstream's web implementation.
80
+ *
81
+ * Exported as data rather than refused because it is data: `hoverEffect` is
82
+ * referenced by upstream's TYPES and by nothing in its web handler, so an app
83
+ * that sets it is writing correct portable code that happens to do nothing
84
+ * here. That is the same call `State` got, and the opposite of the one
85
+ * `RectButton` gets — a refusal is for something that would silently not
86
+ * work, not for a value that is honestly inert.
87
+ */
88
+ export declare const HOVER_EFFECT: {
89
+ readonly NONE: 0;
90
+ readonly LIFT: 1;
91
+ readonly HIGHLIGHT: 2;
92
+ };
93
+ /**
94
+ * RNGH's `MouseButton`, a bitmask, exported as data for one narrow reason:
95
+ * `.mouseButton()` is already ACCEPTED here (and inert, as it is off Web
96
+ * upstream), so refusing the enum whose values it takes would make
97
+ * `.mouseButton(MouseButton.LEFT)` throw where `.mouseButton(1)` is fine.
98
+ * A knob and the constants it takes have to agree about whether they exist.
99
+ */
100
+ export declare const MOUSE_BUTTON: {
101
+ readonly LEFT: 1;
102
+ readonly RIGHT: 2;
103
+ readonly MIDDLE: 4;
104
+ readonly BUTTON_4: 8;
105
+ readonly BUTTON_5: 16;
106
+ readonly ALL: 31;
107
+ };
108
+ /**
109
+ * An activation or failure bound.
110
+ *
111
+ * The single-number spelling is directional, and the direction is the SIGN:
112
+ * `activeOffsetX(20)` bounds the positive side only and leaves the negative
113
+ * side unbounded, `activeOffsetX(-20)` the other way round. Reading it as a
114
+ * symmetric ±20 turns a one-way drawer into a two-way one, silently.
115
+ */
116
+ export type OffsetBound = number | readonly [number, number];
117
+ /**
118
+ * Extra area in which a press still counts, in RNGH's gesture spelling rather
119
+ * than RN's View one — and note that it can SHRINK the area, which RN's
120
+ * cannot: a negative number pulls every edge inwards.
121
+ *
122
+ * `width`/`height` anchor the box to whichever side was named:
123
+ * `{ left: 0, width: 32 }` is "the leftmost 32px", which is exactly how
124
+ * `react-native-drawer-layout` catches an edge swipe on a closed drawer.
125
+ */
126
+ export type GestureHitSlop = number | null | {
127
+ left?: number;
128
+ right?: number;
129
+ top?: number;
130
+ bottom?: number;
131
+ width?: number;
132
+ height?: number;
133
+ vertical?: number;
134
+ horizontal?: number;
135
+ };
136
+ /**
137
+ * One event payload, carrying the union of what both spellings read.
138
+ *
139
+ * The legacy spelling's `GestureUpdateEvent`/`GestureStateChangeEvent` and
140
+ * the hook spelling's `GestureEvent`/`GestureEndEvent` are subsets of this,
141
+ * so the recognizer builds it once and each facade hands it over as-is. The
142
+ * extra fields a given spelling does not document are harmless; inventing a
143
+ * second payload so each could be exactly minimal would be two things to keep
144
+ * correct instead of one.
145
+ */
146
+ export type GestureEventPayload = {
147
+ handlerTag: number;
148
+ numberOfPointers: number;
149
+ pointerType: (typeof POINTER_TYPE)[keyof typeof POINTER_TYPE];
150
+ state: GestureStateValue;
151
+ /** Only meaningful on the state-change callbacks; the legacy spelling reads it. */
152
+ oldState: GestureStateValue;
153
+ /** Relative to the GESTURE's view, not to whatever widget carried the event. */
154
+ x: number;
155
+ y: number;
156
+ /** Window coordinates — RN's `pageX`/`pageY`. */
157
+ absoluteX: number;
158
+ absoluteY: number;
159
+ /** Measured from the point of ACTIVATION, not from the press. */
160
+ translationX: number;
161
+ translationY: number;
162
+ velocityX: number;
163
+ velocityY: number;
164
+ /** Delta of TRANSLATION since the previous update; equal to it on the first. */
165
+ changeX: number;
166
+ changeY: number;
167
+ /**
168
+ * `Pinch`: the scale relative to the start of the gesture, so 1 at the
169
+ * start and above 1 for a spread. Upstream's `PinchGestureHandlerEventPayload`
170
+ * field, with upstream's cumulative-and-multiplicative meaning. 1 for every
171
+ * other kind, which is the identity a consumer would multiply by anyway.
172
+ */
173
+ scale: number;
174
+ /**
175
+ * `Pinch`: the ratio between this update's `scale` and the previous one's —
176
+ * upstream's `scaleChange`, which is a RATIO where `changeX` is a
177
+ * difference, because scale composes by multiplication. On the first update
178
+ * it is the `scale` itself, exactly as upstream's `changeEventCalculator`
179
+ * returns `current.scale` when there is no previous event.
180
+ */
181
+ scaleChange: number;
182
+ /** `Pinch`: the gesture's focal point, in the gesture VIEW's coordinates. */
183
+ focalX: number;
184
+ focalY: number;
185
+ /**
186
+ * `Rotation`: radians since the start of the gesture, positive CLOCKWISE.
187
+ * Upstream's `RotationGestureHandlerEventPayload` field, same units and
188
+ * same sign. 0 for every other kind.
189
+ */
190
+ rotation: number;
191
+ /** `Rotation`: the difference in radians since the previous update. */
192
+ rotationChange: number;
193
+ /** `Rotation`: the point rotated about, in the gesture VIEW's coordinates. */
194
+ anchorX: number;
195
+ anchorY: number;
196
+ /**
197
+ * `Pinch`: scale change per SECOND. `Rotation`: radians per second.
198
+ *
199
+ * Upstream calls both of these `velocity` and documents both as per-second,
200
+ * and neither of its web implementations is: `PinchGestureHandler` divides
201
+ * by a millisecond `timeDelta` and never by 1000, and
202
+ * `RotationGestureDetector.timeDelta` returns `currentTime + previousTime`
203
+ * — an ADDITION, which makes the denominator roughly twice a page-lifetime
204
+ * timestamp and the result meaningless rather than merely mis-scaled.
205
+ * Android's `PinchGestureHandler` uses `timeDeltaSeconds` and agrees with
206
+ * the documentation.
207
+ *
208
+ * So there is no single upstream number to reproduce, and this is the same
209
+ * call `hitSlopRect` already makes about a plain-number `hitSlop`: where the
210
+ * web path contradicts both the documentation and upstream's own native
211
+ * path, follow the documentation and say so. Per second, in both.
212
+ */
213
+ velocity: number;
214
+ /**
215
+ * `ForceTouch`: the pressure, normalised to upstream's documented `[0, 1]`.
216
+ *
217
+ * 0 for every other kind, which is what an input with no pressure axis
218
+ * reports and therefore the only honest filler. See ./force-touch for where
219
+ * the number comes from and what it costs to produce one.
220
+ */
221
+ force: number;
222
+ /** `ForceTouch`: the difference since the previous update; the force itself on the first. */
223
+ forceChange: number;
224
+ /**
225
+ * Milliseconds since the press that started this gesture.
226
+ *
227
+ * Upstream carries it on `LongPress` alone, where it is the point of the
228
+ * gesture. It is filled in for every kind here for the same reason the rest
229
+ * of this payload is a union: one payload built once beats three that each
230
+ * have to stay correct, and a field a spelling does not document is
231
+ * harmless where a missing one is not.
232
+ */
233
+ duration: number;
234
+ };
235
+ /** The ending payload the hook spelling reads, which says `canceled` instead. */
236
+ export type GestureEndEventPayload = GestureEventPayload & {
237
+ canceled: boolean;
238
+ };
239
+ /** One pointer, as the `onTouches*` callbacks see it. */
240
+ export type GestureTouchData = {
241
+ id: number;
242
+ x: number;
243
+ y: number;
244
+ absoluteX: number;
245
+ absoluteY: number;
246
+ };
247
+ export type GestureTouchEvent = {
248
+ handlerTag: number;
249
+ numberOfTouches: number;
250
+ eventType: TouchEventTypeValue;
251
+ allTouches: GestureTouchData[];
252
+ changedTouches: GestureTouchData[];
253
+ state: GestureStateValue;
254
+ pointerType: (typeof POINTER_TYPE)[keyof typeof POINTER_TYPE];
255
+ };
256
+ /**
257
+ * The imperative handle handed to `onTouches*` by the legacy spelling.
258
+ *
259
+ * `activate()` from here is a second reason the responder system grew an
260
+ * out-of-event grant channel: a callback that decides mid-press to take the
261
+ * gesture is in exactly the position `activateAfterLongPress`'s timer is in.
262
+ */
263
+ export type GestureStateManagerApi = {
264
+ begin: () => void;
265
+ activate: () => void;
266
+ fail: () => void;
267
+ end: () => void;
268
+ };
269
+ /**
270
+ * The internal callback set, in the hook spelling's names. Both facades
271
+ * normalise onto this; the recognizer knows no other names.
272
+ */
273
+ export type RecognizerCallbacks = {
274
+ onBegin?: (event: GestureEventPayload) => void;
275
+ onActivate?: (event: GestureEventPayload) => void;
276
+ onUpdate?: (event: GestureEventPayload) => void;
277
+ onChange?: (event: GestureEventPayload) => void;
278
+ onDeactivate?: (event: GestureEventPayload, success: boolean) => void;
279
+ onFinalize?: (event: GestureEventPayload, success: boolean) => void;
280
+ onTouchesDown?: (event: GestureTouchEvent, manager: GestureStateManagerApi) => void;
281
+ onTouchesMove?: (event: GestureTouchEvent, manager: GestureStateManagerApi) => void;
282
+ onTouchesUp?: (event: GestureTouchEvent, manager: GestureStateManagerApi) => void;
283
+ onTouchesCancel?: (event: GestureTouchEvent, manager: GestureStateManagerApi) => void;
284
+ };
285
+ /**
286
+ * How one gesture names another in a relation.
287
+ *
288
+ * Upstream's `GestureRef`, in all three of its spellings: the other gesture
289
+ * itself, a ref built with `withRef()` holding it, or a raw handler tag. A
290
+ * composed gesture stands for every gesture inside it.
291
+ *
292
+ * The reference is deliberately not a tag: a tag identifies a MOUNTED
293
+ * gesture, and an app writes its relations against gesture objects it built
294
+ * itself, often before either end is mounted. ./relations resolves the two.
295
+ */
296
+ export type GestureRef = AnyGestureSpec | {
297
+ current: unknown;
298
+ } | number;
299
+ /** The three relation maps, as one gesture's share of them. */
300
+ export type GestureRelations = {
301
+ waitFor: readonly GestureRef[];
302
+ simultaneousHandlers: readonly GestureRef[];
303
+ blocksHandlers: readonly GestureRef[];
304
+ };
305
+ /** Everything every spelling of every kind configures, normalised. */
306
+ export type RecognizerConfig = RecognizerCallbacks & {
307
+ waitFor?: readonly GestureRef[];
308
+ simultaneousHandlers?: readonly GestureRef[];
309
+ blocksHandlers?: readonly GestureRef[];
310
+ enabled?: boolean;
311
+ hitSlop?: GestureHitSlop;
312
+ shouldCancelWhenOutside?: boolean;
313
+ minPointers?: number;
314
+ maxPointers?: number;
315
+ /** Only the `onTouches*` state manager may activate the gesture. */
316
+ manualActivation?: boolean;
317
+ activeOffsetX?: OffsetBound;
318
+ activeOffsetY?: OffsetBound;
319
+ failOffsetX?: OffsetBound;
320
+ failOffsetY?: OffsetBound;
321
+ minDistance?: number;
322
+ minVelocity?: number;
323
+ minVelocityX?: number;
324
+ minVelocityY?: number;
325
+ activateAfterLongPress?: number;
326
+ /** Presses required before the tap activates. Upstream's default is 1. */
327
+ numberOfTaps?: number;
328
+ /** How fast the pointer must come back up. Upstream's default is 500ms. */
329
+ maxDuration?: number;
330
+ /** How long the next tap may take to arrive. Upstream's default is 500ms. */
331
+ maxDelay?: number;
332
+ maxDeltaX?: number;
333
+ maxDeltaY?: number;
334
+ /**
335
+ * Take the gesture the instant the pointer goes down, instead of waiting
336
+ * for the wrapped view to start handling it. Upstream's spelling for a
337
+ * native view that is a BUTTON rather than a scrollable.
338
+ */
339
+ shouldActivateOnStart?: boolean;
340
+ /**
341
+ * Upstream: an active `Native` handler that disallows interruption cannot
342
+ * be cancelled by anything else. Recorded and read by nothing yet — it is a
343
+ * statement about ARBITRATION, and the registry that arbitrates is the
344
+ * orchestrator's. Storing it is what lets that registry find it later;
345
+ * refusing it would refuse `@gorhom/bottom-sheet`'s own configuration for a
346
+ * knob whose only effect is on a relation it also sets explicitly.
347
+ */
348
+ disallowInterruption?: boolean;
349
+ /** Upstream's companion to `disallowInterruption`, same treatment. */
350
+ yieldsToContinuousGestures?: boolean;
351
+ /** How long the pointer must stay down. Upstream's default is 500ms. */
352
+ minDuration?: number;
353
+ /**
354
+ * Exactly this many pointers. Upstream's spelling for LongPress and for
355
+ * Fling, and EXACT in both: `Fling` compares it against the most pointers
356
+ * the interaction ever had at once, and refuses a mismatch either way.
357
+ */
358
+ numberOfPointers?: number;
359
+ /**
360
+ * A BITMASK of `Directions`, defaulting to `Directions.RIGHT`. Several
361
+ * directions are one value: `Directions.LEFT | Directions.RIGHT`.
362
+ */
363
+ direction?: number;
364
+ /**
365
+ * iOS's own pointer effect. Recorded and inert, exactly as it is inert in
366
+ * upstream's web implementation — nothing there branches on it either.
367
+ */
368
+ hoverEffect?: number;
369
+ /** Pressure below which the gesture will not activate. Upstream documents 0.2. */
370
+ minForce?: number;
371
+ /** Pressure above which the gesture FAILS. Unset means no ceiling. */
372
+ maxForce?: number;
373
+ /**
374
+ * Haptic feedback on activation. Recorded and inert: there is no haptic
375
+ * device on this platform and upstream implements it in iOS code only.
376
+ */
377
+ feedbackOnActivation?: boolean;
378
+ /**
379
+ * How far the pointer may travel and still count. Upstream defaults it to
380
+ * 10 for `LongPress` and leaves it UNSET for `Tap` — a tap that drags 200px
381
+ * inside the view and lifts in time is still a tap there, which reads like
382
+ * an oversight and is reproduced because guessing a default would silently
383
+ * refuse taps upstream accepts.
384
+ */
385
+ maxDistance?: number;
386
+ runOnJS?: boolean;
387
+ averageTouches?: boolean;
388
+ enableTrackpadTwoFingerGesture?: boolean;
389
+ cancelsTouchesInView?: boolean;
390
+ activeCursor?: string;
391
+ mouseButton?: number;
392
+ testId?: string;
393
+ };
394
+ /**
395
+ * Which predicates the shared machine runs. Spelled as upstream's
396
+ * `SingleGestureName` reads, minus the `GestureHandler` suffix.
397
+ */
398
+ export type GestureKind = "pan" | "tap" | "longPress" | "native" | "pinch" | "rotation" | "fling" | "manual" | "hover" | "forceTouch";
399
+ /**
400
+ * What a `GestureDetector` consumes. Both spellings produce exactly this.
401
+ *
402
+ * No `handlerTag`: a tag identifies a MOUNTED gesture, and both spellings
403
+ * rebuild their object on every render (upstream's do too — the builder is
404
+ * called in the component body, the hook returns a fresh config). The
405
+ * detector mints one stable tag for as long as it is mounted, which is the
406
+ * identity that means something.
407
+ */
408
+ export type GestureSpec = {
409
+ readonly kind: GestureKind;
410
+ readonly config: RecognizerConfig;
411
+ };
412
+ /** Which of the three ways a group of gestures was put together. */
413
+ export type ComposedGestureKind = "race" | "simultaneous" | "exclusive";
414
+ /**
415
+ * What `Gesture.Race()`, `Gesture.Simultaneous()` and `Gesture.Exclusive()`
416
+ * produce — a LIST and a label, with no mechanism in it.
417
+ *
418
+ * The composers are list-builders over the three relation maps and nothing
419
+ * else: `Race` adds no relation at all because racing IS the default,
420
+ * `Simultaneous` is a pairwise fill of `simultaneousHandlers`, and
421
+ * `Exclusive` is a chain fill of `waitFor` where every group waits for all
422
+ * the groups before it. See ./composition, which is where that is spelled
423
+ * out, and note there is no third state and no second arbitration path.
424
+ */
425
+ export type ComposedGestureSpec = {
426
+ readonly composed: ComposedGestureKind;
427
+ readonly gestures: readonly AnyGestureSpec[];
428
+ /** Upstream's flattening hook: every single gesture, composition removed. */
429
+ toGestureArray: () => GestureSpec[];
430
+ };
431
+ /** What a `GestureDetector` accepts: one gesture, or a composition of them. */
432
+ export type AnyGestureSpec = GestureSpec | ComposedGestureSpec;
433
+ /** RNGH's `handlerTag`: an identity for one mounted gesture. */
434
+ export declare const mintHandlerTag: () => number;
435
+ /** Whether a value is one recognizer rather than a composition of them. */
436
+ export declare const isGestureSpec: (value: unknown) => value is GestureSpec;
437
+ export declare const isComposedGestureSpec: (value: unknown) => value is ComposedGestureSpec;
438
+ /** Whether a value is something a `GestureDetector` can drive. */
439
+ export declare const isAnyGestureSpec: (value: unknown) => value is AnyGestureSpec;
440
+ /** Every single gesture in a composition, in the order they were written. */
441
+ export declare const flattenGestures: (gesture: AnyGestureSpec) => GestureSpec[];
@@ -0,0 +1,167 @@
1
+ // The internal shape of a gesture, and the vocabulary its callbacks speak.
2
+ //
3
+ // THIS is the implementation. `Gesture.Pan()` and `usePanGesture()` are two
4
+ // spellings that both produce a `GestureSpec` and nothing else, which is the
5
+ // one architectural decision this module is not free to get wrong: upstream
6
+ // deprecated all twelve `Gesture.*` statics in 3.1.0 in favour of a hook tree
7
+ // and had to rewrite the internals because the builder WAS the internals.
8
+ //
9
+ // One config type covers all three recognizers rather than one per kind, and
10
+ // that is the same call: `Tap` and `LongPress` are the same state machine as
11
+ // `Pan` with different predicates, so what tells them apart is which fields a
12
+ // decider READS, not which fields exist. A per-kind config would have to be
13
+ // narrowed at every point the machine touches it, for no behaviour.
14
+ //
15
+ // The two spellings are not cosmetic variants of each other, and that is the
16
+ // reason this middle layer earns its keep. Upstream's hook renamed `onStart`
17
+ // to `onActivate` and `onEnd` to `onDeactivate`, dropped `onChange`, renamed
18
+ // `onTouchesCancelled` to `onTouchesCancel`, and replaced the
19
+ // `(event, success)` ending signature with a `canceled` field on the event.
20
+ // Neither naming is privileged here: the internal callbacks use the newer
21
+ // names because that is the shape upstream is migrating towards, and both
22
+ // public spellings adapt onto them.
23
+ //
24
+ // Config is plain data on purpose. A builder that accumulated behaviour
25
+ // rather than values would make the hook spelling a reimplementation instead
26
+ // of a second constructor, and would leave nothing for the orchestrator
27
+ // (slice 3) to read.
28
+ /**
29
+ * RNGH's gesture states, as numbers, because its event payloads carry `state`
30
+ * and consumers compare it.
31
+ *
32
+ * Exported from the package entry as `State`, which is the name upstream uses
33
+ * — see ./index. The numbers are `react-native-gesture-handler` 3.1.0's own
34
+ * (`src/State.ts`) and a test pins every one of them, because a silently
35
+ * different number is the failure mode: `state === State.ACTIVE` would just
36
+ * quietly answer wrong.
37
+ */
38
+ export const GESTURE_STATE = {
39
+ UNDETERMINED: 0,
40
+ FAILED: 1,
41
+ BEGAN: 2,
42
+ CANCELLED: 3,
43
+ ACTIVE: 4,
44
+ END: 5,
45
+ };
46
+ /** RNGH's `TouchEventType`, for the `onTouches*` callbacks. */
47
+ export const TOUCH_EVENT_TYPE = {
48
+ UNDETERMINED: 0,
49
+ TOUCHES_DOWN: 1,
50
+ TOUCHES_MOVE: 2,
51
+ TOUCHES_UP: 3,
52
+ TOUCHES_CANCEL: 4,
53
+ };
54
+ /**
55
+ * RNGH's `PointerType`. Every event here is `MOUSE`: the responder system
56
+ * fabricates one touch per pointer and this platform has no touch input to
57
+ * distinguish it from (`docs/research/gestures.md` — wlroots offers no
58
+ * virtual-touch protocol, so there is nothing to test a `TOUCH` path with).
59
+ *
60
+ * `STYLUS` is the one exception and `ForceTouch` is why: a pressure reading
61
+ * only ever comes from a tablet tool, so the recognizer fed by
62
+ * `GtkGestureStylus` reports the pointer type that is actually true rather
63
+ * than the platform default.
64
+ */
65
+ export const POINTER_TYPE = {
66
+ TOUCH: 0,
67
+ STYLUS: 1,
68
+ MOUSE: 2,
69
+ KEY: 3,
70
+ OTHER: 4,
71
+ };
72
+ /**
73
+ * RNGH's `Directions`, which `Gesture.Fling().direction()` takes.
74
+ *
75
+ * A BITMASK, and that is the whole of its API: `Directions.LEFT |
76
+ * Directions.RIGHT` is a fling that accepts either. The four numbers are
77
+ * `react-native-gesture-handler` 3.1.0's own (`src/Directions.ts`) and a test
78
+ * pins them, for the same reason `State`'s six are pinned — a silently
79
+ * different bit would go on compiling and quietly accept the wrong direction.
80
+ */
81
+ export const DIRECTIONS = {
82
+ RIGHT: 1,
83
+ LEFT: 2,
84
+ UP: 4,
85
+ DOWN: 8,
86
+ };
87
+ /**
88
+ * The four diagonals, which upstream keeps INTERNAL — they are not on the
89
+ * public `Directions` object and an app never names one.
90
+ *
91
+ * They are reachable all the same, and that is the point: a config of
92
+ * `UP | RIGHT` sets both bits, so `(UP_RIGHT & direction) === UP_RIGHT` holds
93
+ * and the diagonal is tested too, with a wider cone. Naming them here is what
94
+ * makes ./fling's alignment loop read like upstream's.
95
+ */
96
+ export const DIAGONAL_DIRECTIONS = {
97
+ UP_RIGHT: 5,
98
+ DOWN_RIGHT: 9,
99
+ UP_LEFT: 6,
100
+ DOWN_LEFT: 10,
101
+ };
102
+ /**
103
+ * RNGH's `HoverEffect` — iOS's own pointer effects, and inert everywhere else
104
+ * including in upstream's web implementation.
105
+ *
106
+ * Exported as data rather than refused because it is data: `hoverEffect` is
107
+ * referenced by upstream's TYPES and by nothing in its web handler, so an app
108
+ * that sets it is writing correct portable code that happens to do nothing
109
+ * here. That is the same call `State` got, and the opposite of the one
110
+ * `RectButton` gets — a refusal is for something that would silently not
111
+ * work, not for a value that is honestly inert.
112
+ */
113
+ export const HOVER_EFFECT = {
114
+ NONE: 0,
115
+ LIFT: 1,
116
+ HIGHLIGHT: 2,
117
+ };
118
+ /**
119
+ * RNGH's `MouseButton`, a bitmask, exported as data for one narrow reason:
120
+ * `.mouseButton()` is already ACCEPTED here (and inert, as it is off Web
121
+ * upstream), so refusing the enum whose values it takes would make
122
+ * `.mouseButton(MouseButton.LEFT)` throw where `.mouseButton(1)` is fine.
123
+ * A knob and the constants it takes have to agree about whether they exist.
124
+ */
125
+ export const MOUSE_BUTTON = {
126
+ LEFT: 1,
127
+ RIGHT: 2,
128
+ MIDDLE: 4,
129
+ BUTTON_4: 8,
130
+ BUTTON_5: 16,
131
+ ALL: 31,
132
+ };
133
+ const KINDS = new Set([
134
+ "pan",
135
+ "tap",
136
+ "longPress",
137
+ "native",
138
+ "pinch",
139
+ "rotation",
140
+ "fling",
141
+ "manual",
142
+ "hover",
143
+ "forceTouch",
144
+ ]);
145
+ let nextHandlerTag = 1;
146
+ /** RNGH's `handlerTag`: an identity for one mounted gesture. */
147
+ export const mintHandlerTag = () => {
148
+ const tag = nextHandlerTag;
149
+ nextHandlerTag += 1;
150
+ return tag;
151
+ };
152
+ /** Whether a value is one recognizer rather than a composition of them. */
153
+ export const isGestureSpec = (value) => typeof value === "object" &&
154
+ value !== null &&
155
+ KINDS.has(value.kind) &&
156
+ typeof value.config === "object";
157
+ export const isComposedGestureSpec = (value) => typeof value === "object" &&
158
+ value !== null &&
159
+ Array.isArray(value.gestures) &&
160
+ typeof value.composed === "string";
161
+ /** Whether a value is something a `GestureDetector` can drive. */
162
+ export const isAnyGestureSpec = (value) => isGestureSpec(value) || isComposedGestureSpec(value);
163
+ /** Every single gesture in a composition, in the order they were written. */
164
+ export const flattenGestures = (gesture) => isComposedGestureSpec(gesture)
165
+ ? gesture.gestures.flatMap(flattenGestures)
166
+ : [gesture];
167
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/gesture-handler-compat/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,oEAAoE;AACpE,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,8DAA8D;AAC9D,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,oCAAoC;AACpC,EAAE;AACF,wEAAwE;AACxE,6EAA6E;AAC7E,wEAAwE;AACxE,qBAAqB;AAErB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,CAAC;IACf,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;CACE,CAAA;AAKV,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,cAAc,EAAE,CAAC;CACT,CAAA;AAKV;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;CACA,CAAA;AAEV;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,EAAE,EAAE,CAAC;IACL,IAAI,EAAE,CAAC;CACC,CAAA;AAEV;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,EAAE;CACL,CAAA;AAEV;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,SAAS,EAAE,CAAC;CACJ,CAAA;AAEV;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,EAAE;IACZ,GAAG,EAAE,EAAE;CACC,CAAA;AAwWV,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS;IAC5B,KAAK;IACL,KAAK;IACL,WAAW;IACX,QAAQ;IACR,OAAO;IACP,UAAU;IACV,OAAO;IACP,QAAQ;IACR,OAAO;IACP,YAAY;CACb,CAAC,CAAA;AAwCF,IAAI,cAAc,GAAG,CAAC,CAAA;AAEtB,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE;IACzC,MAAM,GAAG,GAAG,cAAc,CAAA;IAC1B,cAAc,IAAI,CAAC,CAAA;IACnB,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,KAAK,CAAC,GAAG,CAAE,KAAqB,CAAC,IAAI,CAAC;IACtC,OAAQ,KAAqB,CAAC,MAAM,KAAK,QAAQ,CAAA;AAEnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,KAAc,EACgB,EAAE,CAChC,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,KAAK,CAAC,OAAO,CAAE,KAA6B,CAAC,QAAQ,CAAC;IACtD,OAAQ,KAA6B,CAAC,QAAQ,KAAK,QAAQ,CAAA;AAE7D,kEAAkE;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA2B,EAAE,CAC1E,aAAa,CAAC,KAAK,CAAC,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAA;AAEtD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAuB,EAAiB,EAAE,CACxE,qBAAqB,CAAC,OAAO,CAAC;IAC5B,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC;IAC3C,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["// The internal shape of a gesture, and the vocabulary its callbacks speak.\n//\n// THIS is the implementation. `Gesture.Pan()` and `usePanGesture()` are two\n// spellings that both produce a `GestureSpec` and nothing else, which is the\n// one architectural decision this module is not free to get wrong: upstream\n// deprecated all twelve `Gesture.*` statics in 3.1.0 in favour of a hook tree\n// and had to rewrite the internals because the builder WAS the internals.\n//\n// One config type covers all three recognizers rather than one per kind, and\n// that is the same call: `Tap` and `LongPress` are the same state machine as\n// `Pan` with different predicates, so what tells them apart is which fields a\n// decider READS, not which fields exist. A per-kind config would have to be\n// narrowed at every point the machine touches it, for no behaviour.\n//\n// The two spellings are not cosmetic variants of each other, and that is the\n// reason this middle layer earns its keep. Upstream's hook renamed `onStart`\n// to `onActivate` and `onEnd` to `onDeactivate`, dropped `onChange`, renamed\n// `onTouchesCancelled` to `onTouchesCancel`, and replaced the\n// `(event, success)` ending signature with a `canceled` field on the event.\n// Neither naming is privileged here: the internal callbacks use the newer\n// names because that is the shape upstream is migrating towards, and both\n// public spellings adapt onto them.\n//\n// Config is plain data on purpose. A builder that accumulated behaviour\n// rather than values would make the hook spelling a reimplementation instead\n// of a second constructor, and would leave nothing for the orchestrator\n// (slice 3) to read.\n\n/**\n * RNGH's gesture states, as numbers, because its event payloads carry `state`\n * and consumers compare it.\n *\n * Exported from the package entry as `State`, which is the name upstream uses\n * — see ./index. The numbers are `react-native-gesture-handler` 3.1.0's own\n * (`src/State.ts`) and a test pins every one of them, because a silently\n * different number is the failure mode: `state === State.ACTIVE` would just\n * quietly answer wrong.\n */\nexport const GESTURE_STATE = {\n UNDETERMINED: 0,\n FAILED: 1,\n BEGAN: 2,\n CANCELLED: 3,\n ACTIVE: 4,\n END: 5,\n} as const\n\nexport type GestureStateValue =\n (typeof GESTURE_STATE)[keyof typeof GESTURE_STATE]\n\n/** RNGH's `TouchEventType`, for the `onTouches*` callbacks. */\nexport const TOUCH_EVENT_TYPE = {\n UNDETERMINED: 0,\n TOUCHES_DOWN: 1,\n TOUCHES_MOVE: 2,\n TOUCHES_UP: 3,\n TOUCHES_CANCEL: 4,\n} as const\n\nexport type TouchEventTypeValue =\n (typeof TOUCH_EVENT_TYPE)[keyof typeof TOUCH_EVENT_TYPE]\n\n/**\n * RNGH's `PointerType`. Every event here is `MOUSE`: the responder system\n * fabricates one touch per pointer and this platform has no touch input to\n * distinguish it from (`docs/research/gestures.md` — wlroots offers no\n * virtual-touch protocol, so there is nothing to test a `TOUCH` path with).\n *\n * `STYLUS` is the one exception and `ForceTouch` is why: a pressure reading\n * only ever comes from a tablet tool, so the recognizer fed by\n * `GtkGestureStylus` reports the pointer type that is actually true rather\n * than the platform default.\n */\nexport const POINTER_TYPE = {\n TOUCH: 0,\n STYLUS: 1,\n MOUSE: 2,\n KEY: 3,\n OTHER: 4,\n} as const\n\n/**\n * RNGH's `Directions`, which `Gesture.Fling().direction()` takes.\n *\n * A BITMASK, and that is the whole of its API: `Directions.LEFT |\n * Directions.RIGHT` is a fling that accepts either. The four numbers are\n * `react-native-gesture-handler` 3.1.0's own (`src/Directions.ts`) and a test\n * pins them, for the same reason `State`'s six are pinned — a silently\n * different bit would go on compiling and quietly accept the wrong direction.\n */\nexport const DIRECTIONS = {\n RIGHT: 1,\n LEFT: 2,\n UP: 4,\n DOWN: 8,\n} as const\n\n/**\n * The four diagonals, which upstream keeps INTERNAL — they are not on the\n * public `Directions` object and an app never names one.\n *\n * They are reachable all the same, and that is the point: a config of\n * `UP | RIGHT` sets both bits, so `(UP_RIGHT & direction) === UP_RIGHT` holds\n * and the diagonal is tested too, with a wider cone. Naming them here is what\n * makes ./fling's alignment loop read like upstream's.\n */\nexport const DIAGONAL_DIRECTIONS = {\n UP_RIGHT: 5,\n DOWN_RIGHT: 9,\n UP_LEFT: 6,\n DOWN_LEFT: 10,\n} as const\n\n/**\n * RNGH's `HoverEffect` — iOS's own pointer effects, and inert everywhere else\n * including in upstream's web implementation.\n *\n * Exported as data rather than refused because it is data: `hoverEffect` is\n * referenced by upstream's TYPES and by nothing in its web handler, so an app\n * that sets it is writing correct portable code that happens to do nothing\n * here. That is the same call `State` got, and the opposite of the one\n * `RectButton` gets — a refusal is for something that would silently not\n * work, not for a value that is honestly inert.\n */\nexport const HOVER_EFFECT = {\n NONE: 0,\n LIFT: 1,\n HIGHLIGHT: 2,\n} as const\n\n/**\n * RNGH's `MouseButton`, a bitmask, exported as data for one narrow reason:\n * `.mouseButton()` is already ACCEPTED here (and inert, as it is off Web\n * upstream), so refusing the enum whose values it takes would make\n * `.mouseButton(MouseButton.LEFT)` throw where `.mouseButton(1)` is fine.\n * A knob and the constants it takes have to agree about whether they exist.\n */\nexport const MOUSE_BUTTON = {\n LEFT: 1,\n RIGHT: 2,\n MIDDLE: 4,\n BUTTON_4: 8,\n BUTTON_5: 16,\n ALL: 31,\n} as const\n\n/**\n * An activation or failure bound.\n *\n * The single-number spelling is directional, and the direction is the SIGN:\n * `activeOffsetX(20)` bounds the positive side only and leaves the negative\n * side unbounded, `activeOffsetX(-20)` the other way round. Reading it as a\n * symmetric ±20 turns a one-way drawer into a two-way one, silently.\n */\nexport type OffsetBound = number | readonly [number, number]\n\n/**\n * Extra area in which a press still counts, in RNGH's gesture spelling rather\n * than RN's View one — and note that it can SHRINK the area, which RN's\n * cannot: a negative number pulls every edge inwards.\n *\n * `width`/`height` anchor the box to whichever side was named:\n * `{ left: 0, width: 32 }` is \"the leftmost 32px\", which is exactly how\n * `react-native-drawer-layout` catches an edge swipe on a closed drawer.\n */\nexport type GestureHitSlop =\n | number\n | null\n | {\n left?: number\n right?: number\n top?: number\n bottom?: number\n width?: number\n height?: number\n vertical?: number\n horizontal?: number\n }\n\n/**\n * One event payload, carrying the union of what both spellings read.\n *\n * The legacy spelling's `GestureUpdateEvent`/`GestureStateChangeEvent` and\n * the hook spelling's `GestureEvent`/`GestureEndEvent` are subsets of this,\n * so the recognizer builds it once and each facade hands it over as-is. The\n * extra fields a given spelling does not document are harmless; inventing a\n * second payload so each could be exactly minimal would be two things to keep\n * correct instead of one.\n */\nexport type GestureEventPayload = {\n handlerTag: number\n numberOfPointers: number\n pointerType: (typeof POINTER_TYPE)[keyof typeof POINTER_TYPE]\n state: GestureStateValue\n /** Only meaningful on the state-change callbacks; the legacy spelling reads it. */\n oldState: GestureStateValue\n /** Relative to the GESTURE's view, not to whatever widget carried the event. */\n x: number\n y: number\n /** Window coordinates — RN's `pageX`/`pageY`. */\n absoluteX: number\n absoluteY: number\n /** Measured from the point of ACTIVATION, not from the press. */\n translationX: number\n translationY: number\n velocityX: number\n velocityY: number\n /** Delta of TRANSLATION since the previous update; equal to it on the first. */\n changeX: number\n changeY: number\n /**\n * `Pinch`: the scale relative to the start of the gesture, so 1 at the\n * start and above 1 for a spread. Upstream's `PinchGestureHandlerEventPayload`\n * field, with upstream's cumulative-and-multiplicative meaning. 1 for every\n * other kind, which is the identity a consumer would multiply by anyway.\n */\n scale: number\n /**\n * `Pinch`: the ratio between this update's `scale` and the previous one's —\n * upstream's `scaleChange`, which is a RATIO where `changeX` is a\n * difference, because scale composes by multiplication. On the first update\n * it is the `scale` itself, exactly as upstream's `changeEventCalculator`\n * returns `current.scale` when there is no previous event.\n */\n scaleChange: number\n /** `Pinch`: the gesture's focal point, in the gesture VIEW's coordinates. */\n focalX: number\n focalY: number\n /**\n * `Rotation`: radians since the start of the gesture, positive CLOCKWISE.\n * Upstream's `RotationGestureHandlerEventPayload` field, same units and\n * same sign. 0 for every other kind.\n */\n rotation: number\n /** `Rotation`: the difference in radians since the previous update. */\n rotationChange: number\n /** `Rotation`: the point rotated about, in the gesture VIEW's coordinates. */\n anchorX: number\n anchorY: number\n /**\n * `Pinch`: scale change per SECOND. `Rotation`: radians per second.\n *\n * Upstream calls both of these `velocity` and documents both as per-second,\n * and neither of its web implementations is: `PinchGestureHandler` divides\n * by a millisecond `timeDelta` and never by 1000, and\n * `RotationGestureDetector.timeDelta` returns `currentTime + previousTime`\n * — an ADDITION, which makes the denominator roughly twice a page-lifetime\n * timestamp and the result meaningless rather than merely mis-scaled.\n * Android's `PinchGestureHandler` uses `timeDeltaSeconds` and agrees with\n * the documentation.\n *\n * So there is no single upstream number to reproduce, and this is the same\n * call `hitSlopRect` already makes about a plain-number `hitSlop`: where the\n * web path contradicts both the documentation and upstream's own native\n * path, follow the documentation and say so. Per second, in both.\n */\n velocity: number\n /**\n * `ForceTouch`: the pressure, normalised to upstream's documented `[0, 1]`.\n *\n * 0 for every other kind, which is what an input with no pressure axis\n * reports and therefore the only honest filler. See ./force-touch for where\n * the number comes from and what it costs to produce one.\n */\n force: number\n /** `ForceTouch`: the difference since the previous update; the force itself on the first. */\n forceChange: number\n /**\n * Milliseconds since the press that started this gesture.\n *\n * Upstream carries it on `LongPress` alone, where it is the point of the\n * gesture. It is filled in for every kind here for the same reason the rest\n * of this payload is a union: one payload built once beats three that each\n * have to stay correct, and a field a spelling does not document is\n * harmless where a missing one is not.\n */\n duration: number\n}\n\n/** The ending payload the hook spelling reads, which says `canceled` instead. */\nexport type GestureEndEventPayload = GestureEventPayload & { canceled: boolean }\n\n/** One pointer, as the `onTouches*` callbacks see it. */\nexport type GestureTouchData = {\n id: number\n x: number\n y: number\n absoluteX: number\n absoluteY: number\n}\n\nexport type GestureTouchEvent = {\n handlerTag: number\n numberOfTouches: number\n eventType: TouchEventTypeValue\n allTouches: GestureTouchData[]\n changedTouches: GestureTouchData[]\n state: GestureStateValue\n pointerType: (typeof POINTER_TYPE)[keyof typeof POINTER_TYPE]\n}\n\n/**\n * The imperative handle handed to `onTouches*` by the legacy spelling.\n *\n * `activate()` from here is a second reason the responder system grew an\n * out-of-event grant channel: a callback that decides mid-press to take the\n * gesture is in exactly the position `activateAfterLongPress`'s timer is in.\n */\nexport type GestureStateManagerApi = {\n begin: () => void\n activate: () => void\n fail: () => void\n end: () => void\n}\n\n/**\n * The internal callback set, in the hook spelling's names. Both facades\n * normalise onto this; the recognizer knows no other names.\n */\nexport type RecognizerCallbacks = {\n onBegin?: (event: GestureEventPayload) => void\n onActivate?: (event: GestureEventPayload) => void\n onUpdate?: (event: GestureEventPayload) => void\n onChange?: (event: GestureEventPayload) => void\n onDeactivate?: (event: GestureEventPayload, success: boolean) => void\n onFinalize?: (event: GestureEventPayload, success: boolean) => void\n onTouchesDown?: (\n event: GestureTouchEvent,\n manager: GestureStateManagerApi,\n ) => void\n onTouchesMove?: (\n event: GestureTouchEvent,\n manager: GestureStateManagerApi,\n ) => void\n onTouchesUp?: (\n event: GestureTouchEvent,\n manager: GestureStateManagerApi,\n ) => void\n onTouchesCancel?: (\n event: GestureTouchEvent,\n manager: GestureStateManagerApi,\n ) => void\n}\n\n/**\n * How one gesture names another in a relation.\n *\n * Upstream's `GestureRef`, in all three of its spellings: the other gesture\n * itself, a ref built with `withRef()` holding it, or a raw handler tag. A\n * composed gesture stands for every gesture inside it.\n *\n * The reference is deliberately not a tag: a tag identifies a MOUNTED\n * gesture, and an app writes its relations against gesture objects it built\n * itself, often before either end is mounted. ./relations resolves the two.\n */\nexport type GestureRef = AnyGestureSpec | { current: unknown } | number\n\n/** The three relation maps, as one gesture's share of them. */\nexport type GestureRelations = {\n waitFor: readonly GestureRef[]\n simultaneousHandlers: readonly GestureRef[]\n blocksHandlers: readonly GestureRef[]\n}\n\n/** Everything every spelling of every kind configures, normalised. */\nexport type RecognizerConfig = RecognizerCallbacks & {\n // --- the relations, in the names the three maps carry ---\n //\n // Config rather than behaviour, like everything else here: both spellings\n // write these lists and the orchestrator reads them. `waitFor` is\n // `requireExternalGestureToFail`, `simultaneousHandlers` is\n // `simultaneousWithExternalGesture`, `blocksHandlers` is\n // `blocksExternalGesture` — and `Exclusive` and `Simultaneous` fill the\n // first two without adding a mechanism of their own.\n waitFor?: readonly GestureRef[]\n simultaneousHandlers?: readonly GestureRef[]\n blocksHandlers?: readonly GestureRef[]\n\n // --- common to all three kinds ---\n enabled?: boolean\n hitSlop?: GestureHitSlop\n shouldCancelWhenOutside?: boolean\n minPointers?: number\n maxPointers?: number\n /** Only the `onTouches*` state manager may activate the gesture. */\n manualActivation?: boolean\n\n // --- Pan ---\n activeOffsetX?: OffsetBound\n activeOffsetY?: OffsetBound\n failOffsetX?: OffsetBound\n failOffsetY?: OffsetBound\n minDistance?: number\n minVelocity?: number\n minVelocityX?: number\n minVelocityY?: number\n activateAfterLongPress?: number\n\n // --- Tap ---\n /** Presses required before the tap activates. Upstream's default is 1. */\n numberOfTaps?: number\n /** How fast the pointer must come back up. Upstream's default is 500ms. */\n maxDuration?: number\n /** How long the next tap may take to arrive. Upstream's default is 500ms. */\n maxDelay?: number\n maxDeltaX?: number\n maxDeltaY?: number\n\n // --- Native ---\n /**\n * Take the gesture the instant the pointer goes down, instead of waiting\n * for the wrapped view to start handling it. Upstream's spelling for a\n * native view that is a BUTTON rather than a scrollable.\n */\n shouldActivateOnStart?: boolean\n /**\n * Upstream: an active `Native` handler that disallows interruption cannot\n * be cancelled by anything else. Recorded and read by nothing yet — it is a\n * statement about ARBITRATION, and the registry that arbitrates is the\n * orchestrator's. Storing it is what lets that registry find it later;\n * refusing it would refuse `@gorhom/bottom-sheet`'s own configuration for a\n * knob whose only effect is on a relation it also sets explicitly.\n */\n disallowInterruption?: boolean\n /** Upstream's companion to `disallowInterruption`, same treatment. */\n yieldsToContinuousGestures?: boolean\n\n // --- LongPress, and Fling, which spells it the same way ---\n /** How long the pointer must stay down. Upstream's default is 500ms. */\n minDuration?: number\n /**\n * Exactly this many pointers. Upstream's spelling for LongPress and for\n * Fling, and EXACT in both: `Fling` compares it against the most pointers\n * the interaction ever had at once, and refuses a mismatch either way.\n */\n numberOfPointers?: number\n\n // --- Fling ---\n /**\n * A BITMASK of `Directions`, defaulting to `Directions.RIGHT`. Several\n * directions are one value: `Directions.LEFT | Directions.RIGHT`.\n */\n direction?: number\n\n // --- Hover ---\n /**\n * iOS's own pointer effect. Recorded and inert, exactly as it is inert in\n * upstream's web implementation — nothing there branches on it either.\n */\n hoverEffect?: number\n\n // --- ForceTouch ---\n /** Pressure below which the gesture will not activate. Upstream documents 0.2. */\n minForce?: number\n /** Pressure above which the gesture FAILS. Unset means no ceiling. */\n maxForce?: number\n /**\n * Haptic feedback on activation. Recorded and inert: there is no haptic\n * device on this platform and upstream implements it in iOS code only.\n */\n feedbackOnActivation?: boolean\n\n // --- Tap and LongPress share this one, with different defaults ---\n /**\n * How far the pointer may travel and still count. Upstream defaults it to\n * 10 for `LongPress` and leaves it UNSET for `Tap` — a tap that drags 200px\n * inside the view and lifts in time is still a tap there, which reads like\n * an oversight and is reproduced because guessing a default would silently\n * refuse taps upstream accepts.\n */\n maxDistance?: number\n\n // Recorded, and deliberately not acted on. Each is either platform-specific\n // upstream and inert off its platform (`averageTouches` is Android-only,\n // `enableTrackpadTwoFingerGesture` and `cancelsTouchesInView` iOS-only,\n // `activeCursor` and `mouseButton` Web-only) or asks for something this\n // platform already gives it (`runOnJS` — there is one runtime here, so every\n // callback already runs on the JS one). Keeping them in the config means it\n // describes what the app asked for rather than only what was honoured.\n runOnJS?: boolean\n averageTouches?: boolean\n enableTrackpadTwoFingerGesture?: boolean\n cancelsTouchesInView?: boolean\n activeCursor?: string\n mouseButton?: number\n testId?: string\n}\n\n/**\n * Which predicates the shared machine runs. Spelled as upstream's\n * `SingleGestureName` reads, minus the `GestureHandler` suffix.\n */\nexport type GestureKind =\n | \"pan\"\n | \"tap\"\n | \"longPress\"\n | \"native\"\n | \"pinch\"\n | \"rotation\"\n | \"fling\"\n | \"manual\"\n | \"hover\"\n | \"forceTouch\"\n\nconst KINDS = new Set<string>([\n \"pan\",\n \"tap\",\n \"longPress\",\n \"native\",\n \"pinch\",\n \"rotation\",\n \"fling\",\n \"manual\",\n \"hover\",\n \"forceTouch\",\n])\n\n/**\n * What a `GestureDetector` consumes. Both spellings produce exactly this.\n *\n * No `handlerTag`: a tag identifies a MOUNTED gesture, and both spellings\n * rebuild their object on every render (upstream's do too — the builder is\n * called in the component body, the hook returns a fresh config). The\n * detector mints one stable tag for as long as it is mounted, which is the\n * identity that means something.\n */\nexport type GestureSpec = {\n readonly kind: GestureKind\n readonly config: RecognizerConfig\n}\n\n/** Which of the three ways a group of gestures was put together. */\nexport type ComposedGestureKind = \"race\" | \"simultaneous\" | \"exclusive\"\n\n/**\n * What `Gesture.Race()`, `Gesture.Simultaneous()` and `Gesture.Exclusive()`\n * produce — a LIST and a label, with no mechanism in it.\n *\n * The composers are list-builders over the three relation maps and nothing\n * else: `Race` adds no relation at all because racing IS the default,\n * `Simultaneous` is a pairwise fill of `simultaneousHandlers`, and\n * `Exclusive` is a chain fill of `waitFor` where every group waits for all\n * the groups before it. See ./composition, which is where that is spelled\n * out, and note there is no third state and no second arbitration path.\n */\nexport type ComposedGestureSpec = {\n readonly composed: ComposedGestureKind\n readonly gestures: readonly AnyGestureSpec[]\n /** Upstream's flattening hook: every single gesture, composition removed. */\n toGestureArray: () => GestureSpec[]\n}\n\n/** What a `GestureDetector` accepts: one gesture, or a composition of them. */\nexport type AnyGestureSpec = GestureSpec | ComposedGestureSpec\n\nlet nextHandlerTag = 1\n\n/** RNGH's `handlerTag`: an identity for one mounted gesture. */\nexport const mintHandlerTag = (): number => {\n const tag = nextHandlerTag\n nextHandlerTag += 1\n return tag\n}\n\n/** Whether a value is one recognizer rather than a composition of them. */\nexport const isGestureSpec = (value: unknown): value is GestureSpec =>\n typeof value === \"object\" &&\n value !== null &&\n KINDS.has((value as GestureSpec).kind) &&\n typeof (value as GestureSpec).config === \"object\"\n\nexport const isComposedGestureSpec = (\n value: unknown,\n): value is ComposedGestureSpec =>\n typeof value === \"object\" &&\n value !== null &&\n Array.isArray((value as ComposedGestureSpec).gestures) &&\n typeof (value as ComposedGestureSpec).composed === \"string\"\n\n/** Whether a value is something a `GestureDetector` can drive. */\nexport const isAnyGestureSpec = (value: unknown): value is AnyGestureSpec =>\n isGestureSpec(value) || isComposedGestureSpec(value)\n\n/** Every single gesture in a composition, in the order they were written. */\nexport const flattenGestures = (gesture: AnyGestureSpec): GestureSpec[] =>\n isComposedGestureSpec(gesture)\n ? gesture.gestures.flatMap(flattenGestures)\n : [gesture]\n"]}