@rootnative/inertia 0.0.9 → 0.0.10

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 (100) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/README.md +7 -7
  3. package/dist/applyBounds-BYGiHrYO.d.mts +18 -0
  4. package/dist/applyBounds-BYGiHrYO.d.ts +18 -0
  5. package/dist/{chunk-E3ALFSH2.js → chunk-2UGWAB6N.js} +78 -70
  6. package/dist/{chunk-ZBHQPVWE.js → chunk-3ZNHPT5Z.js} +2 -2
  7. package/dist/{chunk-IHVMNOS4.js → chunk-46766TBM.js} +2 -2
  8. package/dist/{chunk-MUT6BTZS.js → chunk-4EZ5DBL3.js} +10 -7
  9. package/dist/{chunk-MFAFB4K7.mjs → chunk-6FCATUMY.mjs} +8 -10
  10. package/dist/{chunk-6YIUETBF.mjs → chunk-7BH3CAO5.mjs} +1 -1
  11. package/dist/{chunk-JBK5ZLMH.mjs → chunk-CUHOCONB.mjs} +1 -1
  12. package/dist/{chunk-M4766VUV.mjs → chunk-DRA2K53O.mjs} +1 -1
  13. package/dist/{chunk-L4JFECXU.mjs → chunk-F4HMCXAX.mjs} +6 -3
  14. package/dist/{chunk-W7NTRSPD.mjs → chunk-HEAWMZEM.mjs} +105 -66
  15. package/dist/{chunk-IX6SEOSK.mjs → chunk-JENYDTXH.mjs} +52 -44
  16. package/dist/chunk-KFHZMFAX.js +23 -0
  17. package/dist/{chunk-6AN5X3YE.js → chunk-KXU6VH2Y.js} +10 -11
  18. package/dist/{chunk-WNVHPMBI.js → chunk-N33GSDNQ.js} +106 -65
  19. package/dist/chunk-OH46TGEA.mjs +20 -0
  20. package/dist/{chunk-QNLSCOR5.mjs → chunk-OLOSU2BD.mjs} +1 -1
  21. package/dist/chunk-PLKXCJIB.js +8 -0
  22. package/dist/{chunk-GSUC4HWP.mjs → chunk-QXKPIENP.mjs} +1 -1
  23. package/dist/chunk-UBHQJFUW.js +8 -0
  24. package/dist/{chunk-6NOCY764.js → chunk-VKXSL3ZL.js} +2 -2
  25. package/dist/chunk-XKNEQDAT.js +8 -0
  26. package/dist/{chunk-EN4PN7X3.mjs → chunk-Z23AMUSW.mjs} +1 -1
  27. package/dist/gestureLayer/index.d.mts +3 -3
  28. package/dist/gestureLayer/index.d.ts +3 -3
  29. package/dist/gestureLayer/index.js +12 -18
  30. package/dist/gestureLayer/index.mjs +5 -11
  31. package/dist/index.d.mts +87 -45
  32. package/dist/index.d.ts +87 -45
  33. package/dist/index.js +114 -91
  34. package/dist/index.mjs +66 -59
  35. package/dist/motion/FlatList.d.mts +1 -1
  36. package/dist/motion/FlatList.d.ts +1 -1
  37. package/dist/motion/FlatList.js +5 -5
  38. package/dist/motion/FlatList.mjs +4 -4
  39. package/dist/motion/Image.d.mts +1 -1
  40. package/dist/motion/Image.d.ts +1 -1
  41. package/dist/motion/Image.js +5 -5
  42. package/dist/motion/Image.mjs +4 -4
  43. package/dist/motion/Pressable.d.mts +1 -1
  44. package/dist/motion/Pressable.d.ts +1 -1
  45. package/dist/motion/Pressable.js +5 -5
  46. package/dist/motion/Pressable.mjs +4 -4
  47. package/dist/motion/ScrollView.d.mts +1 -1
  48. package/dist/motion/ScrollView.d.ts +1 -1
  49. package/dist/motion/ScrollView.js +5 -5
  50. package/dist/motion/ScrollView.mjs +4 -4
  51. package/dist/motion/Text.d.mts +1 -1
  52. package/dist/motion/Text.d.ts +1 -1
  53. package/dist/motion/Text.js +5 -5
  54. package/dist/motion/Text.mjs +4 -4
  55. package/dist/motion/View.d.mts +1 -1
  56. package/dist/motion/View.d.ts +1 -1
  57. package/dist/motion/View.js +5 -5
  58. package/dist/motion/View.mjs +4 -4
  59. package/dist/touch/index.d.mts +2 -1
  60. package/dist/touch/index.d.ts +2 -1
  61. package/dist/touch/index.js +16 -31
  62. package/dist/touch/index.mjs +11 -29
  63. package/dist/{types-DyJpG64F.d.mts → types-08mG8fNk.d.mts} +10 -3
  64. package/dist/{types-DyJpG64F.d.ts → types-08mG8fNk.d.ts} +10 -3
  65. package/dist/{useGesture-DbH46EBp.d.ts → useGesture-D1lHeQQ6.d.ts} +1 -1
  66. package/dist/{useGesture-CnZQnYHH.d.mts → useGesture-DjszaHWz.d.mts} +1 -1
  67. package/package.json +4 -2
  68. package/src/config/namedTransitions.ts +7 -9
  69. package/src/gestureLayer/index.ts +3 -0
  70. package/src/gestureLayer/useGestureLayer.ts +6 -9
  71. package/src/gestures/focusVisibility.ts +19 -17
  72. package/src/gestures/index.ts +1 -1
  73. package/src/index.ts +9 -0
  74. package/src/layout/resolveLayout.ts +4 -1
  75. package/src/layout/useSharedLayout.ts +2 -1
  76. package/src/motion/createMotionComponent.tsx +92 -44
  77. package/src/presence/Presence.tsx +5 -7
  78. package/src/touch/applyBounds.ts +30 -0
  79. package/src/touch/index.ts +1 -0
  80. package/src/touch/useTouchDrag.ts +15 -45
  81. package/src/transitions/constants.ts +14 -0
  82. package/src/transitions/easing.ts +23 -11
  83. package/src/transitions/index.ts +5 -0
  84. package/src/transitions/keys.ts +0 -2
  85. package/src/transitions/resolve.ts +86 -11
  86. package/src/transitions/resolveSequence.ts +3 -1
  87. package/src/transitions/runtime.ts +4 -7
  88. package/src/transitions/spring.ts +7 -2
  89. package/src/types.ts +9 -2
  90. package/src/values/extrapolation.ts +21 -0
  91. package/src/values/index.ts +1 -0
  92. package/src/values/useGesture.ts +9 -2
  93. package/src/values/useInterpolatedStyle.ts +5 -12
  94. package/src/values/useShadow.ts +18 -7
  95. package/src/values/useSpring.ts +34 -25
  96. package/src/values/useTransform.ts +24 -20
  97. package/src/values/useTranslateStyle.ts +31 -0
  98. package/dist/chunk-24NUL23E.js +0 -8
  99. package/dist/chunk-4XBX7KOD.js +0 -8
  100. package/dist/chunk-Z5USXWTE.js +0 -8
