@rootnative/inertia 0.0.9 → 0.0.11

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 (105) hide show
  1. package/CHANGELOG.md +95 -1
  2. package/README.md +8 -8
  3. package/dist/{chunk-MFAFB4K7.mjs → chunk-2Q6JMDYZ.mjs} +8 -10
  4. package/dist/chunk-2UREDR4Z.js +8 -0
  5. package/dist/{chunk-ZBHQPVWE.js → chunk-3PB27UIE.js} +2 -2
  6. package/dist/{chunk-IX6SEOSK.mjs → chunk-5EYIZG72.mjs} +60 -45
  7. package/dist/{chunk-EN4PN7X3.mjs → chunk-7RMSLKQQ.mjs} +1 -1
  8. package/dist/{chunk-6YIUETBF.mjs → chunk-DT2KVAAO.mjs} +1 -1
  9. package/dist/{chunk-L4JFECXU.mjs → chunk-FKJLPYGY.mjs} +6 -3
  10. package/dist/{chunk-E3ALFSH2.js → chunk-HBURWGCZ.js} +86 -71
  11. package/dist/chunk-JAJHKJC5.js +8 -0
  12. package/dist/chunk-JBMTTICC.js +8 -0
  13. package/dist/{chunk-GSUC4HWP.mjs → chunk-JGQ6YRDN.mjs} +1 -1
  14. package/dist/chunk-KFHZMFAX.js +23 -0
  15. package/dist/{chunk-M4766VUV.mjs → chunk-LHW4VNWD.mjs} +1 -1
  16. package/dist/{chunk-MUT6BTZS.js → chunk-NTG6PSGZ.js} +10 -7
  17. package/dist/chunk-OH46TGEA.mjs +20 -0
  18. package/dist/{chunk-6AN5X3YE.js → chunk-QDMSFRQR.js} +10 -11
  19. package/dist/{chunk-W7NTRSPD.mjs → chunk-QIRKPDXA.mjs} +118 -68
  20. package/dist/{chunk-WNVHPMBI.js → chunk-QX5JHRZ2.js} +118 -66
  21. package/dist/{chunk-6NOCY764.js → chunk-R7YD6L3D.js} +2 -2
  22. package/dist/{chunk-JBK5ZLMH.mjs → chunk-RO4XFTQ6.mjs} +1 -1
  23. package/dist/{chunk-QNLSCOR5.mjs → chunk-UGYBFAVY.mjs} +1 -1
  24. package/dist/{chunk-IHVMNOS4.js → chunk-XLKI2MSD.js} +2 -2
  25. package/dist/gestureLayer/index.d.mts +3 -3
  26. package/dist/gestureLayer/index.d.ts +3 -3
  27. package/dist/gestureLayer/index.js +12 -18
  28. package/dist/gestureLayer/index.mjs +5 -11
  29. package/dist/index.d.mts +108 -49
  30. package/dist/index.d.ts +108 -49
  31. package/dist/index.js +114 -91
  32. package/dist/index.mjs +66 -59
  33. package/dist/motion/FlatList.d.mts +2 -1
  34. package/dist/motion/FlatList.d.ts +2 -1
  35. package/dist/motion/FlatList.js +5 -5
  36. package/dist/motion/FlatList.mjs +4 -4
  37. package/dist/motion/Image.d.mts +2 -1
  38. package/dist/motion/Image.d.ts +2 -1
  39. package/dist/motion/Image.js +5 -5
  40. package/dist/motion/Image.mjs +4 -4
  41. package/dist/motion/Pressable.d.mts +2 -1
  42. package/dist/motion/Pressable.d.ts +2 -1
  43. package/dist/motion/Pressable.js +5 -5
  44. package/dist/motion/Pressable.mjs +4 -4
  45. package/dist/motion/ScrollView.d.mts +2 -1
  46. package/dist/motion/ScrollView.d.ts +2 -1
  47. package/dist/motion/ScrollView.js +5 -5
  48. package/dist/motion/ScrollView.mjs +4 -4
  49. package/dist/motion/Text.d.mts +2 -1
  50. package/dist/motion/Text.d.ts +2 -1
  51. package/dist/motion/Text.js +5 -5
  52. package/dist/motion/Text.mjs +4 -4
  53. package/dist/motion/View.d.mts +2 -1
  54. package/dist/motion/View.d.ts +2 -1
  55. package/dist/motion/View.js +5 -5
  56. package/dist/motion/View.mjs +4 -4
  57. package/dist/touch/index.d.mts +5 -3
  58. package/dist/touch/index.d.ts +5 -3
  59. package/dist/touch/index.js +16 -31
  60. package/dist/touch/index.mjs +11 -29
  61. package/dist/{types-DyJpG64F.d.mts → types-C5Zbs9MC.d.mts} +22 -4
  62. package/dist/{types-DyJpG64F.d.ts → types-C5Zbs9MC.d.ts} +22 -4
  63. package/dist/{useGesture-DbH46EBp.d.ts → useGesture-Be0ZhCWj.d.ts} +1 -1
  64. package/dist/{useGesture-CnZQnYHH.d.mts → useGesture-Ve8EGjTr.d.mts} +1 -1
  65. package/dist/useTranslateStyle-BDrOD97O.d.mts +58 -0
  66. package/dist/useTranslateStyle-BDrOD97O.d.ts +58 -0
  67. package/jest-preset.js +31 -2
  68. package/llms.txt +2 -1
  69. package/package.json +15 -12
  70. package/src/config/namedTransitions.ts +7 -9
  71. package/src/gestureLayer/index.ts +3 -0
  72. package/src/gestureLayer/useGestureLayer.ts +6 -9
  73. package/src/gestures/focusVisibility.ts +19 -17
  74. package/src/gestures/index.ts +1 -1
  75. package/src/index.ts +12 -0
  76. package/src/internal/boxShadow.ts +24 -2
  77. package/src/layout/resolveLayout.ts +4 -1
  78. package/src/layout/useSharedLayout.ts +2 -1
  79. package/src/motion/createMotionComponent.tsx +92 -44
  80. package/src/presence/Presence.tsx +5 -7
  81. package/src/touch/applyBounds.ts +30 -0
  82. package/src/touch/index.ts +1 -0
  83. package/src/touch/useTouchDrag.ts +18 -46
  84. package/src/transitions/constants.ts +14 -0
  85. package/src/transitions/easing.ts +23 -11
  86. package/src/transitions/index.ts +5 -0
  87. package/src/transitions/keys.ts +0 -2
  88. package/src/transitions/resolve.ts +86 -11
  89. package/src/transitions/resolveSequence.ts +45 -3
  90. package/src/transitions/runtime.ts +4 -7
  91. package/src/transitions/spring.ts +7 -2
  92. package/src/types.ts +23 -3
  93. package/src/values/extrapolation.ts +21 -0
  94. package/src/values/index.ts +3 -0
  95. package/src/values/useColorCascade.ts +3 -3
  96. package/src/values/useColorTransition.ts +17 -2
  97. package/src/values/useGesture.ts +9 -2
  98. package/src/values/useInterpolatedStyle.ts +13 -13
  99. package/src/values/useShadow.ts +36 -9
  100. package/src/values/useSpring.ts +34 -25
  101. package/src/values/useTransform.ts +24 -20
  102. package/src/values/useTranslateStyle.ts +47 -0
  103. package/dist/chunk-24NUL23E.js +0 -8
  104. package/dist/chunk-4XBX7KOD.js +0 -8
  105. package/dist/chunk-Z5USXWTE.js +0 -8
