@rootnative/inertia 0.0.1 → 0.0.3

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 (44) hide show
  1. package/CHANGELOG.md +36 -2
  2. package/dist/{chunk-TDSO63CJ.js → chunk-3XTVY34H.js} +2 -2
  3. package/dist/{chunk-NXDJZD6A.mjs → chunk-46P57VMY.mjs} +1 -1
  4. package/dist/{chunk-7UDYEFBU.js → chunk-BP3Y2SHQ.js} +477 -298
  5. package/dist/{chunk-6SMPIOIC.mjs → chunk-BQQTHG2V.mjs} +1 -1
  6. package/dist/{chunk-DWCLIBYO.mjs → chunk-CSODMRJ7.mjs} +478 -299
  7. package/dist/chunk-FNVFV4EY.js +8 -0
  8. package/dist/chunk-FWQOXA43.js +8 -0
  9. package/dist/chunk-KBP4LR75.js +8 -0
  10. package/dist/{chunk-ALRHDFZE.mjs → chunk-O22NXXCZ.mjs} +1 -1
  11. package/dist/{chunk-CWLFUYIY.mjs → chunk-OQV66TBQ.mjs} +1 -1
  12. package/dist/{chunk-JVBXPF2G.mjs → chunk-SGUHE5CX.mjs} +1 -1
  13. package/dist/{chunk-2HYD2ZBK.js → chunk-W5MC3P4N.js} +2 -2
  14. package/dist/index.d.mts +231 -43
  15. package/dist/index.d.ts +231 -43
  16. package/dist/index.js +212 -23
  17. package/dist/index.mjs +204 -18
  18. package/dist/motion/Image.js +3 -3
  19. package/dist/motion/Image.mjs +2 -2
  20. package/dist/motion/Pressable.js +3 -3
  21. package/dist/motion/Pressable.mjs +2 -2
  22. package/dist/motion/ScrollView.js +3 -3
  23. package/dist/motion/ScrollView.mjs +2 -2
  24. package/dist/motion/Text.js +3 -3
  25. package/dist/motion/Text.mjs +2 -2
  26. package/dist/motion/View.js +3 -3
  27. package/dist/motion/View.mjs +2 -2
  28. package/llms.txt +5 -0
  29. package/package.json +1 -1
  30. package/src/index.ts +10 -0
  31. package/src/layout/index.ts +1 -0
  32. package/src/layout/sharedRegistry.ts +51 -2
  33. package/src/motion/createMotionComponent.tsx +781 -502
  34. package/src/presence/Presence.tsx +73 -10
  35. package/src/values/index.ts +13 -0
  36. package/src/values/useAnimation.ts +15 -1
  37. package/src/values/useAnimator.ts +83 -0
  38. package/src/values/useColorCascade.ts +125 -0
  39. package/src/values/useInterpolatedStyle.ts +319 -0
  40. package/src/values/useMotionValue.ts +20 -2
  41. package/src/values/useSpring.ts +12 -0
  42. package/dist/chunk-3UTJJ4A3.js +0 -8
  43. package/dist/chunk-4QGXK6TF.js +0 -8
  44. package/dist/chunk-Z7HIOFKQ.js +0 -8
@@ -1,4 +1,9 @@
1
- import { useSharedValue, type SharedValue } from 'react-native-reanimated'
1
+ import { useEffect } from 'react'
2
+ import {
3
+ cancelAnimation,
4
+ useSharedValue,
5
+ type SharedValue,
6
+ } from 'react-native-reanimated'
2
7
 
3
8
  /**
4
9
  * Create an animatable value owned by JS but readable from worklets.
@@ -40,5 +45,18 @@ export function useMotionValue<T extends number | string>(
40
45
  export function useMotionValue<T extends number | string>(
41
46
  initial: T,
42
47
  ): SharedValue<T> {
43
- return useSharedValue<T>(initial)
48
+ const sv = useSharedValue<T>(initial)
49
+ // Cancel any in-flight animation when the owning component unmounts, so a
50
+ // mid-flight (or infinite-repeat) `withX` driving this value stops ticking
51
+ // its worklet once the value is orphaned. The shared value is
52
+ // identity-stable per hook instance and owned by this component, so
53
+ // cancelling on unmount is always safe. Mid-life cancellation stays the
54
+ // consumer's job via the `/reanimated` interop `cancelAnimation`.
55
+ useEffect(
56
+ () => () => cancelAnimation(sv),
57
+ // `sv` is identity-stable per hook instance (Reanimated guarantee).
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ [],
60
+ )
61
+ return sv
44
62
  }
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useMemo } from 'react'
2
2
  import {
3
+ cancelAnimation,
3
4
  useAnimatedReaction,
4
5
  useSharedValue,
5
6
  withSpring,
@@ -95,6 +96,17 @@ export function useSpring(
95
96
  [isSharedTarget, reanimConfig],
96
97
  )
97
98
 
99
+ // Stop the in-flight spring when the owning component unmounts so its
100
+ // worklet doesn't keep ticking against an orphaned value. `output` is
101
+ // identity-stable per hook instance and owned here, so cancelling on
102
+ // unmount is always safe.
103
+ useEffect(
104
+ () => () => cancelAnimation(output),
105
+ // `output` is identity-stable per hook instance (Reanimated guarantee).
106
+ // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ [],
108
+ )
109
+
98
110
  return output
99
111
  }
100
112
 
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk7UDYEFBU_js = require('./chunk-7UDYEFBU.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionImage = chunk7UDYEFBU_js.createMotionComponent(reactNative.Image);
7
-
8
- exports.MotionImage = MotionImage;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk7UDYEFBU_js = require('./chunk-7UDYEFBU.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionView = chunk7UDYEFBU_js.createMotionComponent(reactNative.View);
7
-
8
- exports.MotionView = MotionView;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk7UDYEFBU_js = require('./chunk-7UDYEFBU.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionText = chunk7UDYEFBU_js.createMotionComponent(reactNative.Text);
7
-
8
- exports.MotionText = MotionText;