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,217 @@
1
+ // The hooks. Each one is a mapper plus a React lifetime: built during
2
+ // render (so the first frame is already correct), subscribed in an effect,
3
+ // and — the part the spike deliberately left out — DISPOSED on unmount, so a
4
+ // shared value never keeps a dead component's mapper alive.
5
+ //
6
+ // `dependencies` is honoured but is not how dependencies are found. Upstream
7
+ // needs the array because its inputs come from the Babel plugin's `__closure`
8
+ // snapshot, which is absent without the plugin; here tracking is dynamic, so
9
+ // the array only controls when a mapper is REBUILT (its updater closure went
10
+ // stale), never what it listens to. An app that passes the array and an app
11
+ // that does not both work.
12
+ import { useEffect, useReducer, useRef, useState } from "react";
13
+ import { initialUpdaterRun } from "./animation";
14
+ import { cancelAnimation } from "./mutable";
15
+ import { createAnimatedProps, } from "./props";
16
+ import { createAnimatedStyle, settlesThroughReact, } from "./style";
17
+ import { createMapper, untracked } from "./tracking";
18
+ import { createUpdaterAnimations, } from "./updater-animations";
19
+ /**
20
+ * When the Babel plugin IS in the app's build (an app that also targets iOS
21
+ * or Android keeps it), the emitted worklet carries the values it captured.
22
+ * Using them as the rebuild trigger costs nothing and makes an explicit
23
+ * `dependencies` array unnecessary for those apps, exactly as upstream does.
24
+ */
25
+ const closureDependencies = (updater) => {
26
+ const closure = updater.__closure;
27
+ return closure ? Object.values(closure) : [];
28
+ };
29
+ const rebuildDependencies = (updater, dependencies) => dependencies ?? closureDependencies(updater);
30
+ export const createHooks = (makeMutable,
31
+ // The same clock everything else in this layer runs on, needed here because
32
+ // `useAnimatedStyle`/`useAnimatedProps` may have to RUN an animation the
33
+ // updater returned rather than merely publish a value — see
34
+ // ./updater-animations.ts.
35
+ engine) => {
36
+ /** A mutable value that survives renders and drives animations. */
37
+ const useSharedValue = (initialValue) => {
38
+ const [shared] = useState(() => makeMutable(typeof initialValue === "function"
39
+ ? initialValue()
40
+ : initialValue));
41
+ useEffect(() => () => {
42
+ // Upstream cancels on unmount too: a running animation holds a frame
43
+ // subscription, and nothing is left to observe it.
44
+ cancelAnimation(shared);
45
+ }, [shared]);
46
+ return shared;
47
+ };
48
+ /** A read-only shared value recomputed whenever its inputs change. */
49
+ const useDerivedValue = (updater, dependencies) => {
50
+ const updaterRef = useRef(updater);
51
+ updaterRef.current = updater;
52
+ const [derived] = useState(() => makeMutable(initialUpdaterRun(() => untracked(updater))));
53
+ useEffect(() => {
54
+ const mapper = createMapper(() => {
55
+ derived.value = updaterRef.current();
56
+ });
57
+ mapper.run();
58
+ return () => {
59
+ mapper.dispose();
60
+ };
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
+ }, [derived, ...rebuildDependencies(updater, dependencies)]);
63
+ return derived;
64
+ };
65
+ /** Runs `react` whenever what `prepare` reads produces a new value. */
66
+ const useAnimatedReaction = (prepare, react, dependencies) => {
67
+ const prepareRef = useRef(prepare);
68
+ prepareRef.current = prepare;
69
+ const reactRef = useRef(react);
70
+ reactRef.current = react;
71
+ useEffect(() => {
72
+ let previous = null;
73
+ const mapper = createMapper(() => {
74
+ const current = prepareRef.current();
75
+ // Outside tracking: only `prepare` decides what re-runs this mapper,
76
+ // as upstream's __closure-derived inputs do.
77
+ untracked(() => {
78
+ reactRef.current(current, previous);
79
+ previous = current;
80
+ });
81
+ });
82
+ mapper.run();
83
+ return () => {
84
+ mapper.dispose();
85
+ };
86
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
+ }, [...rebuildDependencies(prepare, dependencies)]);
88
+ };
89
+ /**
90
+ * A style whose animatable leaves are driven straight to GTK. The updater
91
+ * re-runs on every write to a shared value it read; React does not.
92
+ */
93
+ const useAnimatedStyle = (updater, dependencies) => {
94
+ const updaterRef = useRef(updater);
95
+ updaterRef.current = updater;
96
+ const [rebuilds, requestRebuild] = useReducer((count) => count + 1, 0);
97
+ const animatedRef = useRef(null);
98
+ // Carries the result that did not fit the current shape from the mapper
99
+ // run that noticed into the render that rebuilds for it.
100
+ const pendingRef = useRef(null);
101
+ if (animatedRef.current === null) {
102
+ animatedRef.current = createAnimatedStyle(initialUpdaterRun(() => untracked(updater)));
103
+ }
104
+ else if (pendingRef.current !== null) {
105
+ // Reusing the nodes keeps the identity of every leaf that survived the
106
+ // shape change, so the view layer rebinds only what actually moved.
107
+ animatedRef.current = createAnimatedStyle(pendingRef.current, animatedRef.current.nodes);
108
+ pendingRef.current = null;
109
+ }
110
+ // Outside the mapper's effect on purpose: a shape change re-arms that
111
+ // effect, and an animation the updater started must not be cancelled and
112
+ // rebuilt because the set of leaves moved. It lives as long as the
113
+ // component does.
114
+ const animationsRef = useRef(null);
115
+ if (animationsRef.current === null) {
116
+ // A property this platform will not write at frame rate says so and
117
+ // promises the value "on the next React render". For a value that only
118
+ // ever moves inside an animation there IS no next render, so the promise
119
+ // is kept here — when the animation reaches its target, and on the
120
+ // cadence that carries it there (updater-animations.ts), never once a
121
+ // frame.
122
+ //
123
+ // `renew` before the render and not merely the render: the view this
124
+ // style lands on may be behind a `memo`, and a re-render of the
125
+ // component that owns the hook stops there with every prop identical
126
+ // unless the style itself has a new identity.
127
+ const land = (key) => {
128
+ if (!settlesThroughReact(key)) {
129
+ return;
130
+ }
131
+ animatedRef.current?.renew();
132
+ requestRebuild();
133
+ };
134
+ animationsRef.current = createUpdaterAnimations(engine, (resolved) => {
135
+ const animated = animatedRef.current;
136
+ if (animated && !animated.apply(resolved)) {
137
+ // The set of animatable leaves changed, so the nodes the view
138
+ // layer bound no longer describe this style. This is the ONE case
139
+ // that costs a React render, and it costs exactly one.
140
+ pendingRef.current = resolved;
141
+ requestRebuild();
142
+ }
143
+ }, land, land);
144
+ }
145
+ useEffect(() => () => {
146
+ animationsRef.current?.dispose();
147
+ animationsRef.current = null;
148
+ }, []);
149
+ useEffect(() => {
150
+ const mapper = createMapper(() => {
151
+ animationsRef.current?.run(updaterRef.current());
152
+ });
153
+ mapper.run();
154
+ return () => {
155
+ mapper.dispose();
156
+ };
157
+ // eslint-disable-next-line react-hooks/exhaustive-deps
158
+ }, [rebuilds, ...rebuildDependencies(updater, dependencies)]);
159
+ return animatedRef.current.style;
160
+ };
161
+ /**
162
+ * Props whose numeric leaves are driven straight to the component that
163
+ * takes them — the SVG shapes, which subscribe to an animated node on any
164
+ * numeric geometry or paint prop. Same lifecycle as `useAnimatedStyle`,
165
+ * down to the one render a shape change costs.
166
+ */
167
+ const useAnimatedProps = (updater, dependencies) => {
168
+ const updaterRef = useRef(updater);
169
+ updaterRef.current = updater;
170
+ const [rebuilds, requestRebuild] = useReducer((count) => count + 1, 0);
171
+ const animatedRef = useRef(null);
172
+ const pendingRef = useRef(null);
173
+ if (animatedRef.current === null) {
174
+ animatedRef.current = createAnimatedProps(initialUpdaterRun(() => untracked(updater)));
175
+ }
176
+ else if (pendingRef.current !== null) {
177
+ animatedRef.current = createAnimatedProps(pendingRef.current, animatedRef.current.nodes);
178
+ pendingRef.current = null;
179
+ }
180
+ // Same lifetime and the same reason as the style hook's. Every numeric
181
+ // prop here IS driven at frame rate, so there is no settle to publish
182
+ // through React.
183
+ const animationsRef = useRef(null);
184
+ if (animationsRef.current === null) {
185
+ animationsRef.current = createUpdaterAnimations(engine, (resolved) => {
186
+ const animated = animatedRef.current;
187
+ if (animated && !animated.apply(resolved)) {
188
+ pendingRef.current = resolved;
189
+ requestRebuild();
190
+ }
191
+ });
192
+ }
193
+ useEffect(() => () => {
194
+ animationsRef.current?.dispose();
195
+ animationsRef.current = null;
196
+ }, []);
197
+ useEffect(() => {
198
+ const mapper = createMapper(() => {
199
+ animationsRef.current?.run(updaterRef.current());
200
+ });
201
+ mapper.run();
202
+ return () => {
203
+ mapper.dispose();
204
+ };
205
+ // eslint-disable-next-line react-hooks/exhaustive-deps
206
+ }, [rebuilds, ...rebuildDependencies(updater, dependencies)]);
207
+ return animatedRef.current.props;
208
+ };
209
+ return {
210
+ useSharedValue,
211
+ useDerivedValue,
212
+ useAnimatedReaction,
213
+ useAnimatedStyle,
214
+ useAnimatedProps,
215
+ };
216
+ };
217
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/reanimated-compat/hooks.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,2EAA2E;AAC3E,6EAA6E;AAC7E,4DAA4D;AAC5D,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,2BAA2B;AAC3B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EA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A;IAED,OAAO;QACL,cAAc;QACd,eAAe;QACf,mBAAmB;QACnB,gBAAgB;QAChB,gBAAgB;KACjB,CAAA;AACH,CAAC,CAAA","sourcesContent":["// The hooks. Each one is a mapper plus a React lifetime: built during\n// render (so the first frame is already correct), subscribed in an effect,\n// and — the part the spike deliberately left out — DISPOSED on unmount, so a\n// shared value never keeps a dead component's mapper alive.\n//\n// `dependencies` is honoured but is not how dependencies are found. Upstream\n// needs the array because its inputs come from the Babel plugin's `__closure`\n// snapshot, which is absent without the plugin; here tracking is dynamic, so\n// the array only controls when a mapper is REBUILT (its updater closure went\n// stale), never what it listens to. An app that passes the array and an app\n// that does not both work.\nimport { useEffect, useReducer, useRef, useState } from \"react\"\nimport { initialUpdaterRun, type AnimationEngine } from \"./animation\"\nimport type { SharedValue } from \"./mutable\"\nimport { cancelAnimation } from \"./mutable\"\nimport {\n createAnimatedProps,\n type AnimatedPropsObject,\n type PropsObject,\n} from \"./props\"\nimport {\n createAnimatedStyle,\n settlesThroughReact,\n type AnimatedStyle,\n type StyleObject,\n} from \"./style\"\nimport { createMapper, untracked } from \"./tracking\"\nimport {\n createUpdaterAnimations,\n type UpdaterAnimations,\n} from \"./updater-animations\"\n\nexport type DependencyList = readonly unknown[]\n\ntype MakeMutable = <T>(initial: T) => SharedValue<T>\n\n/**\n * When the Babel plugin IS in the app's build (an app that also targets iOS\n * or Android keeps it), the emitted worklet carries the values it captured.\n * Using them as the rebuild trigger costs nothing and makes an explicit\n * `dependencies` array unnecessary for those apps, exactly as upstream does.\n */\nconst closureDependencies = (updater: unknown): DependencyList => {\n const closure = (updater as { __closure?: Record<string, unknown> }).__closure\n return closure ? Object.values(closure) : []\n}\n\nconst rebuildDependencies = (\n updater: unknown,\n dependencies: DependencyList | undefined,\n): DependencyList => dependencies ?? closureDependencies(updater)\n\nexport const createHooks = (\n makeMutable: MakeMutable,\n // The same clock everything else in this layer runs on, needed here because\n // `useAnimatedStyle`/`useAnimatedProps` may have to RUN an animation the\n // updater returned rather than merely publish a value — see\n // ./updater-animations.ts.\n engine: AnimationEngine,\n) => {\n /** A mutable value that survives renders and drives animations. */\n const useSharedValue = <T>(initialValue: T | (() => T)): SharedValue<T> => {\n const [shared] = useState(() =>\n makeMutable(\n typeof initialValue === \"function\"\n ? (initialValue as () => T)()\n : initialValue,\n ),\n )\n useEffect(\n () => () => {\n // Upstream cancels on unmount too: a running animation holds a frame\n // subscription, and nothing is left to observe it.\n cancelAnimation(shared)\n },\n [shared],\n )\n return shared\n }\n\n /** A read-only shared value recomputed whenever its inputs change. */\n const useDerivedValue = <T>(\n updater: () => T,\n dependencies?: DependencyList,\n ): SharedValue<T> => {\n const updaterRef = useRef(updater)\n updaterRef.current = updater\n const [derived] = useState(() =>\n makeMutable(initialUpdaterRun(() => untracked(updater))),\n )\n\n useEffect(() => {\n const mapper = createMapper(() => {\n derived.value = updaterRef.current()\n })\n mapper.run()\n return () => {\n mapper.dispose()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [derived, ...rebuildDependencies(updater, dependencies)])\n\n return derived\n }\n\n /** Runs `react` whenever what `prepare` reads produces a new value. */\n const useAnimatedReaction = <T>(\n prepare: () => T,\n react: (current: T, previous: T | null) => void,\n dependencies?: DependencyList,\n ): void => {\n const prepareRef = useRef(prepare)\n prepareRef.current = prepare\n const reactRef = useRef(react)\n reactRef.current = react\n\n useEffect(() => {\n let previous: T | null = null\n const mapper = createMapper(() => {\n const current = prepareRef.current()\n // Outside tracking: only `prepare` decides what re-runs this mapper,\n // as upstream's __closure-derived inputs do.\n untracked(() => {\n reactRef.current(current, previous)\n previous = current\n })\n })\n mapper.run()\n return () => {\n mapper.dispose()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [...rebuildDependencies(prepare, dependencies)])\n }\n\n /**\n * A style whose animatable leaves are driven straight to GTK. The updater\n * re-runs on every write to a shared value it read; React does not.\n */\n const useAnimatedStyle = (\n updater: () => StyleObject,\n dependencies?: DependencyList,\n ): StyleObject => {\n const updaterRef = useRef(updater)\n updaterRef.current = updater\n const [rebuilds, requestRebuild] = useReducer(\n (count: number) => count + 1,\n 0,\n )\n const animatedRef = useRef<AnimatedStyle | null>(null)\n // Carries the result that did not fit the current shape from the mapper\n // run that noticed into the render that rebuilds for it.\n const pendingRef = useRef<StyleObject | null>(null)\n\n if (animatedRef.current === null) {\n animatedRef.current = createAnimatedStyle(\n initialUpdaterRun(() => untracked(updater)),\n )\n } else if (pendingRef.current !== null) {\n // Reusing the nodes keeps the identity of every leaf that survived the\n // shape change, so the view layer rebinds only what actually moved.\n animatedRef.current = createAnimatedStyle(\n pendingRef.current,\n animatedRef.current.nodes,\n )\n pendingRef.current = null\n }\n\n // Outside the mapper's effect on purpose: a shape change re-arms that\n // effect, and an animation the updater started must not be cancelled and\n // rebuilt because the set of leaves moved. It lives as long as the\n // component does.\n const animationsRef = useRef<UpdaterAnimations | null>(null)\n if (animationsRef.current === null) {\n // A property this platform will not write at frame rate says so and\n // promises the value \"on the next React render\". For a value that only\n // ever moves inside an animation there IS no next render, so the promise\n // is kept here — when the animation reaches its target, and on the\n // cadence that carries it there (updater-animations.ts), never once a\n // frame.\n //\n // `renew` before the render and not merely the render: the view this\n // style lands on may be behind a `memo`, and a re-render of the\n // component that owns the hook stops there with every prop identical\n // unless the style itself has a new identity.\n const land = (key: string): void => {\n if (!settlesThroughReact(key)) {\n return\n }\n animatedRef.current?.renew()\n requestRebuild()\n }\n animationsRef.current = createUpdaterAnimations(\n engine,\n (resolved) => {\n const animated = animatedRef.current\n if (animated && !animated.apply(resolved as StyleObject)) {\n // The set of animatable leaves changed, so the nodes the view\n // layer bound no longer describe this style. This is the ONE case\n // that costs a React render, and it costs exactly one.\n pendingRef.current = resolved as StyleObject\n requestRebuild()\n }\n },\n land,\n land,\n )\n }\n useEffect(\n () => () => {\n animationsRef.current?.dispose()\n animationsRef.current = null\n },\n [],\n )\n\n useEffect(() => {\n const mapper = createMapper(() => {\n animationsRef.current?.run(updaterRef.current())\n })\n mapper.run()\n return () => {\n mapper.dispose()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [rebuilds, ...rebuildDependencies(updater, dependencies)])\n\n return animatedRef.current.style\n }\n\n /**\n * Props whose numeric leaves are driven straight to the component that\n * takes them — the SVG shapes, which subscribe to an animated node on any\n * numeric geometry or paint prop. Same lifecycle as `useAnimatedStyle`,\n * down to the one render a shape change costs.\n */\n const useAnimatedProps = (\n updater: () => PropsObject,\n dependencies?: DependencyList,\n ): PropsObject => {\n const updaterRef = useRef(updater)\n updaterRef.current = updater\n const [rebuilds, requestRebuild] = useReducer(\n (count: number) => count + 1,\n 0,\n )\n const animatedRef = useRef<AnimatedPropsObject | null>(null)\n const pendingRef = useRef<PropsObject | null>(null)\n\n if (animatedRef.current === null) {\n animatedRef.current = createAnimatedProps(\n initialUpdaterRun(() => untracked(updater)),\n )\n } else if (pendingRef.current !== null) {\n animatedRef.current = createAnimatedProps(\n pendingRef.current,\n animatedRef.current.nodes,\n )\n pendingRef.current = null\n }\n\n // Same lifetime and the same reason as the style hook's. Every numeric\n // prop here IS driven at frame rate, so there is no settle to publish\n // through React.\n const animationsRef = useRef<UpdaterAnimations | null>(null)\n if (animationsRef.current === null) {\n animationsRef.current = createUpdaterAnimations(engine, (resolved) => {\n const animated = animatedRef.current\n if (animated && !animated.apply(resolved as PropsObject)) {\n pendingRef.current = resolved as PropsObject\n requestRebuild()\n }\n })\n }\n useEffect(\n () => () => {\n animationsRef.current?.dispose()\n animationsRef.current = null\n },\n [],\n )\n\n useEffect(() => {\n const mapper = createMapper(() => {\n animationsRef.current?.run(updaterRef.current())\n })\n mapper.run()\n return () => {\n mapper.dispose()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [rebuilds, ...rebuildDependencies(updater, dependencies)])\n\n return animatedRef.current.props\n }\n\n return {\n useSharedValue,\n useDerivedValue,\n useAnimatedReaction,\n useAnimatedStyle,\n useAnimatedProps,\n }\n}\n"]}
@@ -0,0 +1,258 @@
1
+ import { type ReactNode } from "react";
2
+ import type { AnimatedViewStyle, AnimatedViewProps as PlatformAnimatedViewProps } from "../components/animated";
3
+ import { makeShareableCloneRecursive, runOnJS, runOnUI, scheduleOnRN, scheduleOnUI } from "../worklets-compat/index";
4
+ import { measure, useAnimatedRef } from "./animated-ref";
5
+ import { withClamp, withDecay, withDelay, withRepeat, withSequence, withSpring, withTiming } from "./animation";
6
+ import { convertToRGBA, interpolateColor, isColor, rgbaArrayToRGBAColor } from "./color";
7
+ import { Easing } from "./easing";
8
+ import { clamp, Extrapolation, interpolate } from "./interpolation";
9
+ import { FadeIn, FadeOut, Keyframe, AnimationBuilder as LayoutAnimationBuilder, LinearTransition } from "./layout-animation";
10
+ import { type LayoutAnimationProps } from "./layout-animation-view";
11
+ import { cancelAnimation, isSharedValue, type SharedValue } from "./mutable";
12
+ import { scrollTo, useAnimatedScrollHandler, useEvent, useHandler, type AnimatedScrollEvent, type ScrollHandlerCallback, type ScrollHandlers, type UseHandlerContext } from "./scroll-handler";
13
+ import type { StyleObject } from "./style";
14
+ import { isWorkletFunction } from "./threads";
15
+ declare const makeMutable: <T>(initial: T) => SharedValue<T>;
16
+ declare const useSharedValue: <T>(initialValue: T | (() => T)) => SharedValue<T>, useDerivedValue: <T>(updater: () => T, dependencies?: import("./hooks").DependencyList) => SharedValue<T>, useAnimatedReaction: <T>(prepare: () => T, react: (current: T, previous: T | null) => void, dependencies?: import("./hooks").DependencyList) => void, useAnimatedStyle: (updater: () => StyleObject, dependencies?: import("./hooks").DependencyList) => StyleObject, useAnimatedProps: (updater: () => import("./props").PropsObject, dependencies?: import("./hooks").DependencyList) => import("./props").PropsObject;
17
+ declare const useScrollOffset: (animatedRef: {
18
+ current: unknown;
19
+ } | (() => unknown) | null | undefined, providedOffset?: SharedValue<number>) => SharedValue<number>, useScrollViewOffset: (animatedRef: {
20
+ current: unknown;
21
+ } | (() => unknown) | null | undefined, providedOffset?: SharedValue<number>) => SharedValue<number>;
22
+ export { cancelAnimation, clamp, convertToRGBA, Easing, Extrapolation, interpolate, interpolateColor, isColor, isSharedValue, isWorkletFunction, makeMutable, makeShareableCloneRecursive, measure, rgbaArrayToRGBAColor, runOnJS, runOnUI, scheduleOnRN, scheduleOnUI, scrollTo, useAnimatedProps, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useEvent, useHandler, useScrollOffset, useScrollViewOffset, useSharedValue, withClamp, withDecay, withDelay, withRepeat, withSequence, withSpring, withTiming, };
23
+ /**
24
+ * RN's `PlatformColor`, which Reanimated re-exports. This is the platform's
25
+ * own — theme colours by name, resolved by GTK against the live Adwaita
26
+ * palette (`var(--accent-bg-color)`). It can be written to a style, animated
27
+ * BETWEEN by a shared value, and not interpolated THROUGH: see
28
+ * {@link interpolateColor}.
29
+ */
30
+ export { PlatformColor } from "../style/colors";
31
+ export type { AnimationCallback, WithDecayConfig, WithSpringConfig, WithTimingConfig, } from "./animation";
32
+ export type { ColorInterpolationOptions, ColorSpace, ParsedColorArray, } from "./color";
33
+ export type { EasingFunction, EasingFunctionFactory } from "./easing";
34
+ export type { AnimatedRef, MeasuredDimensions } from "./animated-ref";
35
+ export type { AnimatedScrollEvent, ScrollHandlerCallback, ScrollHandlers, UseHandlerContext, };
36
+ export type { DependencyList } from "./hooks";
37
+ export type { ExtrapolationConfig, ExtrapolationType } from "./interpolation";
38
+ export type { DerivedValue, SharedValue } from "./mutable";
39
+ export type { PropsObject as AnimatedProps } from "./props";
40
+ export type { KeyframeDefinitions, LayoutAnimationCallback, BuiltLayoutAnimation, LayoutAnimationValues, } from "./layout-animation";
41
+ export type { LayoutAnimationProps } from "./layout-animation-view";
42
+ /** Deprecated upstream alias of {@link Extrapolation}, kept for source parity. */
43
+ export declare const Extrapolate: typeof Extrapolation;
44
+ /**
45
+ * Upstream's spring presets, which are plain data and therefore free to
46
+ * mirror exactly. `GentleSpringConfig` is `withSpring`'s default.
47
+ */
48
+ export declare const Reanimated3DefaultSpringConfig: {
49
+ readonly damping: 10;
50
+ readonly mass: 1;
51
+ readonly stiffness: 100;
52
+ };
53
+ export declare const Reanimated3DefaultSpringConfigWithDuration: {
54
+ readonly duration: 1333;
55
+ readonly dampingRatio: 0.5;
56
+ };
57
+ export declare const WigglySpringConfig: {
58
+ readonly damping: 90;
59
+ readonly mass: 4;
60
+ readonly stiffness: 900;
61
+ };
62
+ export declare const WigglySpringConfigWithDuration: {
63
+ readonly duration: 550;
64
+ readonly dampingRatio: 0.75;
65
+ };
66
+ export declare const GentleSpringConfig: {
67
+ readonly damping: 120;
68
+ readonly mass: 4;
69
+ readonly stiffness: 900;
70
+ };
71
+ export declare const GentleSpringConfigWithDuration: {
72
+ readonly duration: 550;
73
+ readonly dampingRatio: 1;
74
+ };
75
+ export declare const SnappySpringConfig: {
76
+ readonly damping: 110;
77
+ readonly mass: 4;
78
+ readonly stiffness: 900;
79
+ readonly overshootClamping: true;
80
+ };
81
+ export declare const SnappySpringConfigWithDuration: {
82
+ readonly duration: 550;
83
+ readonly dampingRatio: 0.92;
84
+ readonly overshootClamping: true;
85
+ };
86
+ /**
87
+ * How an animation should respond to the OS "reduce motion" setting. The
88
+ * enum is mirrored so a config carrying it type-checks and runs; the setting
89
+ * itself is not wired up on this platform yet, so every value behaves as
90
+ * `Never` and {@link useReducedMotion} reports false. GNOME's
91
+ * `gtk-enable-animations` is the signal to read when it is.
92
+ */
93
+ export declare enum ReduceMotion {
94
+ System = "system",
95
+ Always = "always",
96
+ Never = "never"
97
+ }
98
+ export declare enum ReanimatedLogLevel {
99
+ warn = 1,
100
+ error = 2
101
+ }
102
+ /**
103
+ * Accepted and ignored: there is no Reanimated logger to configure here.
104
+ * Warnings come from the platform's own one-per-session channel, which is not
105
+ * routed through this object. Refusing would break apps that call it at
106
+ * startup for a setting that changes nothing.
107
+ */
108
+ export declare const configureReanimatedLogger: () => void;
109
+ /** No reduce-motion source is wired on this platform yet — see {@link ReduceMotion}. */
110
+ export declare const useReducedMotion: () => boolean;
111
+ /**
112
+ * Upstream's keyboard states. Mirrored because {@link useAnimatedKeyboard}
113
+ * returns one of them, and because a caller comparing against
114
+ * `KeyboardState.CLOSED` should type-check and be right.
115
+ */
116
+ export declare enum KeyboardState {
117
+ UNKNOWN = 0,
118
+ OPENING = 1,
119
+ OPEN = 2,
120
+ CLOSING = 3,
121
+ CLOSED = 4
122
+ }
123
+ /**
124
+ * The keyboard's height and state as shared values — **honoured and never
125
+ * updated**, which is the same shape and the same reason as RN's `Keyboard`
126
+ * (src/apis/keyboard.ts): every number this hook reports describes a software
127
+ * panel sliding over the app and taking screen space from it, and a desktop
128
+ * has no such panel. The height a caller reads is 0 because the keyboard
129
+ * occupies nothing, and the state is `CLOSED` because it is.
130
+ *
131
+ * Both values are REAL shared values, so a `useAnimatedStyle` reading them
132
+ * subscribes, computes and settles exactly once, and a layout that offsets
133
+ * itself by `keyboard.height.value` lands where it should instead of
134
+ * throwing. That is the whole of the difference from refusing: an app written
135
+ * for three platforms keeps one source and gets the right answer here.
136
+ *
137
+ * `UNKNOWN` is deliberately not the state. Upstream seeds `UNKNOWN` and
138
+ * replaces it the moment the native side reports; here nothing ever will, so
139
+ * a permanent "we do not know" would be false — the state IS known.
140
+ *
141
+ * The measured caller is `@gorhom/bottom-sheet`, which has its own
142
+ * `useAnimatedKeyboard` over RN's `Keyboard` and never reaches this one; the
143
+ * hook is here for apps, which do.
144
+ */
145
+ export declare const useAnimatedKeyboard: (options?: unknown) => {
146
+ height: SharedValue<number>;
147
+ state: SharedValue<KeyboardState>;
148
+ };
149
+ /**
150
+ * Both are deprecated warn-only aliases upstream, and libraries call them to
151
+ * ask "is Reanimated present and modern". Here the answer is yes.
152
+ */
153
+ export declare const isConfigured: () => boolean;
154
+ export declare const isReanimated3: () => boolean;
155
+ /**
156
+ * The upstream version whose API this surface mirrors — NOT a claim to be
157
+ * that package. Libraries read it to gate on API level, which is exactly what
158
+ * it answers.
159
+ */
160
+ export declare const reanimatedVersion = "4.5.3";
161
+ export declare const startMapper: (mapper: () => void) => number;
162
+ export declare const stopMapper: (id: number) => void;
163
+ /** A style object whose animatable leaves `useAnimatedStyle` has replaced with nodes. */
164
+ export type AnimatedStyleProp = StyleObject;
165
+ type StyleEntry = AnimatedViewStyle | AnimatedStyleProp;
166
+ export type AnimatedViewProps = Omit<PlatformAnimatedViewProps, "style"> & LayoutAnimationProps & {
167
+ style?: StyleEntry | readonly (StyleEntry | false | null | undefined)[];
168
+ };
169
+ /**
170
+ * The rest of the host components, and the factory behind them. All four are
171
+ * the platform's own, because the imperative write path never needed to know
172
+ * what it was writing to: it needs the child's widget and its parent's, and
173
+ * `createAnimatedComponent` reads the first back out of the ref the wrapped
174
+ * component exposes. It adds NO widget to the tree — wrapping in an
175
+ * `Animated.View` would change flex layout and change what `measureLayout` is
176
+ * relative to, which is a different tree, not a shim.
177
+ *
178
+ * `FlatList` is the one refusal, and it is a decision rather than an
179
+ * omission: it is a composite over the windowed core over a ScrollView, and
180
+ * its ref is a scroll API, so no widget is reachable. It throws on render,
181
+ * naming itself and naming the workaround.
182
+ */
183
+ declare const Animated: {
184
+ View: (props: AnimatedViewProps) => ReactNode;
185
+ Text: any;
186
+ ScrollView: any;
187
+ Image: any;
188
+ FlatList: any;
189
+ createAnimatedComponent: any;
190
+ addWhitelistedNativeProps: () => void;
191
+ addWhitelistedUIProps: () => void;
192
+ };
193
+ export default Animated;
194
+ export declare const createAnimatedComponent: any;
195
+ export declare const defineAnimation: any;
196
+ export declare const processColor: any;
197
+ export declare const DynamicColorIOS: any;
198
+ export { FadeIn, FadeOut, Keyframe, LinearTransition };
199
+ export declare const BaseAnimationBuilder: typeof LayoutAnimationBuilder;
200
+ export declare const ComplexAnimationBuilder: typeof LayoutAnimationBuilder;
201
+ /** Upstream's own deprecated alias of {@link LinearTransition}. */
202
+ export declare const Layout: typeof LinearTransition;
203
+ export { BounceIn, BounceInDown, BounceInLeft, BounceInRight, BounceInUp, BounceOut, BounceOutDown, BounceOutLeft, BounceOutRight, BounceOutUp, FadeInDown, FadeInLeft, FadeInRight, FadeInUp, FadeOutDown, FadeOutLeft, FadeOutRight, FadeOutUp, PinwheelIn, PinwheelOut, RollInLeft, RollInRight, RollOutLeft, RollOutRight, RotateInDownLeft, RotateInDownRight, RotateInUpLeft, RotateInUpRight, RotateOutDownLeft, RotateOutDownRight, RotateOutUpLeft, RotateOutUpRight, SlideInDown, SlideInLeft, SlideInRight, SlideInUp, SlideOutDown, SlideOutLeft, SlideOutRight, SlideOutUp, StretchInX, StretchInY, StretchOutX, StretchOutY, ZoomIn, ZoomInDown, ZoomInEasyDown, ZoomInEasyUp, ZoomInLeft, ZoomInRight, ZoomInRotate, ZoomInUp, ZoomOut, ZoomOutDown, ZoomOutEasyDown, ZoomOutEasyUp, ZoomOutLeft, ZoomOutRight, ZoomOutRotate, ZoomOutUp, } from "./layout-animation-presets";
204
+ export { CurvedTransition, EntryExitTransition, FadingTransition, JumpingTransition, SequencedTransition, } from "./layout-transitions";
205
+ export { enableLayoutAnimations, LayoutAnimationConfig, } from "./layout-animation-config";
206
+ export type { LayoutAnimationConfigProps } from "./layout-animation-config";
207
+ export declare const FlipInEasyX: any;
208
+ export declare const FlipInEasyY: any;
209
+ export declare const FlipInXDown: any;
210
+ export declare const FlipInXUp: any;
211
+ export declare const FlipInYLeft: any;
212
+ export declare const FlipInYRight: any;
213
+ export declare const FlipOutEasyX: any;
214
+ export declare const FlipOutEasyY: any;
215
+ export declare const FlipOutXDown: any;
216
+ export declare const FlipOutXUp: any;
217
+ export declare const FlipOutYLeft: any;
218
+ export declare const FlipOutYRight: any;
219
+ export declare const LightSpeedInLeft: any;
220
+ export declare const LightSpeedInRight: any;
221
+ export declare const LightSpeedOutLeft: any;
222
+ export declare const LightSpeedOutRight: any;
223
+ export declare const SharedTransition: any;
224
+ export declare const SharedTransitionBoundary: any;
225
+ export declare const css: any;
226
+ export declare const createCSSAnimatedComponent: any;
227
+ export declare const cubicBezier: any;
228
+ export declare const linear: any;
229
+ export declare const steps: any;
230
+ export declare const useAnimatedSensor: any;
231
+ export declare const useComposedEventHandler: any;
232
+ export declare const useFrameCallback: any;
233
+ export declare const useTimestamp: any;
234
+ export declare const createWorkletRuntime: any;
235
+ export declare const runOnRuntime: any;
236
+ export declare const executeOnUIRuntimeSync: any;
237
+ export declare const dispatchCommand: any;
238
+ export declare const getRelativeCoords: any;
239
+ export declare const setGestureState: any;
240
+ export declare const setNativeProps: any;
241
+ export declare const getViewProp: any;
242
+ export declare const createAnimatedPropAdapter: any;
243
+ export declare const NativeEventsManager: any;
244
+ export declare const getUseOfValueInStyleWarning: any;
245
+ export declare const InterfaceOrientation: any;
246
+ export declare const IOSReferenceFrame: any;
247
+ export declare const SensorType: any;
248
+ export declare const ScreenTransition: any;
249
+ export declare const startScreenTransition: any;
250
+ export declare const finishScreenTransition: any;
251
+ export declare const PerformanceMonitor: any;
252
+ export declare const ReducedMotionConfig: any;
253
+ export declare const getDynamicFeatureFlag: any;
254
+ export declare const getStaticFeatureFlag: any;
255
+ export declare const setDynamicFeatureFlag: any;
256
+ export { advanceAnimationByFrame, advanceAnimationByTime, withReanimatedTimer, } from "./test-timers";
257
+ export declare const getAnimatedStyle: any;
258
+ export declare const setUpTests: any;