@@ -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-FKJLPYGY.mjs';
2
+ import { useShouldReduceMotion, resolveNamedTransitionProp, useNamedTransitions } from '../chunk-2Q6JMDYZ.mjs';
3
+ import { stableSig, resolveTransition, isTopLevelTransition } from '../chunk-QIRKPDXA.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';
7
- import { SharedValue, useAnimatedStyle } from 'react-native-reanimated';
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-C5Zbs9MC.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-C5Zbs9MC.mjs';
7
+ export { T as TranslateStyle, a as applyBounds, u as useTranslateStyle } from './useTranslateStyle-BDrOD97O.mjs';
8
+ import { SharedValue } 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-Ve8EGjTr.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';
@@ -273,6 +274,12 @@ declare function resolveTransition(config: TransitionConfig | undefined, toValue
273
274
  * 3. array of either → `withSequence` of resolved steps, with the
274
275
  * top-level `repeat` applied at the **sequence level** (not per step).
275
276
  * Per-step `repeat` overrides remain step-local.
277
+ *
278
+ * `withSequence` writes a `finished` flag onto each argument it is handed, so
279
+ * a bare target throws `Cannot create property 'finished' on number` and takes
280
+ * the whole render down with it. Two paths produce bare targets, and both are
281
+ * handled below rather than at the call site: reduced motion (every step) and
282
+ * a per-step `{ type: 'no-animation' }` override (some steps).
276
283
  */
277
284
  declare function resolveAnimatableValue<V extends number | string>(value: AnimatableValue<V>, base: TransitionConfig | undefined, factory?: CallbackFactory): unknown;
278
285
 
@@ -341,6 +348,8 @@ declare function cubicBezier(css: string): EasingInput;
341
348
  */
342
349
  declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: number) => number) | undefined;