@@ -3,7 +3,48 @@
3
3
  var reactNativeWorklets = require('react-native-worklets');
4
4
  var reactNativeReanimated = require('react-native-reanimated');
5
5
 
6
- // src/transitions/easing.ts
6
+ // src/transitions/sig.ts
7
+ function stableSig(value) {
8
+ if (value === void 0) return "";
9
+ try {
10
+ return stableStringify(value);
11
+ } catch {
12
+ return String(value);
13
+ }
14
+ }
15
+ function stableStringify(v) {
16
+ if (v === null || typeof v !== "object") {
17
+ if (typeof v === "function" || v === void 0) return "null";
18
+ return JSON.stringify(v);
19
+ }
20
+ if (Array.isArray(v)) {
21
+ return "[" + v.map(stableStringify).join(",") + "]";
22
+ }
23
+ const obj = v;
24
+ const keys = Object.keys(obj).sort();
25
+ return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
26
+ }
27
+
28
+ // src/transitions/keys.ts
29
+ var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
30
+ "type",
31
+ "tension",
32
+ "friction",
33
+ "mass",
34
+ "velocity",
35
+ "duration",
36
+ "easing",
37
+ "delay",
38
+ "repeat",
39
+ "deceleration",
40
+ "clamp"
41
+ ]);
42
+ function isTopLevelTransition(t) {
43
+ if (t === null || typeof t !== "object") return false;
44
+ const keys = Object.keys(t);
45
+ if (keys.length === 0) return false;
46
+ return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
47
+ }
7
48
 
8
49
  // src/internal/warnOnce.ts
9
50
  var warned = /* @__PURE__ */ new Set();
