@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.
- package/CHANGELOG.md +68 -1
- package/README.md +7 -7
- package/dist/applyBounds-BYGiHrYO.d.mts +18 -0
- package/dist/applyBounds-BYGiHrYO.d.ts +18 -0
- package/dist/{chunk-E3ALFSH2.js → chunk-2UGWAB6N.js} +78 -70
- package/dist/{chunk-ZBHQPVWE.js → chunk-3ZNHPT5Z.js} +2 -2
- package/dist/{chunk-IHVMNOS4.js → chunk-46766TBM.js} +2 -2
- package/dist/{chunk-MUT6BTZS.js → chunk-4EZ5DBL3.js} +10 -7
- package/dist/{chunk-MFAFB4K7.mjs → chunk-6FCATUMY.mjs} +8 -10
- package/dist/{chunk-6YIUETBF.mjs → chunk-7BH3CAO5.mjs} +1 -1
- package/dist/{chunk-JBK5ZLMH.mjs → chunk-CUHOCONB.mjs} +1 -1
- package/dist/{chunk-M4766VUV.mjs → chunk-DRA2K53O.mjs} +1 -1
- package/dist/{chunk-L4JFECXU.mjs → chunk-F4HMCXAX.mjs} +6 -3
- package/dist/{chunk-W7NTRSPD.mjs → chunk-HEAWMZEM.mjs} +105 -66
- package/dist/{chunk-IX6SEOSK.mjs → chunk-JENYDTXH.mjs} +52 -44
- package/dist/chunk-KFHZMFAX.js +23 -0
- package/dist/{chunk-6AN5X3YE.js → chunk-KXU6VH2Y.js} +10 -11
- package/dist/{chunk-WNVHPMBI.js → chunk-N33GSDNQ.js} +106 -65
- package/dist/chunk-OH46TGEA.mjs +20 -0
- package/dist/{chunk-QNLSCOR5.mjs → chunk-OLOSU2BD.mjs} +1 -1
- package/dist/chunk-PLKXCJIB.js +8 -0
- package/dist/{chunk-GSUC4HWP.mjs → chunk-QXKPIENP.mjs} +1 -1
- package/dist/chunk-UBHQJFUW.js +8 -0
- package/dist/{chunk-6NOCY764.js → chunk-VKXSL3ZL.js} +2 -2
- package/dist/chunk-XKNEQDAT.js +8 -0
- package/dist/{chunk-EN4PN7X3.mjs → chunk-Z23AMUSW.mjs} +1 -1
- package/dist/gestureLayer/index.d.mts +3 -3
- package/dist/gestureLayer/index.d.ts +3 -3
- package/dist/gestureLayer/index.js +12 -18
- package/dist/gestureLayer/index.mjs +5 -11
- package/dist/index.d.mts +87 -45
- package/dist/index.d.ts +87 -45
- package/dist/index.js +114 -91
- package/dist/index.mjs +66 -59
- package/dist/motion/FlatList.d.mts +1 -1
- package/dist/motion/FlatList.d.ts +1 -1
- package/dist/motion/FlatList.js +5 -5
- package/dist/motion/FlatList.mjs +4 -4
- package/dist/motion/Image.d.mts +1 -1
- package/dist/motion/Image.d.ts +1 -1
- package/dist/motion/Image.js +5 -5
- package/dist/motion/Image.mjs +4 -4
- package/dist/motion/Pressable.d.mts +1 -1
- package/dist/motion/Pressable.d.ts +1 -1
- package/dist/motion/Pressable.js +5 -5
- package/dist/motion/Pressable.mjs +4 -4
- package/dist/motion/ScrollView.d.mts +1 -1
- package/dist/motion/ScrollView.d.ts +1 -1
- package/dist/motion/ScrollView.js +5 -5
- package/dist/motion/ScrollView.mjs +4 -4
- package/dist/motion/Text.d.mts +1 -1
- package/dist/motion/Text.d.ts +1 -1
- package/dist/motion/Text.js +5 -5
- package/dist/motion/Text.mjs +4 -4
- package/dist/motion/View.d.mts +1 -1
- package/dist/motion/View.d.ts +1 -1
- package/dist/motion/View.js +5 -5
- package/dist/motion/View.mjs +4 -4
- package/dist/touch/index.d.mts +2 -1
- package/dist/touch/index.d.ts +2 -1
- package/dist/touch/index.js +16 -31
- package/dist/touch/index.mjs +11 -29
- package/dist/{types-DyJpG64F.d.mts → types-08mG8fNk.d.mts} +10 -3
- package/dist/{types-DyJpG64F.d.ts → types-08mG8fNk.d.ts} +10 -3
- package/dist/{useGesture-DbH46EBp.d.ts → useGesture-D1lHeQQ6.d.ts} +1 -1
- package/dist/{useGesture-CnZQnYHH.d.mts → useGesture-DjszaHWz.d.mts} +1 -1
- package/package.json +4 -2
- package/src/config/namedTransitions.ts +7 -9
- package/src/gestureLayer/index.ts +3 -0
- package/src/gestureLayer/useGestureLayer.ts +6 -9
- package/src/gestures/focusVisibility.ts +19 -17
- package/src/gestures/index.ts +1 -1
- package/src/index.ts +9 -0
- package/src/layout/resolveLayout.ts +4 -1
- package/src/layout/useSharedLayout.ts +2 -1
- package/src/motion/createMotionComponent.tsx +92 -44
- package/src/presence/Presence.tsx +5 -7
- package/src/touch/applyBounds.ts +30 -0
- package/src/touch/index.ts +1 -0
- package/src/touch/useTouchDrag.ts +15 -45
- package/src/transitions/constants.ts +14 -0
- package/src/transitions/easing.ts +23 -11
- package/src/transitions/index.ts +5 -0
- package/src/transitions/keys.ts +0 -2
- package/src/transitions/resolve.ts +86 -11
- package/src/transitions/resolveSequence.ts +3 -1
- package/src/transitions/runtime.ts +4 -7
- package/src/transitions/spring.ts +7 -2
- package/src/types.ts +9 -2
- package/src/values/extrapolation.ts +21 -0
- package/src/values/index.ts +1 -0
- package/src/values/useGesture.ts +9 -2
- package/src/values/useInterpolatedStyle.ts +5 -12
- package/src/values/useShadow.ts +18 -7
- package/src/values/useSpring.ts +34 -25
- package/src/values/useTransform.ts +24 -20
- package/src/values/useTranslateStyle.ts +31 -0
- package/dist/chunk-24NUL23E.js +0 -8
- package/dist/chunk-4XBX7KOD.js +0 -8
- package/dist/chunk-Z5USXWTE.js +0 -8
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-
|
|
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,
|
|
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.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-08mG8fNk.js';
|
|
7
|
+
export { a as applyBounds } from './applyBounds-BYGiHrYO.js';
|
|
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-
|
|
10
|
+
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-D1lHeQQ6.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';
|
|
@@ -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 };
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
3
|
+
var chunkKFHZMFAX_js = require('./chunk-KFHZMFAX.js');
|
|
4
|
+
var chunk4EZ5DBL3_js = require('./chunk-4EZ5DBL3.js');
|
|
5
|
+
var chunkPLKXCJIB_js = require('./chunk-PLKXCJIB.js');
|
|
6
|
+
var chunkUBHQJFUW_js = require('./chunk-UBHQJFUW.js');
|
|
7
|
+
var chunkXKNEQDAT_js = require('./chunk-XKNEQDAT.js');
|
|
8
|
+
var chunkVKXSL3ZL_js = require('./chunk-VKXSL3ZL.js');
|
|
9
|
+
var chunk3ZNHPT5Z_js = require('./chunk-3ZNHPT5Z.js');
|
|
10
|
+
var chunk46766TBM_js = require('./chunk-46766TBM.js');
|
|
11
|
+
var chunk2UGWAB6N_js = require('./chunk-2UGWAB6N.js');
|
|
12
|
+
var chunkKXU6VH2Y_js = require('./chunk-KXU6VH2Y.js');
|
|
13
|
+
var chunkN33GSDNQ_js = require('./chunk-N33GSDNQ.js');
|
|
13
14
|
var react = require('react');
|
|
14
15
|
var reactNativeReanimated = require('react-native-reanimated');
|
|
15
16
|
var reactNativeWorklets = require('react-native-worklets');
|
|
16
17
|
|
|
17
18
|
// src/motion/index.ts
|
|
18
19
|
var Motion = {
|
|
19
|
-
View:
|
|
20
|
-
Text:
|
|
21
|
-
Image:
|
|
22
|
-
Pressable:
|
|
23
|
-
ScrollView:
|
|
24
|
-
FlatList:
|
|
20
|
+
View: chunkPLKXCJIB_js.MotionView,
|
|
21
|
+
Text: chunkUBHQJFUW_js.MotionText,
|
|
22
|
+
Image: chunkXKNEQDAT_js.MotionImage,
|
|
23
|
+
Pressable: chunkVKXSL3ZL_js.MotionPressable,
|
|
24
|
+
ScrollView: chunk3ZNHPT5Z_js.MotionScrollView,
|
|
25
|
+
FlatList: chunk46766TBM_js.MotionFlatList
|
|
25
26
|
};
|
|
26
27
|
function useAnimation(target, transition) {
|
|
27
28
|
const output = reactNativeReanimated.useSharedValue(target);
|
|
28
|
-
const shouldReduceMotion =
|
|
29
|
-
const resolved =
|
|
30
|
-
const cfgSig =
|
|
29
|
+
const shouldReduceMotion = chunkKXU6VH2Y_js.useShouldReduceMotion();
|
|
30
|
+
const resolved = chunkKXU6VH2Y_js.resolveNamedTransition(transition, chunkKXU6VH2Y_js.useNamedTransitions());
|
|
31
|
+
const cfgSig = chunkN33GSDNQ_js.stableSig(resolved);
|
|
31
32
|
react.useEffect(() => {
|
|
32
33
|
const cfg = shouldReduceMotion ? { type: "no-animation" } : resolved ?? { type: "spring" };
|
|
33
|
-
output.value =
|
|
34
|
+
output.value = chunkN33GSDNQ_js.resolveTransition(cfg, target);
|
|
34
35
|
}, [target, cfgSig, shouldReduceMotion]);
|
|
35
36
|
react.useEffect(
|
|
36
37
|
() => () => reactNativeReanimated.cancelAnimation(output),
|
|
@@ -41,55 +42,50 @@ function useAnimation(target, transition) {
|
|
|
41
42
|
return output;
|
|
42
43
|
}
|
|
43
44
|
function useAnimator() {
|
|
44
|
-
const registry =
|
|
45
|
-
const shouldReduceMotion =
|
|
45
|
+
const registry = chunkKXU6VH2Y_js.useNamedTransitions();
|
|
46
|
+
const shouldReduceMotion = chunkKXU6VH2Y_js.useShouldReduceMotion();
|
|
46
47
|
const registryRef = react.useRef(registry);
|
|
47
48
|
registryRef.current = registry;
|
|
48
49
|
const reduceMotionRef = react.useRef(shouldReduceMotion);
|
|
49
50
|
reduceMotionRef.current = shouldReduceMotion;
|
|
50
51
|
return react.useCallback((value, to, transition) => {
|
|
51
|
-
const resolved =
|
|
52
|
+
const resolved = chunkKXU6VH2Y_js.resolveNamedTransition(transition, registryRef.current);
|
|
52
53
|
const cfg = reduceMotionRef.current ? { type: "no-animation" } : resolved ?? { type: "spring" };
|
|
53
|
-
value.value =
|
|
54
|
+
value.value = chunkN33GSDNQ_js.resolveTransition(cfg, to);
|
|
54
55
|
}, []);
|
|
55
56
|
}
|
|
56
57
|
function useSpring(target, config) {
|
|
57
|
-
const spring = resolveSpringInput(config,
|
|
58
|
+
const spring = resolveSpringInput(config, chunkKXU6VH2Y_js.useNamedTransitions());
|
|
59
|
+
const shouldReduceMotion = chunkKXU6VH2Y_js.useShouldReduceMotion();
|
|
58
60
|
const reanimConfig = react.useMemo(
|
|
59
|
-
() =>
|
|
61
|
+
() => chunkN33GSDNQ_js.springToReanimated(spring ?? {}),
|
|
60
62
|
// Keyed on the resolved primitive fields rather than the `config` object
|
|
61
63
|
// identity: callers routinely pass a fresh object literal each render, so
|
|
62
64
|
// depending on `config` itself would rebuild the Reanimated config on
|
|
63
65
|
// every render and defeat the memo.
|
|
64
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
-
[
|
|
66
|
-
spring?.tension,
|
|
67
|
-
spring?.friction,
|
|
68
|
-
spring?.mass,
|
|
69
|
-
spring?.velocity,
|
|
70
|
-
spring?.restSpeedThreshold,
|
|
71
|
-
spring?.restDisplacementThreshold
|
|
72
|
-
]
|
|
67
|
+
[spring?.tension, spring?.friction, spring?.mass, spring?.velocity]
|
|
73
68
|
);
|
|
74
69
|
const isSharedTarget = isSharedValue(target);
|
|
75
70
|
const initial = isSharedTarget ? target.value : target;
|
|
76
71
|
const output = reactNativeReanimated.useSharedValue(initial);
|
|
77
72
|
react.useEffect(() => {
|
|
78
73
|
if (isSharedTarget) return;
|
|
79
|
-
output.value = reactNativeReanimated.withSpring(target, reanimConfig);
|
|
80
|
-
}, [isSharedTarget, target, reanimConfig]);
|
|
74
|
+
output.value = shouldReduceMotion ? target : reactNativeReanimated.withSpring(target, reanimConfig);
|
|
75
|
+
}, [isSharedTarget, target, reanimConfig, shouldReduceMotion]);
|
|
76
|
+
const source = isSharedTarget ? target : null;
|
|
81
77
|
reactNativeReanimated.useAnimatedReaction(
|
|
82
78
|
() => {
|
|
83
79
|
"worklet";
|
|
84
|
-
if (
|
|
85
|
-
return
|
|
80
|
+
if (source === null) return null;
|
|
81
|
+
return source.value;
|
|
86
82
|
},
|
|
87
83
|
(next, prev) => {
|
|
88
84
|
"worklet";
|
|
89
85
|
if (next === null || next === prev) return;
|
|
90
|
-
output.value = reactNativeReanimated.withSpring(next, reanimConfig);
|
|
86
|
+
output.value = shouldReduceMotion ? next : reactNativeReanimated.withSpring(next, reanimConfig);
|
|
91
87
|
},
|
|
92
|
-
[
|
|
88
|
+
[source, reanimConfig, shouldReduceMotion]
|
|
93
89
|
);
|
|
94
90
|
react.useEffect(
|
|
95
91
|
() => () => reactNativeReanimated.cancelAnimation(output),
|
|
@@ -101,13 +97,12 @@ function useSpring(target, config) {
|
|
|
101
97
|
}
|
|
102
98
|
function resolveSpringInput(config, registry) {
|
|
103
99
|
if (typeof config !== "string") return config;
|
|
104
|
-
const cfg =
|
|
100
|
+
const cfg = chunkKXU6VH2Y_js.lookupNamedTransition(config, registry);
|
|
105
101
|
if (cfg.type === void 0 || cfg.type === "spring") return cfg;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
102
|
+
chunkN33GSDNQ_js.warnOnce(
|
|
103
|
+
`spring-only:${config}`,
|
|
104
|
+
`[inertia] Named transition "${config}" resolves to type '${cfg.type}', but useSpring / useBooleanSpring are spring-only \u2014 falling back to the default spring. Use useAnimation to honor non-spring named transitions.`
|
|
105
|
+
);
|
|
111
106
|
return void 0;
|
|
112
107
|
}
|
|
113
108
|
function isSharedValue(v) {
|
|
@@ -157,6 +152,13 @@ function useColorTransition(progress, range, options) {
|
|
|
157
152
|
return { [key]: reactNativeReanimated.interpolateColor(progress.value, [0, 1], [from, to]) };
|
|
158
153
|
});
|
|
159
154
|
}
|
|
155
|
+
function mapExtrapolation(mode) {
|
|
156
|
+
if (mode === "identity") return reactNativeReanimated.Extrapolation.IDENTITY;
|
|
157
|
+
if (mode === "extend") return reactNativeReanimated.Extrapolation.EXTEND;
|
|
158
|
+
return reactNativeReanimated.Extrapolation.CLAMP;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/values/useInterpolatedStyle.ts
|
|
160
162
|
var TRANSFORM_KEYS = /* @__PURE__ */ new Set([
|
|
161
163
|
"translateX",
|
|
162
164
|
"translateY",
|
|
@@ -185,11 +187,6 @@ function evenlySpaced(count) {
|
|
|
185
187
|
for (let i = 0; i < count; i++) out.push(i / (count - 1));
|
|
186
188
|
return out;
|
|
187
189
|
}
|
|
188
|
-
function mapExtrapolation(mode) {
|
|
189
|
-
if (mode === "identity") return reactNativeReanimated.Extrapolation.IDENTITY;
|
|
190
|
-
if (mode === "extend") return reactNativeReanimated.Extrapolation.EXTEND;
|
|
191
|
-
return reactNativeReanimated.Extrapolation.CLAMP;
|
|
192
|
-
}
|
|
193
190
|
function buildSignature(map, options) {
|
|
194
191
|
let sig = "";
|
|
195
192
|
for (const key of Object.keys(map)) {
|
|
@@ -206,8 +203,9 @@ function buildEntries(map, options) {
|
|
|
206
203
|
const output = map[key];
|
|
207
204
|
if (output === void 0 || output.length === 0) continue;
|
|
208
205
|
const input = explicitInput ? explicitInput : output.length === 2 ? [0, 1] : evenlySpaced(output.length);
|
|
209
|
-
if (
|
|
210
|
-
|
|
206
|
+
if (explicitInput && explicitInput.length !== output.length) {
|
|
207
|
+
chunkN33GSDNQ_js.warnOnce(
|
|
208
|
+
`interpolated-style-range:${String(key)}:${explicitInput.length}:${output.length}`,
|
|
211
209
|
`[inertia] useInterpolatedStyle: inputRange has ${explicitInput.length} stops but the "${String(
|
|
212
210
|
key
|
|
213
211
|
)}" output has ${output.length}. They must match \u2014 interpolation results are undefined otherwise.`
|
|
@@ -296,13 +294,22 @@ function useMotionValue(initial) {
|
|
|
296
294
|
return sv;
|
|
297
295
|
}
|
|
298
296
|
function useTransform(arg1, inputRange, outputRange, options) {
|
|
297
|
+
const rangeSig = chunkN33GSDNQ_js.stableSig([inputRange, outputRange]);
|
|
298
|
+
const ranges = react.useMemo(
|
|
299
|
+
() => ({
|
|
300
|
+
input: inputRange ?? [],
|
|
301
|
+
output: outputRange ?? []
|
|
302
|
+
}),
|
|
303
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
304
|
+
[rangeSig]
|
|
305
|
+
);
|
|
299
306
|
let producer;
|
|
300
307
|
if (typeof arg1 === "function") {
|
|
301
308
|
const userFn = arg1;
|
|
302
309
|
if (reactNativeWorklets.isWorkletFunction(userFn)) {
|
|
303
310
|
producer = userFn;
|
|
304
311
|
} else {
|
|
305
|
-
|
|
312
|
+
chunkN33GSDNQ_js.warnNonWorkletOnce(
|
|
306
313
|
"useTransform-transformer",
|
|
307
314
|
"[inertia] useTransform: the transformer is not a worklet, so the shared values it reads can't be tracked as dependencies \u2014 the derived value will only refresh on React re-renders, and native builds reject plain functions on the UI thread. Add the 'worklet' directive as the first statement of the transformer."
|
|
308
315
|
);
|
|
@@ -313,11 +320,11 @@ function useTransform(arg1, inputRange, outputRange, options) {
|
|
|
313
320
|
}
|
|
314
321
|
} else {
|
|
315
322
|
const source = arg1;
|
|
316
|
-
const input =
|
|
317
|
-
const output =
|
|
323
|
+
const input = ranges.input;
|
|
324
|
+
const output = ranges.output;
|
|
318
325
|
const isColor = output.length > 0 && typeof output[0] === "string";
|
|
319
|
-
const extrapolateLeft =
|
|
320
|
-
const extrapolateRight =
|
|
326
|
+
const extrapolateLeft = mapExtrapolation(options?.extrapolateLeft);
|
|
327
|
+
const extrapolateRight = mapExtrapolation(options?.extrapolateRight);
|
|
321
328
|
producer = isColor ? () => {
|
|
322
329
|
"worklet";
|
|
323
330
|
return reactNativeReanimated.interpolateColor(
|
|
@@ -337,11 +344,6 @@ function useTransform(arg1, inputRange, outputRange, options) {
|
|
|
337
344
|
}
|
|
338
345
|
return reactNativeReanimated.useDerivedValue(producer);
|
|
339
346
|
}
|
|
340
|
-
function mapExtrapolation2(mode) {
|
|
341
|
-
if (mode === "identity") return reactNativeReanimated.Extrapolation.IDENTITY;
|
|
342
|
-
if (mode === "extend") return reactNativeReanimated.Extrapolation.EXTEND;
|
|
343
|
-
return reactNativeReanimated.Extrapolation.CLAMP;
|
|
344
|
-
}
|
|
345
347
|
function useScroll() {
|
|
346
348
|
const scrollX = reactNativeReanimated.useSharedValue(0);
|
|
347
349
|
const scrollY = reactNativeReanimated.useSharedValue(0);
|
|
@@ -368,10 +370,15 @@ function useShadow({
|
|
|
368
370
|
const hasElevation = from.elevation !== void 0 || to.elevation !== void 0;
|
|
369
371
|
const hasColor = from.shadowColor !== void 0 || to.shadowColor !== void 0;
|
|
370
372
|
const hasOffset = from.shadowOffset !== void 0 || to.shadowOffset !== void 0;
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
const boxShadowSig = chunkN33GSDNQ_js.stableSig([from.boxShadow, to.boxShadow]);
|
|
374
|
+
const boxShadowPairs = react.useMemo(
|
|
375
|
+
() => from.boxShadow !== void 0 || to.boxShadow !== void 0 ? chunk2UGWAB6N_js.pairBoxShadowLayers(
|
|
376
|
+
chunk2UGWAB6N_js.resolveBoxShadowInput(from.boxShadow),
|
|
377
|
+
chunk2UGWAB6N_js.resolveBoxShadowInput(to.boxShadow)
|
|
378
|
+
) : [],
|
|
379
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
380
|
+
[boxShadowSig]
|
|
381
|
+
);
|
|
375
382
|
const opacityFrom = from.shadowOpacity ?? 0;
|
|
376
383
|
const opacityTo = to.shadowOpacity ?? 0;
|
|
377
384
|
const radiusFrom = from.shadowRadius ?? 0;
|
|
@@ -467,101 +474,117 @@ function useVariants(variants, initial) {
|
|
|
467
474
|
}, []);
|
|
468
475
|
}
|
|
469
476
|
|
|
477
|
+
Object.defineProperty(exports, "applyBounds", {
|
|
478
|
+
enumerable: true,
|
|
479
|
+
get: function () { return chunkKFHZMFAX_js.applyBounds; }
|
|
480
|
+
});
|
|
481
|
+
Object.defineProperty(exports, "useTranslateStyle", {
|
|
482
|
+
enumerable: true,
|
|
483
|
+
get: function () { return chunkKFHZMFAX_js.useTranslateStyle; }
|
|
484
|
+
});
|
|
470
485
|
Object.defineProperty(exports, "useGesture", {
|
|
471
486
|
enumerable: true,
|
|
472
|
-
get: function () { return
|
|
487
|
+
get: function () { return chunk4EZ5DBL3_js.useGesture; }
|
|
473
488
|
});
|
|
474
489
|
Object.defineProperty(exports, "MotionView", {
|
|
475
490
|
enumerable: true,
|
|
476
|
-
get: function () { return
|
|
491
|
+
get: function () { return chunkPLKXCJIB_js.MotionView; }
|
|
477
492
|
});
|
|
478
493
|
Object.defineProperty(exports, "MotionText", {
|
|
479
494
|
enumerable: true,
|
|
480
|
-
get: function () { return
|
|
495
|
+
get: function () { return chunkUBHQJFUW_js.MotionText; }
|
|
481
496
|
});
|
|
482
497
|
Object.defineProperty(exports, "MotionImage", {
|
|
483
498
|
enumerable: true,
|
|
484
|
-
get: function () { return
|
|
499
|
+
get: function () { return chunkXKNEQDAT_js.MotionImage; }
|
|
485
500
|
});
|
|
486
501
|
Object.defineProperty(exports, "MotionPressable", {
|
|
487
502
|
enumerable: true,
|
|
488
|
-
get: function () { return
|
|
503
|
+
get: function () { return chunkVKXSL3ZL_js.MotionPressable; }
|
|
489
504
|
});
|
|
490
505
|
Object.defineProperty(exports, "MotionScrollView", {
|
|
491
506
|
enumerable: true,
|
|
492
|
-
get: function () { return
|
|
507
|
+
get: function () { return chunk3ZNHPT5Z_js.MotionScrollView; }
|
|
493
508
|
});
|
|
494
509
|
Object.defineProperty(exports, "MotionFlatList", {
|
|
495
510
|
enumerable: true,
|
|
496
|
-
get: function () { return
|
|
511
|
+
get: function () { return chunk46766TBM_js.MotionFlatList; }
|
|
497
512
|
});
|
|
498
513
|
Object.defineProperty(exports, "Presence", {
|
|
499
514
|
enumerable: true,
|
|
500
|
-
get: function () { return
|
|
515
|
+
get: function () { return chunk2UGWAB6N_js.Presence; }
|
|
501
516
|
});
|
|
502
517
|
Object.defineProperty(exports, "Stagger", {
|
|
503
518
|
enumerable: true,
|
|
504
|
-
get: function () { return
|
|
519
|
+
get: function () { return chunk2UGWAB6N_js.Stagger; }
|
|
505
520
|
});
|
|
506
521
|
Object.defineProperty(exports, "TRANSPARENT", {
|
|
507
522
|
enumerable: true,
|
|
508
|
-
get: function () { return
|
|
523
|
+
get: function () { return chunk2UGWAB6N_js.TRANSPARENT; }
|
|
509
524
|
});
|
|
510
525
|
Object.defineProperty(exports, "createMotionComponent", {
|
|
511
526
|
enumerable: true,
|
|
512
|
-
get: function () { return
|
|
527
|
+
get: function () { return chunk2UGWAB6N_js.createMotionComponent; }
|
|
513
528
|
});
|
|
514
529
|
Object.defineProperty(exports, "usePresence", {
|
|
515
530
|
enumerable: true,
|
|
516
|
-
get: function () { return
|
|
531
|
+
get: function () { return chunk2UGWAB6N_js.usePresence; }
|
|
517
532
|
});
|
|
518
533
|
Object.defineProperty(exports, "useStaggerDelay", {
|
|
519
534
|
enumerable: true,
|
|
520
|
-
get: function () { return
|
|
535
|
+
get: function () { return chunk2UGWAB6N_js.useStaggerDelay; }
|
|
521
536
|
});
|
|
522
537
|
Object.defineProperty(exports, "MotionConfig", {
|
|
523
538
|
enumerable: true,
|
|
524
|
-
get: function () { return
|
|
539
|
+
get: function () { return chunkKXU6VH2Y_js.MotionConfig; }
|
|
525
540
|
});
|
|
526
541
|
Object.defineProperty(exports, "resolveNamedTransition", {
|
|
527
542
|
enumerable: true,
|
|
528
|
-
get: function () { return
|
|
543
|
+
get: function () { return chunkKXU6VH2Y_js.resolveNamedTransition; }
|
|
529
544
|
});
|
|
530
545
|
Object.defineProperty(exports, "useMotionConfig", {
|
|
531
546
|
enumerable: true,
|
|
532
|
-
get: function () { return
|
|
547
|
+
get: function () { return chunkKXU6VH2Y_js.useMotionConfig; }
|
|
533
548
|
});
|
|
534
549
|
Object.defineProperty(exports, "useNamedTransitions", {
|
|
535
550
|
enumerable: true,
|
|
536
|
-
get: function () { return
|
|
551
|
+
get: function () { return chunkKXU6VH2Y_js.useNamedTransitions; }
|
|
537
552
|
});
|
|
538
553
|
Object.defineProperty(exports, "useShouldReduceMotion", {
|
|
539
554
|
enumerable: true,
|
|
540
|
-
get: function () { return
|
|
555
|
+
get: function () { return chunkKXU6VH2Y_js.useShouldReduceMotion; }
|
|
541
556
|
});
|
|
542
557
|
Object.defineProperty(exports, "applyDelay", {
|
|
543
558
|
enumerable: true,
|
|
544
|
-
get: function () { return
|
|
559
|
+
get: function () { return chunkN33GSDNQ_js.applyDelay; }
|
|
545
560
|
});
|
|
546
561
|
Object.defineProperty(exports, "buildReleaseAnimation", {
|
|
547
562
|
enumerable: true,
|
|
548
|
-
get: function () { return
|
|
563
|
+
get: function () { return chunkN33GSDNQ_js.buildReleaseAnimation; }
|
|
549
564
|
});
|
|
550
565
|
Object.defineProperty(exports, "cubicBezier", {
|
|
551
566
|
enumerable: true,
|
|
552
|
-
get: function () { return
|
|
567
|
+
get: function () { return chunkN33GSDNQ_js.cubicBezier; }
|
|
553
568
|
});
|
|
554
569
|
Object.defineProperty(exports, "ensureWorkletEasing", {
|
|
555
570
|
enumerable: true,
|
|
556
|
-
get: function () { return
|
|
571
|
+
get: function () { return chunkN33GSDNQ_js.ensureWorkletEasing; }
|
|
572
|
+
});
|
|
573
|
+
Object.defineProperty(exports, "isTopLevelTransition", {
|
|
574
|
+
enumerable: true,
|
|
575
|
+
get: function () { return chunkN33GSDNQ_js.isTopLevelTransition; }
|
|
557
576
|
});
|
|
558
577
|
Object.defineProperty(exports, "resolveAnimatableValue", {
|
|
559
578
|
enumerable: true,
|
|
560
|
-
get: function () { return
|
|
579
|
+
get: function () { return chunkN33GSDNQ_js.resolveAnimatableValue; }
|
|
561
580
|
});
|
|
562
581
|
Object.defineProperty(exports, "resolveTransition", {
|
|
563
582
|
enumerable: true,
|
|
564
|
-
get: function () { return
|
|
583
|
+
get: function () { return chunkN33GSDNQ_js.resolveTransition; }
|
|
584
|
+
});
|
|
585
|
+
Object.defineProperty(exports, "stableSig", {
|
|
586
|
+
enumerable: true,
|
|
587
|
+
get: function () { return chunkN33GSDNQ_js.stableSig; }
|
|
565
588
|
});
|
|
566
589
|
exports.Motion = Motion;
|
|
567
590
|
exports.useAnimation = useAnimation;
|