343
350
 
351
+ declare function isTopLevelTransition(t: unknown): t is TransitionConfig;
352
+
344
353
  /**
345
354
  * Worklet-safe single-step animation builder. Mirrors a subset of
346
355
  * `resolveTransition` for the UI-thread path where the transition config is
@@ -367,6 +376,15 @@ declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: numb
367
376
  */
368
377
  declare function buildReleaseAnimation(transition: TransitionConfig, toValue: number, callback?: AnimationCallback): unknown;
369
378
 
379
+ /**
380
+ * Stable string signature for an arbitrary value — used as a dep-array
381
+ * member so a fresh object literal each render doesn't re-fire an effect
382
+ * unless something structurally changed. Functions serialize as `null`
383
+ * (their identity isn't useful in a sig); `undefined` collapses to an empty
384
+ * string so omitted props compare equal across renders.
385
+ */
386
+ declare function stableSig(value: unknown): string;
387
+
370
388
  /**
371
389
  * The one colour spelling Reanimated's animation drivers cannot accept.
372
390
  *
@@ -521,6 +539,22 @@ declare function useBooleanSpring(active: boolean, springConfig?: SpringTransiti
521
539
  * returned style fragment is always a legal RN style.
522
540
  */
523
541
  type ColorStyleKey = 'backgroundColor' | 'color' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'tintColor' | 'shadowColor';