@@ -24,7 +65,7 @@ function warnNonWorkletOnce(key, message) {
24
65
  // src/transitions/easing.ts
25
66
  function ensureWorkletEasing(easing) {
26
67
  if (!easing) return void 0;
27
- const fn = isEasingFactory(easing) ? easing.factory() : easing;
68
+ const fn = unwrapEasingFactory(easing);
28
69
  if (reactNativeWorklets.isWorkletFunction(fn)) return fn;
29
70
  warnNonWorkletOnce(
30
71
  "timing-easing",
@@ -36,10 +77,18 @@ function ensureWorkletEasing(easing) {
36
77
  };
37
78
  return wrapped;
38
79
  }
39
- function isEasingFactory(value) {
40
- return typeof value === "object" && value !== null && "factory" in value && typeof value.factory === "function";
80
+ function unwrapEasingFactory(easing) {
81
+ "worklet";
82
+ if (typeof easing === "object" && easing !== null && "factory" in easing && typeof easing.factory === "function") {
83
+ return easing.factory();
84
+ }
85
+ return easing;
41
86
  }
42
87
 
88
+ // src/transitions/constants.ts
89
+ var DEFAULT_TIMING_DURATION = 250;
90
+ var DEFAULT_LAYOUT_DURATION = 300;
91
+
43
92
  // src/transitions/spring.ts
44
93
  var DEFAULT_SPRING = {
45
94
  tension: 170,
@@ -52,14 +101,11 @@ function springToReanimated(t) {
52
101
  stiffness: t.tension ?? DEFAULT_SPRING.tension,
53
102
  damping: t.friction ?? DEFAULT_SPRING.friction,
54
103
  mass: t.mass ?? DEFAULT_SPRING.mass,
55
- velocity: t.velocity,
56
- restSpeedThreshold: t.restSpeedThreshold,
57
- restDisplacementThreshold: t.restDisplacementThreshold
104
+ velocity: t.velocity
58
105
  };
59
106
  }
60
107
 
61
108
  // src/transitions/resolve.ts
62
- var DEFAULT_TIMING_DURATION = 250;
63
109
  function buildSpring(cfg, toValue, cb) {
64
110
  return reactNativeReanimated.withSpring(toValue, springToReanimated(cfg), cb);
65
111
  }
@@ -92,17 +138,54 @@ function buildOne(cfg, toValue, cb) {
92
138
  if (cfg.type === "timing") return buildTiming(cfg, toValue, cb);
93
139
  return buildSpring(cfg, toValue, cb);
94
140
  }
95
- function applyRepeat(animation, repeat) {
96
- if (repeat === void 0) return animation;
141
+ function normalizeRepeat(repeat) {
142
+ if (repeat === void 0) return void 0;
97
143
  if (repeat === "infinite") {
98
- return reactNativeReanimated.withRepeat(animation, -1, true);
144
+ return {
145
+ count: Number.POSITIVE_INFINITY,
146
+ alternate: true,
147
+ explicitAlternate: false
148
+ };
149
+ }
150
+ const rawCount = typeof repeat === "number" ? repeat : repeat.count;
151
+ const alternate = typeof repeat === "number" ? true : repeat.alternate;
152
+ if (rawCount === "infinite") {
153
+ return {
154
+ count: Number.POSITIVE_INFINITY,
155
+ alternate: alternate ?? true,
156
+ explicitAlternate: alternate !== void 0
157
+ };
158
+ }
159
+ if (!(rawCount >= 1)) {
160
+ warnOnce(
161
+ `repeat-count:${String(rawCount)}`,
162
+ `[inertia] repeat count ${String(rawCount)} is below 1 \u2014 the animation runs once. Use \`repeat: 2\` or more to repeat, or \`repeat: 'infinite'\`. (Reanimated reads a count of 0 as endless, so it is not forwarded.)`
163
+ );
164
+ return void 0;
99
165
  }
100
- if (typeof repeat === "number") {
101
- return reactNativeReanimated.withRepeat(animation, repeat, true);
166
+ return {
167
+ count: rawCount,
168
+ alternate: alternate ?? true,
169
+ explicitAlternate: alternate !== void 0
170
+ };
171
+ }
172
+ function repeatIterationsOf(repeat) {
173
+ return normalizeRepeat(repeat)?.count ?? 1;
174
+ }
175
+ function applyRepeat(animation, repeat, options) {
176
+ const r = normalizeRepeat(repeat);
177
+ if (r === void 0) return animation;
178
+ const count = Number.isFinite(r.count) ? r.count : -1;
179
+ if (options?.sequence) {
180
+ if (r.explicitAlternate && r.alternate) {
181
+ warnOnce(
182
+ "repeat-sequence-alternate",
183
+ "[inertia] repeat.alternate has no effect on a sequence \u2014 Reanimated restarts a sequence at its first step on every pass. Append the reverse steps to the sequence to alternate."
184
+ );
185
+ }
186
+ return reactNativeReanimated.withRepeat(animation, count, false);
102
187
  }
103
- const count = repeat.count === "infinite" ? -1 : repeat.count;
104
- const alternate = repeat.alternate ?? true;
105
- return reactNativeReanimated.withRepeat(animation, count, alternate);
188
+ return reactNativeReanimated.withRepeat(animation, count, r.alternate);
106
189
  }
107
190
  function applyDelay(animation, delay) {
108
191
  if (!delay || delay <= 0) return animation;
@@ -141,7 +224,9 @@ function resolveAnimatableValue(value, base, factory) {
141
224
  (step2, i) => resolveStep(step2, stepBase, factory?.("step", i))
142
225
  );
143
226
  const seq = reactNativeReanimated.withSequence(...animations);
144
- return applyRepeat(seq, base ? repeatOf(base) : void 0);
227
+ return applyRepeat(seq, base ? repeatOf(base) : void 0, {
228
+ sequence: true
229
+ });
145
230
  }
146
231
  const step = value;
147
232
  const cb = factory?.("animation", void 0);
@@ -211,7 +296,6 @@ function bezier(x1, y1, x2, y2, source) {
211
296
  }
212
297
  return reactNativeReanimated.Easing.bezier(x1, y1, x2, y2);
213
298
  }
214
- var DEFAULT_TIMING_DURATION2 = 250;
215
299
  function buildReleaseAnimation(transition, toValue, callback) {
216
300
  "worklet";
217
301
  if (transition.type === "no-animation") {
@@ -228,11 +312,11 @@ function buildReleaseAnimation(transition, toValue, callback) {
228
312
  }
229
313
  if (transition.type === "timing") {
230
314
  const e = transition.easing;
231
- const easingFn = e && typeof e === "object" && "factory" in e ? e.factory() : e ?? reactNativeReanimated.Easing.inOut(reactNativeReanimated.Easing.ease);
315
+ const easingFn = e ? unwrapEasingFactory(e) : reactNativeReanimated.Easing.inOut(reactNativeReanimated.Easing.ease);
232
316
  return reactNativeReanimated.withTiming(
233
317
  toValue,
234
318
  {
235
- duration: transition.duration ?? DEFAULT_TIMING_DURATION2,
319
+ duration: transition.duration ?? DEFAULT_TIMING_DURATION,
236
320
  easing: easingFn
237
321
  },
238
322
  callback
@@ -241,57 +325,14 @@ function buildReleaseAnimation(transition, toValue, callback) {
241
325
  return reactNativeReanimated.withSpring(toValue, springToReanimated(transition), callback);
242
326
  }
243
327
 
244
- // src/transitions/keys.ts
245
- var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
246
- "type",
247
- "tension",
248
- "friction",
249
- "mass",
250
- "velocity",
251
- "restSpeedThreshold",
252
- "restDisplacementThreshold",
253
- "duration",
254
- "easing",
255
- "delay",
256
- "repeat",
257
- "deceleration",
258
- "clamp"
259
- ]);
260
- function isTopLevelTransition(t) {
261
- if (t === null || typeof t !== "object") return false;
262
- const keys = Object.keys(t);
263
- if (keys.length === 0) return false;
264
- return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
265
- }
266
-
267
- // src/transitions/sig.ts
268
- function stableSig(value) {
269
- if (value === void 0) return "";
270
- try {
271
- return stableStringify(value);
272
- } catch {
273
- return String(value);
274
- }
275
- }
276
- function stableStringify(v) {
277
- if (v === null || typeof v !== "object") {
278
- if (typeof v === "function" || v === void 0) return "null";
279
- return JSON.stringify(v);
280
- }
281
- if (Array.isArray(v)) {
282
- return "[" + v.map(stableStringify).join(",") + "]";
283
- }
284
- const obj = v;
285
- const keys = Object.keys(obj).sort();
286
- return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
287
- }
288
-
328
+ exports.DEFAULT_LAYOUT_DURATION = DEFAULT_LAYOUT_DURATION;
289
329
  exports.DEFAULT_SPRING = DEFAULT_SPRING;
290
330
  exports.applyDelay = applyDelay;
291
331
  exports.buildReleaseAnimation = buildReleaseAnimation;
292
332
  exports.cubicBezier = cubicBezier;
293
333
  exports.ensureWorkletEasing = ensureWorkletEasing;
294
334
  exports.isTopLevelTransition = isTopLevelTransition;
335
+ exports.repeatIterationsOf = repeatIterationsOf;
295
336
  exports.resolveAnimatableValue = resolveAnimatableValue;
296
337
  exports.resolveTransition = resolveTransition;
297
338
  exports.springToReanimated = springToReanimated;
@@ -0,0 +1,20 @@
1
+ import { useAnimatedStyle } from 'react-native-reanimated';
2
+
3
+ // src/touch/applyBounds.ts
4
+ function applyBounds(value, min, max, elastic) {
5
+ "worklet";
6
+ if (min !== void 0 && value < min) {
7
+ return elastic > 0 ? min + (value - min) * elastic : min;
8
+ }
9
+ if (max !== void 0 && value > max) {
10
+ return elastic > 0 ? max + (value - max) * elastic : max;
11
+ }
12
+ return value;
13
+ }
14
+ function useTranslateStyle(x, y) {
15
+ return useAnimatedStyle(() => ({
16
+ transform: [{ translateX: x.value }, { translateY: y.value }]
17
+ }));
18
+ }
19
+
20
+ export { applyBounds, useTranslateStyle };
@@ -1,4 +1,4 @@
1
- import { createMotionComponent } from './chunk-IX6SEOSK.mjs';
1
+ import { createMotionComponent } from './chunk-JENYDTXH.mjs';
2
2
  import { Text } from 'react-native';
3
3
 
4
4
  var MotionText = createMotionComponent(Text);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var chunk2UGWAB6N_js = require('./chunk-2UGWAB6N.js');
4
+ var reactNative = require('react-native');
5
+
6
+ var MotionView = chunk2UGWAB6N_js.createMotionComponent(reactNative.View);
7
+
8
+ exports.MotionView = MotionView;
@@ -1,4 +1,4 @@
1
- import { createMotionComponent } from './chunk-IX6SEOSK.mjs';
1
+ import { createMotionComponent } from './chunk-JENYDTXH.mjs';
2
2
  import { View } from 'react-native';
3
3
 
4
4
  var MotionView = createMotionComponent(View);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var chunk2UGWAB6N_js = require('./chunk-2UGWAB6N.js');
4
+ var reactNative = require('react-native');
5
+
6
+ var MotionText = chunk2UGWAB6N_js.createMotionComponent(reactNative.Text);
7
+
8
+ exports.MotionText = MotionText;
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkE3ALFSH2_js = require('./chunk-E3ALFSH2.js');
3
+ var chunk2UGWAB6N_js = require('./chunk-2UGWAB6N.js');
4
4
  var reactNative = require('react-native');
5
5
 
6
- var MotionPressable = chunkE3ALFSH2_js.createMotionComponent(reactNative.Pressable);
6
+ var MotionPressable = chunk2UGWAB6N_js.createMotionComponent(reactNative.Pressable);
7
7
 
8
8
  exports.MotionPressable = MotionPressable;
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var chunk2UGWAB6N_js = require('./chunk-2UGWAB6N.js');
4
+ var reactNative = require('react-native');
5
+
6
+ var MotionImage = chunk2UGWAB6N_js.createMotionComponent(reactNative.Image);
7
+
8
+ exports.MotionImage = MotionImage;
@@ -1,4 +1,4 @@
1
- import { createMotionComponent } from './chunk-IX6SEOSK.mjs';
1
+ import { createMotionComponent } from './chunk-JENYDTXH.mjs';
2
2
  import Animated from 'react-native-reanimated';
3
3
 
4
4
  var MotionFlatList = createMotionComponent(
@@ -1,6 +1,6 @@
1
1
  import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
2
- import { U as UseGestureHandlers } from '../useGesture-CnZQnYHH.mjs';
3
- import { b as TransitionInput, G as GestureLayerTransitions } from '../types-DyJpG64F.mjs';
2
+ import { U as UseGestureHandlers } from '../useGesture-DjszaHWz.mjs';
3
+ import { b as TransitionInput, G as GestureLayerTransitions } from '../types-08mG8fNk.mjs';
4
4
  import 'react';
5
5
  import 'react-native';
6
6
 
@@ -157,4 +157,4 @@ interface UseGestureLayerResult {
157
157
  */
158
158
  declare function useGestureLayer(states: GestureLayerStates, options?: UseGestureLayerOptions): UseGestureLayerResult;
159
159
 
160
- export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
160
+ export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, GestureLayerTransitions, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
@@ -1,6 +1,6 @@
1
1
  import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
2
- import { U as UseGestureHandlers } from '../useGesture-DbH46EBp.js';
3
- import { b as TransitionInput, G as GestureLayerTransitions } from '../types-DyJpG64F.js';
2
+ import { U as UseGestureHandlers } from '../useGesture-D1lHeQQ6.js';
3
+ import { b as TransitionInput, G as GestureLayerTransitions } from '../types-08mG8fNk.js';
4
4
  import 'react';
5
5
  import 'react-native';
6
6
 
@@ -157,4 +157,4 @@ interface UseGestureLayerResult {
157
157
  */
158
158
  declare function useGestureLayer(states: GestureLayerStates, options?: UseGestureLayerOptions): UseGestureLayerResult;
159
159
 
160
- export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
160
+ export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, GestureLayerTransitions, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
@@ -1,26 +1,27 @@
1
1
  'use strict';
2
2
 
3
- var chunkMUT6BTZS_js = require('../chunk-MUT6BTZS.js');
4
- var chunk6AN5X3YE_js = require('../chunk-6AN5X3YE.js');
5
- var chunkWNVHPMBI_js = require('../chunk-WNVHPMBI.js');
3
+ var chunk4EZ5DBL3_js = require('../chunk-4EZ5DBL3.js');
4
+ var chunkKXU6VH2Y_js = require('../chunk-KXU6VH2Y.js');
5
+ var chunkN33GSDNQ_js = require('../chunk-N33GSDNQ.js');
6
6
  var react = require('react');
7
7
  var reactNativeReanimated = require('react-native-reanimated');
8
8
 
9
9
  function useGestureLayer(states, options = {}) {
10
10
  const { disabled: isDisabled = false, transition: transitionInput } = options;
11
- const shouldReduceMotion = chunk6AN5X3YE_js.useShouldReduceMotion();
12
- const transition = chunk6AN5X3YE_js.resolveNamedTransitionProp(
11
+ const shouldReduceMotion = chunkKXU6VH2Y_js.useShouldReduceMotion();
12
+ const transition = chunkKXU6VH2Y_js.resolveNamedTransitionProp(
13
13
  transitionInput,
14
- chunk6AN5X3YE_js.useNamedTransitions()
14
+ chunkKXU6VH2Y_js.useNamedTransitions()
15
15
  );
16
- const gesture = chunkMUT6BTZS_js.useGesture(transition);
16
+ const gesture = chunk4EZ5DBL3_js.useGesture(transition);
17
17
  const disabledProgress = reactNativeReanimated.useSharedValue(0);
18
- const transitionSig = chunkWNVHPMBI_js.stableSig(transition);
18
+ const transitionSig = chunkN33GSDNQ_js.stableSig(transition);
19
19
  react.useEffect(() => {
20
20
  const target = isDisabled ? 1 : 0;
21
21
  const cfg = shouldReduceMotion ? { type: "no-animation" } : disabledTransition(transition) ?? { type: "spring" };
22
- disabledProgress.value = chunkWNVHPMBI_js.resolveTransition(cfg, target);
22
+ disabledProgress.value = chunkN33GSDNQ_js.resolveTransition(cfg, target);
23
23
  }, [isDisabled, shouldReduceMotion, transitionSig, disabledProgress]);
24
+ const statesSig = chunkN33GSDNQ_js.stableSig(states);
24
25
  const meta = react.useMemo(() => {
25
26
  const layers = {
26
27
  rest: states.rest,
@@ -60,14 +61,7 @@ function useGestureLayer(states, options = {}) {
60
61
  restValues[k] = restRaw !== void 0 ? restRaw : isColor ? "transparent" : 0;
61
62
  }
62
63
  return { layers, keys, types, restValues };
63
- }, [
64
- states.rest,
65
- states.hovered,
66
- states.focused,
67
- states.focusVisible,
68
- states.pressed,
69
- states.disabled
70
- ]);
64
+ }, [statesSig]);
71
65
  const style = reactNativeReanimated.useAnimatedStyle(() => {
72
66
  const { layers, keys, types, restValues } = meta;
73
67
  const ph = gesture.hovered.value;
@@ -154,7 +148,7 @@ function useGestureLayer(states, options = {}) {
154
148
  }
155
149
  function disabledTransition(transition) {
156
150
  if (!transition) return void 0;
157
- if (chunkWNVHPMBI_js.isTopLevelTransition(transition)) return transition;
151
+ if (chunkN33GSDNQ_js.isTopLevelTransition(transition)) return transition;
158
152
  return void 0;
159
153
  }
160
154
 
@@ -1,6 +1,6 @@
1
- import { useGesture } from '../chunk-L4JFECXU.mjs';
2
- import { useShouldReduceMotion, resolveNamedTransitionProp, useNamedTransitions } from '../chunk-MFAFB4K7.mjs';
3
- import { stableSig, resolveTransition, isTopLevelTransition } from '../chunk-W7NTRSPD.mjs';
1
+ import { useGesture } from '../chunk-F4HMCXAX.mjs';
2
+ import { useShouldReduceMotion, resolveNamedTransitionProp, useNamedTransitions } from '../chunk-6FCATUMY.mjs';
3
+ import { stableSig, resolveTransition, isTopLevelTransition } from '../chunk-HEAWMZEM.mjs';
4
4
  import { useEffect, useMemo } from 'react';
5
5
  import { useSharedValue, useAnimatedStyle, interpolateColor } from 'react-native-reanimated';
6
6
 
@@ -19,6 +19,7 @@ function useGestureLayer(states, options = {}) {
19
19
  const cfg = shouldReduceMotion ? { type: "no-animation" } : disabledTransition(transition) ?? { type: "spring" };
20
20
  disabledProgress.value = resolveTransition(cfg, target);
21
21
  }, [isDisabled, shouldReduceMotion, transitionSig, disabledProgress]);
22
+ const statesSig = stableSig(states);
22
23
  const meta = useMemo(() => {
23
24
  const layers = {
24
25
  rest: states.rest,
@@ -58,14 +59,7 @@ function useGestureLayer(states, options = {}) {
58
59
  restValues[k] = restRaw !== void 0 ? restRaw : isColor ? "transparent" : 0;
59
60
  }
60
61
  return { layers, keys, types, restValues };
61
- }, [
62
- states.rest,
63
- states.hovered,
64
- states.focused,
65
- states.focusVisible,
66
- states.pressed,
67
- states.disabled
68
- ]);
62
+ }, [statesSig]);
69
63
  const style = useAnimatedStyle(() => {
70
64
  const { layers, keys, types, restValues } = meta;
71
65
  const ph = gesture.hovered.value;
package/dist/index.d.mts CHANGED
@@ -2,11 +2,12 @@ import * as react from 'react';
2
2
  import { ComponentType, ReactNode } from 'react';
3
3
  import * as react_native from 'react-native';
4
4
  import { TextStyle, ImageStyle, ViewStyle, NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
5
- import { M as MotionComponent, V as VariantsMap, a as MotionProps, N as NamedTransitions, b as TransitionInput, T as TransitionConfig, A as AnimatableValue, E as EasingInput, S as SpringTransition, c as TransitionName, d as VariantController } from './types-DyJpG64F.mjs';
6
- export { e as AnimateStyle, f as AnimationCallbackInfo, B as BoxShadowInput, D as DecayTransition, g as EasingFunction, h as EasingFunctionFactory, i as GestureSubStates, j as NoAnimationTransition, P as PerPropertyTransition, R as RegisteredTransitions, k as RepeatConfig, l as SequenceStep, m as TimingTransition, n as Transition } from './types-DyJpG64F.mjs';
5
+ import { M as MotionComponent, V as VariantsMap, a as MotionProps, N as NamedTransitions, b as TransitionInput, T as TransitionConfig, A as AnimatableValue, E as EasingInput, S as SpringTransition, c as TransitionName, d as VariantController } from './types-08mG8fNk.mjs';
6
+ export { e as AnimateStyle, f as AnimationCallbackInfo, B as BoxShadowInput, D as DecayTransition, g as EasingFunction, h as EasingFunctionFactory, G as GestureLayerTransitions, i as GestureSubStates, j as MotionComponentProps, k as NoAnimationTransition, P as PerPropertyTransition, R as RegisteredTransitions, l as RepeatConfig, m as SequenceStep, n as TimingTransition, o as Transition } from './types-08mG8fNk.mjs';
7
+ export { a as applyBounds } from './applyBounds-BYGiHrYO.mjs';
7
8
  import { SharedValue, useAnimatedStyle } from 'react-native-reanimated';
8
9
  export { SharedValue } from 'react-native-reanimated';
9
- export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-CnZQnYHH.mjs';
10
+ export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-DjszaHWz.mjs';
10
11
  export { MotionFlatList } from './motion/FlatList.mjs';
11
12
  export { MotionImage } from './motion/Image.mjs';
12
13
  export { MotionPressable } from './motion/Pressable.mjs';
@@ -341,6 +342,8 @@ declare function cubicBezier(css: string): EasingInput;
341
342
  */
342
343
  declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: number) => number) | undefined;
343
344
 
345
+ declare function isTopLevelTransition(t: unknown): t is TransitionConfig;
346
+
344
347
  /**
345
348
  * Worklet-safe single-step animation builder. Mirrors a subset of
346
349
  * `resolveTransition` for the UI-thread path where the transition config is
@@ -367,6 +370,15 @@ declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: numb
367
370
  */
368
371
  declare function buildReleaseAnimation(transition: TransitionConfig, toValue: number, callback?: AnimationCallback): unknown;
369
372
 
373
+ /**
374
+ * Stable string signature for an arbitrary value — used as a dep-array
375
+ * member so a fresh object literal each render doesn't re-fire an effect
376
+ * unless something structurally changed. Functions serialize as `null`
377
+ * (their identity isn't useful in a sig); `undefined` collapses to an empty
378
+ * string so omitted props compare equal across renders.
379
+ */
380
+ declare function stableSig(value: unknown): string;
381
+
370
382
  /**
371
383
  * The one colour spelling Reanimated's animation drivers cannot accept.
372
384
  *
@@ -624,47 +636,6 @@ declare function useColorCascade(rest: string, layers: readonly ColorCascadeLaye
624
636
  * - `'extend'` — continue the linear slope beyond the range.
625
637
  */
626
638
  type ExtrapolationMode = 'clamp' | 'identity' | 'extend';
627
- interface UseTransformOptions {
628
- extrapolateLeft?: ExtrapolationMode;
629
- extrapolateRight?: ExtrapolationMode;
630
- }
631
- /**
632
- * Derive a value from one or more shared values via a transformer worklet.
633
- *
634
- * ```ts
635
- * const x = useMotionValue(0)
636
- * const y = useMotionValue(0)
637
- * const distance = useTransform(() => Math.sqrt(x.value ** 2 + y.value ** 2))
638
- * ```
639
- *
640
- * The transformer MUST be a worklet — put the `'worklet'` directive as its
641
- * first statement so the consumer's Babel plugin captures the shared values
642
- * it reads as its closure. It runs on the UI thread on every frame where
643
- * any read shared value changes.
644
- *
645
- * A plain function cannot work here, and the hook warns in dev when it gets
646
- * one: the best-effort wrapper it falls back to closes over the opaque
647
- * function reference, not the shared values read inside it, so Reanimated
648
- * can't track them as dependencies — the derived value only refreshes on
649
- * React re-renders, and native builds reject the plain function when the
650
- * closure crosses to the UI thread.
651
- */
652
- declare function useTransform<T>(transformer: () => T): SharedValue<T>;
653
- /**
654
- * Interpolate a numeric shared value onto a range of numbers or colors.
655
- *
656
- * ```ts
657
- * const scroll = useMotionValue(0)
658
- * const headerOpacity = useTransform(scroll, [0, 100], [1, 0])
659
- * const headerColor = useTransform(scroll, [0, 100], ['#fff', '#000'])
660
- * ```
661
- *
662
- * When `outputRange` is numeric, this maps to Reanimated's `interpolate`;
663
- * when it's a tuple of color strings, it maps to `interpolateColor`. The
664
- * input range must be monotonically increasing.
665
- */
666
- declare function useTransform(value: SharedValue<number>, inputRange: readonly number[], outputRange: readonly number[], options?: UseTransformOptions): SharedValue<number>;
667
- declare function useTransform(value: SharedValue<number>, inputRange: readonly number[], outputRange: readonly string[], options?: UseTransformOptions): SharedValue<string>;
668
639
 
669
640
  /**
670
641
  * Numeric style keys `useInterpolatedStyle` can emit directly (not lifted into
@@ -813,9 +784,57 @@ declare function useMotionValue<T extends number | string>(initial: T): SharedVa
813
784
  * must resolve to a spring config — a name registered as timing / decay /
814
785
  * no-animation warns in dev and falls back to the default spring (reach for
815
786
  * `useAnimation` when the named transition's type should be honored).
787
+ *
788
+ * Reduced motion (via `<MotionConfig reducedMotion>`) is honoured: the output
789
+ * is assigned the target directly, with no spring, on both paths.
816
790
  */
817
791
  declare function useSpring(target: number | SharedValue<number>, config?: SpringTransition | TransitionName): SharedValue<number>;
818
792
 
793
+ interface UseTransformOptions {
794
+ extrapolateLeft?: ExtrapolationMode;
795
+ extrapolateRight?: ExtrapolationMode;
796
+ }
797
+ /**
798
+ * Derive a value from one or more shared values via a transformer worklet.
799
+ *
800
+ * ```ts
801
+ * const x = useMotionValue(0)
802
+ * const y = useMotionValue(0)
803
+ * const distance = useTransform(() => {
804
+ * 'worklet'
805
+ * return Math.sqrt(x.value ** 2 + y.value ** 2)
806
+ * })
807
+ * ```
808
+ *
809
+ * The transformer MUST be a worklet — put the `'worklet'` directive as its
810
+ * first statement so the consumer's Babel plugin captures the shared values
811
+ * it reads as its closure. It runs on the UI thread on every frame where
812
+ * any read shared value changes.
813
+ *
814
+ * A plain function cannot work here, and the hook warns in dev when it gets
815
+ * one: the best-effort wrapper it falls back to closes over the opaque
816
+ * function reference, not the shared values read inside it, so Reanimated
817
+ * can't track them as dependencies — the derived value only refreshes on
818
+ * React re-renders, and native builds reject the plain function when the
819
+ * closure crosses to the UI thread.
820
+ */
821
+ declare function useTransform<T>(transformer: () => T): SharedValue<T>;
822
+ /**
823
+ * Interpolate a numeric shared value onto a range of numbers or colors.
824
+ *
825
+ * ```ts
826
+ * const scroll = useMotionValue(0)
827
+ * const headerOpacity = useTransform(scroll, [0, 100], [1, 0])
828
+ * const headerColor = useTransform(scroll, [0, 100], ['#fff', '#000'])
829
+ * ```
830
+ *
831
+ * When `outputRange` is numeric, this maps to Reanimated's `interpolate`;
832
+ * when it's a tuple of color strings, it maps to `interpolateColor`. The
833
+ * input range must be monotonically increasing.
834
+ */
835
+ declare function useTransform(value: SharedValue<number>, inputRange: readonly number[], outputRange: readonly number[], options?: UseTransformOptions): SharedValue<number>;
836
+ declare function useTransform(value: SharedValue<number>, inputRange: readonly number[], outputRange: readonly string[], options?: UseTransformOptions): SharedValue<string>;
837
+
819
838
  interface UseScrollResult {
820
839
  /** Horizontal scroll offset in points. */
821
840
  scrollX: SharedValue<number>;
@@ -979,6 +998,29 @@ interface UseShadowOptions {
979
998
  */
980
999
  declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnType<typeof useAnimatedStyle>;
981
1000
 
1001
+ /**
1002
+ * Animated style that translates by two shared values:
1003
+ * `transform: [{ translateX: x }, { translateY: y }]`.
1004
+ *
1005
+ * This is the style fragment every drag-style hook returns (`useTouchDrag`,
1006
+ * and `useDrag` / `usePan` / `useSwipe` in `@rootnative/inertia-gestures`).
1007
+ * Use it directly when a custom gesture owns its own translation values.
1008
+ *
1009
+ * The style owns the whole `transform` key. Do not stack a second transform
1010
+ * style beside it — `transform` is one key in React Native, so the later
1011
+ * style replaces this one instead of merging. Nest another animated view, or
1012
+ * build one style from `x` / `y` with `useInterpolatedStyle`, to add a
1013
+ * transform.
1014
+ *
1015
+ * ```tsx
1016
+ * const x = useMotionValue(0)
1017
+ * const y = useMotionValue(0)
1018
+ * const style = useTranslateStyle(x, y)
1019
+ * return <Motion.View style={style} />
1020
+ * ```
1021
+ */
1022
+ declare function useTranslateStyle(x: SharedValue<number>, y: SharedValue<number>): ReturnType<typeof useAnimatedStyle>;
1023
+
982
1024
  /**
983
1025
  * Build a controller for a variants map. The controller is the imperative
984
1026
  * escape hatch — pass it to a Motion primitive via `controller={...}` and
@@ -992,4 +1034,4 @@ declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnTyp
992
1034
  */
993
1035
  declare function useVariants<V extends Readonly<Record<string, object>>>(variants: V, initial?: keyof V & string): VariantController<keyof V & string>;
994
1036
 
995
- export { AnimatableValue, type AnimationCallback, type Animator, type BoxShadowLayer, type ColorCascadeLayer, type ColorStyleKey, EasingInput, type ExtrapolationMode, type InterpolatedStyle, type InterpolatedStyleMap, Motion, MotionComponent, MotionConfig, type MotionConfigProps, type MotionConfigValue, MotionProps, NamedTransitions, type NumericStyleKey, Presence, type PresenceContextValue, type ReducedMotion, type ShadowConfig, SpringTransition, Stagger, type StaggerProps, TRANSPARENT, type TransformKey, TransitionConfig, TransitionInput, TransitionName, type UseColorCascadeOptions, type UseColorTransitionOptions, type UseInterpolatedStyleOptions, type UseScrollResult, type UseShadowOptions, type UseTransformOptions, VariantController, VariantsMap, applyDelay, buildReleaseAnimation, createMotionComponent, cubicBezier, ensureWorkletEasing, resolveAnimatableValue, resolveNamedTransition, resolveTransition, useAnimation, useAnimator, useBooleanSpring, useColorCascade, useColorTransition, useInterpolatedStyle, useMotionConfig, useMotionValue, useNamedTransitions, usePresence, useScroll, useShadow, useShouldReduceMotion, useSpring, useStaggerDelay, useTransform, useVariants };
1037
+ export { AnimatableValue, type AnimationCallback, type Animator, type BoxShadowLayer, type CallbackFactory, type ColorCascadeLayer, type ColorStyleKey, EasingInput, type ExtrapolationMode, type InterpolatedStyle, type InterpolatedStyleMap, Motion, MotionComponent, MotionConfig, type MotionConfigProps, type MotionConfigValue, MotionProps, NamedTransitions, type NumericStyleKey, Presence, type PresenceContextValue, type ReducedMotion, type ShadowConfig, SpringTransition, Stagger, type StaggerProps, TRANSPARENT, type TransformKey, TransitionConfig, TransitionInput, TransitionName, type UseColorCascadeOptions, type UseColorTransitionOptions, type UseInterpolatedStyleOptions, type UseScrollResult, type UseShadowOptions, type UseTransformOptions, VariantController, VariantsMap, applyDelay, buildReleaseAnimation, createMotionComponent, cubicBezier, ensureWorkletEasing, isTopLevelTransition, resolveAnimatableValue, resolveNamedTransition, resolveTransition, stableSig, useAnimation, useAnimator, useBooleanSpring, useColorCascade, useColorTransition, useInterpolatedStyle, useMotionConfig, useMotionValue, useNamedTransitions, usePresence, useScroll, useShadow, useShouldReduceMotion, useSpring, useStaggerDelay, useTransform, useTranslateStyle, useVariants };