542
+ /**
543
+ * A one-key colour style fragment, as returned by {@link useColorTransition}
544
+ * and {@link useColorCascade}.
545
+ *
546
+ * Deliberately **not** `ReturnType<typeof useAnimatedStyle>`. Reanimated 4.5
547
+ * brands that value (`AnimatedStyleHandle`), and a branded type is rejected
548
+ * inside a `StyleProp` array — so every call site would need a cast, which is
549
+ * the defect `InterpolatedStyle` was introduced to remove in `0.0.9`. The brand
550
+ * is compile-time only, so the runtime value is unchanged.
551
+ *
552
+ * Optional per key because which slot is filled is chosen at run time from
553
+ * `options.key`; exactly one is ever present.
554
+ */
555
+ type ColorStyle = {
556
+ [K in ColorStyleKey]?: string;
557
+ };
524
558
  interface UseColorTransitionOptions {
525
559
  /**
526
560
  * Which style slot the interpolated color is emitted under. Defaults to
@@ -552,7 +586,7 @@ interface UseColorTransitionOptions {
552
586
  * compose into a hand-rolled `useAnimatedStyle`), use `useTransform`
553
587
  * directly with a color output range.
554
588
  */
555
- declare function useColorTransition(progress: SharedValue<number>, range: readonly [string, string], options?: UseColorTransitionOptions): ReturnType<typeof useAnimatedStyle>;
589
+ declare function useColorTransition(progress: SharedValue<number>, range: readonly [string, string], options?: UseColorTransitionOptions): ColorStyle;
556
590
 
557
591
  /**
558
592
  * One layer in a color cascade: its own `progress` shared value (0→1) and the
@@ -612,7 +646,7 @@ interface UseColorCascadeOptions {
612
646
  * `rest`, the layer count, or **which shared value drives a layer** all rewire
613
647
  * the worklet as you'd expect.
614
648
  */
615
- declare function useColorCascade(rest: string, layers: readonly ColorCascadeLayer[], options?: UseColorCascadeOptions): ReturnType<typeof useAnimatedStyle>;
649
+ declare function useColorCascade(rest: string, layers: readonly ColorCascadeLayer[], options?: UseColorCascadeOptions): ColorStyle;
616
650
 
617
651
  /**
618
652
  * Extrapolation behavior at the edges of the input range. Mirrors
@@ -624,47 +658,6 @@ declare function useColorCascade(rest: string, layers: readonly ColorCascadeLaye
624
658
  * - `'extend'` — continue the linear slope beyond the range.
625
659
  */
626
660
  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
661
 
669
662
  /**
670
663
  * Numeric style keys `useInterpolatedStyle` can emit directly (not lifted into
@@ -813,9 +806,57 @@ declare function useMotionValue<T extends number | string>(initial: T): SharedVa
813
806
  * must resolve to a spring config — a name registered as timing / decay /
814
807
  * no-animation warns in dev and falls back to the default spring (reach for
815
808
  * `useAnimation` when the named transition's type should be honored).
809
+ *
810
+ * Reduced motion (via `<MotionConfig reducedMotion>`) is honoured: the output
811
+ * is assigned the target directly, with no spring, on both paths.
816
812
  */
817
813
  declare function useSpring(target: number | SharedValue<number>, config?: SpringTransition | TransitionName): SharedValue<number>;
818
814
 
815
+ interface UseTransformOptions {
816
+ extrapolateLeft?: ExtrapolationMode;
817
+ extrapolateRight?: ExtrapolationMode;
818
+ }
819
+ /**
820
+ * Derive a value from one or more shared values via a transformer worklet.
821
+ *
822
+ * ```ts
823
+ * const x = useMotionValue(0)
824
+ * const y = useMotionValue(0)
825
+ * const distance = useTransform(() => {
826
+ * 'worklet'
827
+ * return Math.sqrt(x.value ** 2 + y.value ** 2)
828
+ * })
829
+ * ```
830
+ *
831
+ * The transformer MUST be a worklet — put the `'worklet'` directive as its
832
+ * first statement so the consumer's Babel plugin captures the shared values
833
+ * it reads as its closure. It runs on the UI thread on every frame where
834
+ * any read shared value changes.
835
+ *
836
+ * A plain function cannot work here, and the hook warns in dev when it gets
837
+ * one: the best-effort wrapper it falls back to closes over the opaque
838
+ * function reference, not the shared values read inside it, so Reanimated
839
+ * can't track them as dependencies — the derived value only refreshes on
840
+ * React re-renders, and native builds reject the plain function when the
841
+ * closure crosses to the UI thread.
842
+ */
843
+ declare function useTransform<T>(transformer: () => T): SharedValue<T>;
844
+ /**
845
+ * Interpolate a numeric shared value onto a range of numbers or colors.
846
+ *
847
+ * ```ts
848
+ * const scroll = useMotionValue(0)
849
+ * const headerOpacity = useTransform(scroll, [0, 100], [1, 0])
850
+ * const headerColor = useTransform(scroll, [0, 100], ['#fff', '#000'])
851
+ * ```
852
+ *
853
+ * When `outputRange` is numeric, this maps to Reanimated's `interpolate`;
854
+ * when it's a tuple of color strings, it maps to `interpolateColor`. The
855
+ * input range must be monotonically increasing.
856
+ */
857
+ declare function useTransform(value: SharedValue<number>, inputRange: readonly number[], outputRange: readonly number[], options?: UseTransformOptions): SharedValue<number>;
858
+ declare function useTransform(value: SharedValue<number>, inputRange: readonly number[], outputRange: readonly string[], options?: UseTransformOptions): SharedValue<string>;
859
+
819
860
  interface UseScrollResult {
820
861
  /** Horizontal scroll offset in points. */
821
862
  scrollX: SharedValue<number>;
@@ -928,6 +969,24 @@ interface ShadowConfig {
928
969
  */
929
970
  boxShadow?: string | readonly BoxShadowLayer[];
930
971
  }
972
+ /**
973
+ * The style fragment {@link useShadow} returns: the native shadow keys plus the
974
+ * CSS `boxShadow`, each present only when the paired configs drive it.
975
+ *
976
+ * Deliberately **not** `ReturnType<typeof useAnimatedStyle>` — see
977
+ * {@link ColorStyle} for why the brand is erased here.
978
+ */
979
+ type ShadowStyle = {
980
+ shadowColor?: string;
981
+ shadowOffset?: {
982
+ width: number;
983
+ height: number;
984
+ };
985
+ shadowOpacity?: number;
986
+ shadowRadius?: number;
987
+ elevation?: number;
988
+ boxShadow?: string;
989
+ };
931
990
  interface UseShadowOptions {
932
991
  /** Shadow state at `progress === 0`. */
933
992
  from: ShadowConfig;
@@ -977,7 +1036,7 @@ interface UseShadowOptions {
977
1036
  * })
978
1037
  * ```
979
1038
  */
980
- declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnType<typeof useAnimatedStyle>;
1039
+ declare function useShadow({ from, to, progress, }: UseShadowOptions): ShadowStyle;
981
1040
 
982
1041
  /**
983
1042
  * Build a controller for a variants map. The controller is the imperative
@@ -992,4 +1051,4 @@ declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnTyp
992
1051
  */
993
1052
  declare function useVariants<V extends Readonly<Record<string, object>>>(variants: V, initial?: keyof V & string): VariantController<keyof V & string>;
994
1053
 
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 };
1054
+ export { AnimatableValue, type AnimationCallback, type Animator, type BoxShadowLayer, type CallbackFactory, type ColorCascadeLayer, type ColorStyle, 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, type ShadowStyle, 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, useVariants };
package/dist/index.d.ts 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.js';
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.js';
7
- import { SharedValue, useAnimatedStyle } from 'react-native-reanimated';
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-C5Zbs9MC.js';
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-C5Zbs9MC.js';
7
+ export { T as TranslateStyle, a as applyBounds, u as useTranslateStyle } from './useTranslateStyle-BDrOD97O.js';
8
+ import { SharedValue } 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-DbH46EBp.js';
10
+ export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-Be0ZhCWj.js';
10
11
  export { MotionFlatList } from './motion/FlatList.js';
11
12
  export { MotionImage } from './motion/Image.js';
12
13
  export { MotionPressable } from './motion/Pressable.js';
@@ -273,6 +274,12 @@ declare function resolveTransition(config: TransitionConfig | undefined, toValue
273
274
  * 3. array of either → `withSequence` of resolved steps, with the
274
275
  * top-level `repeat` applied at the **sequence level** (not per step).
275
276
  * Per-step `repeat` overrides remain step-local.
277
+ *
278
+ * `withSequence` writes a `finished` flag onto each argument it is handed, so
279
+ * a bare target throws `Cannot create property 'finished' on number` and takes
280
+ * the whole render down with it. Two paths produce bare targets, and both are
281
+ * handled below rather than at the call site: reduced motion (every step) and
282
+ * a per-step `{ type: 'no-animation' }` override (some steps).
276
283
  */
277
284
  declare function resolveAnimatableValue<V extends number | string>(value: AnimatableValue<V>, base: TransitionConfig | undefined, factory?: CallbackFactory): unknown;
278
285
 
@@ -341,6 +348,8 @@ declare function cubicBezier(css: string): EasingInput;
341
348
  */
342
349
  declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: number) => number) | undefined;
343
350
 
351
+ declare function isTopLevelTransition(t: unknown): t is TransitionConfig;
352
+
344
353
  /**
345
354
  * Worklet-safe single-step animation builder. Mirrors a subset of
346
355
  * `resolveTransition` for the UI-thread path where the transition config is
@@ -367,6 +376,15 @@ declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: numb
367
376
  */
368
377
  declare function buildReleaseAnimation(transition: TransitionConfig, toValue: number, callback?: AnimationCallback): unknown;
369
378
 
379
+ /**
380
+ * Stable string signature for an arbitrary value — used as a dep-array
381
+ * member so a fresh object literal each render doesn't re-fire an effect
382
+ * unless something structurally changed. Functions serialize as `null`
383
+ * (their identity isn't useful in a sig); `undefined` collapses to an empty
384
+ * string so omitted props compare equal across renders.
385
+ */
386
+ declare function stableSig(value: unknown): string;
387
+
370
388
  /**
371
389
  * The one colour spelling Reanimated's animation drivers cannot accept.
372
390
  *
@@ -521,6 +539,22 @@ declare function useBooleanSpring(active: boolean, springConfig?: SpringTransiti
521
539
  * returned style fragment is always a legal RN style.
522
540
  */
523
541
  type ColorStyleKey = 'backgroundColor' | 'color' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'tintColor' | 'shadowColor';
542
+ /**
543
+ * A one-key colour style fragment, as returned by {@link useColorTransition}
544
+ * and {@link useColorCascade}.
545
+ *
546
+ * Deliberately **not** `ReturnType<typeof useAnimatedStyle>`. Reanimated 4.5
547
+ * brands that value (`AnimatedStyleHandle`), and a branded type is rejected
548
+ * inside a `StyleProp` array — so every call site would need a cast, which is
549
+ * the defect `InterpolatedStyle` was introduced to remove in `0.0.9`. The brand
550
+ * is compile-time only, so the runtime value is unchanged.
551
+ *
552
+ * Optional per key because which slot is filled is chosen at run time from
553
+ * `options.key`; exactly one is ever present.
554
+ */
555
+ type ColorStyle = {
556
+ [K in ColorStyleKey]?: string;
557
+ };
524
558
  interface UseColorTransitionOptions {
525
559
  /**
526
560
  * Which style slot the interpolated color is emitted under. Defaults to
@@ -552,7 +586,7 @@ interface UseColorTransitionOptions {
552
586
  * compose into a hand-rolled `useAnimatedStyle`), use `useTransform`
553
587
  * directly with a color output range.
554
588
  */
555
- declare function useColorTransition(progress: SharedValue<number>, range: readonly [string, string], options?: UseColorTransitionOptions): ReturnType<typeof useAnimatedStyle>;
589
+ declare function useColorTransition(progress: SharedValue<number>, range: readonly [string, string], options?: UseColorTransitionOptions): ColorStyle;
556
590
 
557
591
  /**
558
592
  * One layer in a color cascade: its own `progress` shared value (0→1) and the
@@ -612,7 +646,7 @@ interface UseColorCascadeOptions {
612
646
  * `rest`, the layer count, or **which shared value drives a layer** all rewire
613
647
  * the worklet as you'd expect.
614
648
  */
615
- declare function useColorCascade(rest: string, layers: readonly ColorCascadeLayer[], options?: UseColorCascadeOptions): ReturnType<typeof useAnimatedStyle>;
649
+ declare function useColorCascade(rest: string, layers: readonly ColorCascadeLayer[], options?: UseColorCascadeOptions): ColorStyle;
616
650
 
617
651
  /**
618
652
  * Extrapolation behavior at the edges of the input range. Mirrors
@@ -624,47 +658,6 @@ declare function useColorCascade(rest: string, layers: readonly ColorCascadeLaye
624
658
  * - `'extend'` — continue the linear slope beyond the range.
625
659
  */
626
660
  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
661
 
669
662
  /**
670
663
  * Numeric style keys `useInterpolatedStyle` can emit directly (not lifted into
@@ -813,9 +806,57 @@ declare function useMotionValue<T extends number | string>(initial: T): SharedVa
813
806
  * must resolve to a spring config — a name registered as timing / decay /
814
807
  * no-animation warns in dev and falls back to the default spring (reach for
815
808
  * `useAnimation` when the named transition's type should be honored).
809
+ *
810
+ * Reduced motion (via `<MotionConfig reducedMotion>`) is honoured: the output
811
+ * is assigned the target directly, with no spring, on both paths.
816
812
  */
817
813
  declare function useSpring(target: number | SharedValue<number>, config?: SpringTransition | TransitionName): SharedValue<number>;
818
814
 
815
+ interface UseTransformOptions {
816
+ extrapolateLeft?: ExtrapolationMode;
817
+ extrapolateRight?: ExtrapolationMode;
818
+ }
819
+ /**
820
+ * Derive a value from one or more shared values via a transformer worklet.
821
+ *
822
+ * ```ts
823
+ * const x = useMotionValue(0)
824
+ * const y = useMotionValue(0)
825
+ * const distance = useTransform(() => {
826
+ * 'worklet'
827
+ * return Math.sqrt(x.value ** 2 + y.value ** 2)
828
+ * })
829
+ * ```
830
+ *
831
+ * The transformer MUST be a worklet — put the `'worklet'` directive as its
832
+ * first statement so the consumer's Babel plugin captures the shared values
833
+ * it reads as its closure. It runs on the UI thread on every frame where
834
+ * any read shared value changes.
835
+ *
836
+ * A plain function cannot work here, and the hook warns in dev when it gets
837
+ * one: the best-effort wrapper it falls back to closes over the opaque
838
+ * function reference, not the shared values read inside it, so Reanimated
839
+ * can't track them as dependencies — the derived value only refreshes on
840
+ * React re-renders, and native builds reject the plain function when the
841
+ * closure crosses to the UI thread.
842
+ */
843
+ declare function useTransform<T>(transformer: () => T): SharedValue<T>;
844
+ /**
845
+ * Interpolate a numeric shared value onto a range of numbers or colors.
846
+ *
847
+ * ```ts
848
+ * const scroll = useMotionValue(0)
849
+ * const headerOpacity = useTransform(scroll, [0, 100], [1, 0])
850
+ * const headerColor = useTransform(scroll, [0, 100], ['#fff', '#000'])
851
+ * ```
852
+ *
853
+ * When `outputRange` is numeric, this maps to Reanimated's `interpolate`;
854
+ * when it's a tuple of color strings, it maps to `interpolateColor`. The
855
+ * input range must be monotonically increasing.
856
+ */
857
+ declare function useTransform(value: SharedValue<number>, inputRange: readonly number[], outputRange: readonly number[], options?: UseTransformOptions): SharedValue<number>;
858
+ declare function useTransform(value: SharedValue<number>, inputRange: readonly number[], outputRange: readonly string[], options?: UseTransformOptions): SharedValue<string>;
859
+
819
860
  interface UseScrollResult {
820
861
  /** Horizontal scroll offset in points. */
821
862
  scrollX: SharedValue<number>;
@@ -928,6 +969,24 @@ interface ShadowConfig {
928
969
  */
929
970
  boxShadow?: string | readonly BoxShadowLayer[];
930
971
  }
972
+ /**
973
+ * The style fragment {@link useShadow} returns: the native shadow keys plus the
974
+ * CSS `boxShadow`, each present only when the paired configs drive it.
975
+ *
976
+ * Deliberately **not** `ReturnType<typeof useAnimatedStyle>` — see
977
+ * {@link ColorStyle} for why the brand is erased here.
978
+ */
979
+ type ShadowStyle = {
980
+ shadowColor?: string;
981
+ shadowOffset?: {
982
+ width: number;
983
+ height: number;
984
+ };
985
+ shadowOpacity?: number;
986
+ shadowRadius?: number;
987
+ elevation?: number;
988
+ boxShadow?: string;
989
+ };
931
990
  interface UseShadowOptions {
932
991
  /** Shadow state at `progress === 0`. */
933
992
  from: ShadowConfig;
@@ -977,7 +1036,7 @@ interface UseShadowOptions {
977
1036
  * })
978
1037
  * ```
979
1038
  */
980
- declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnType<typeof useAnimatedStyle>;
1039
+ declare function useShadow({ from, to, progress, }: UseShadowOptions): ShadowStyle;
981
1040
 
982
1041
  /**
983
1042
  * Build a controller for a variants map. The controller is the imperative
@@ -992,4 +1051,4 @@ declare function useShadow({ from, to, progress, }: UseShadowOptions): ReturnTyp
992
1051
  */
993
1052
  declare function useVariants<V extends Readonly<Record<string, object>>>(variants: V, initial?: keyof V & string): VariantController<keyof V & string>;
994
1053
 
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 };
1054
+ export { AnimatableValue, type AnimationCallback, type Animator, type BoxShadowLayer, type CallbackFactory, type ColorCascadeLayer, type ColorStyle, 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, type ShadowStyle, 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, useVariants };