@rootnative/inertia 0.0.1 → 0.0.2

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 (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{chunk-ALRHDFZE.mjs → chunk-2DHKV2XY.mjs} +1 -1
  3. package/dist/chunk-34Q4UM6V.js +8 -0
  4. package/dist/{chunk-CWLFUYIY.mjs → chunk-HFDZAHWP.mjs} +1 -1
  5. package/dist/{chunk-7UDYEFBU.js → chunk-IWLU3VDE.js} +361 -288
  6. package/dist/chunk-KYJROYCG.js +8 -0
  7. package/dist/{chunk-DWCLIBYO.mjs → chunk-LYMLQ6WQ.mjs} +362 -289
  8. package/dist/{chunk-TDSO63CJ.js → chunk-NKA6XR77.js} +2 -2
  9. package/dist/{chunk-6SMPIOIC.mjs → chunk-TUMNV4P7.mjs} +1 -1
  10. package/dist/{chunk-2HYD2ZBK.js → chunk-TUYHTHVV.js} +2 -2
  11. package/dist/{chunk-NXDJZD6A.mjs → chunk-V6BTXHZK.mjs} +1 -1
  12. package/dist/chunk-X5J5M3K3.js +8 -0
  13. package/dist/{chunk-JVBXPF2G.mjs → chunk-ZN3PNGHQ.mjs} +1 -1
  14. package/dist/index.d.mts +229 -43
  15. package/dist/index.d.ts +229 -43
  16. package/dist/index.js +199 -23
  17. package/dist/index.mjs +191 -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/motion/createMotionComponent.tsx +624 -501
  32. package/src/values/index.ts +13 -0
  33. package/src/values/useAnimation.ts +15 -1
  34. package/src/values/useAnimator.ts +72 -0
  35. package/src/values/useColorCascade.ts +107 -0
  36. package/src/values/useInterpolatedStyle.ts +319 -0
  37. package/src/values/useMotionValue.ts +20 -2
  38. package/src/values/useSpring.ts +12 -0
  39. package/dist/chunk-3UTJJ4A3.js +0 -8
  40. package/dist/chunk-4QGXK6TF.js +0 -8
  41. package/dist/chunk-Z7HIOFKQ.js +0 -8
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to `@rootnative/inertia` are documented here. The format fol
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.0.2] - 2026-07-24
8
+
9
+ ### Added
10
+
11
+ - **`useAnimator()` — imperative writes that resolve named transitions and respect reduced motion.** The imperative counterpart to `useAnimation`: returns an identity-stable `(value, to, transition?)` setter to call from event handlers (hover-in, focus, press) rather than from an effect. It closes the two footguns of the hand-written `value.value = resolveTransition(config, to)` escape hatch: a registered `TransitionName` now resolves through the nearest `<MotionConfig transitions>` (a bare `resolveTransition` can't reach the context registry, so imperative call sites otherwise rebuild configs the provider already owns — surfaced by the RootNative UI Slider rebuilding `state-hover` / `state-focus` by hand), and the write routes through the same `no-animation` reduced-motion downgrade `useAnimation` applies (raw `resolveTransition` writes silently bypass `<MotionConfig reducedMotion>` — a correctness fix). Not a new animation API — the hooks-layer equivalent of `useMotionValue` + `resolveTransition`, minus the footguns. New `Animator` type exported from the root barrel.
12
+ - **`useColorCascade(rest, layers, options?)` — priority-ordered layered color crossfade.** Composites a stack of color layers over a base `rest` color; each layer carries its own `progress` shared value and blends toward its color as that progress rises, later layers winning over earlier ones (the values-layer form of the `gesture` prop's fixed-priority cascade, Decision 5). Exactly equivalent to the hand-chained nested-`interpolateColor` shape `focus(error(hover(rest)))`, collapsed into one hook and one worklet — the shape the RootNative UI TextField hand-writes three times (label color, filled indicator, outlined border). `options.key` reuses `ColorStyleKey` (default `backgroundColor`). Memoized on a colors+key signature so an equal-but-fresh `layers` literal produces no new UI-thread closure. Color-only by design; cascade a numeric key via `useInterpolatedStyle` + `useTransform` max. `useColorTransition` remains the single-layer fast path. New `ColorCascadeLayer` / `UseColorCascadeOptions` types exported from the root barrel.
13
+
14
+ ### Changed
15
+
16
+ - **A prop-less `Motion.*` primitive is now a zero-cost plain host.** An instance carrying none of the animation-driving props (`initial` / `animate` / `exit` / `transition` / `variants` / `controller` / `gesture` / `layout` / `layoutId` / `onAnimationEnd`) previously still allocated the full animated body — ~25 per-key shared values, four gesture-progress shared values, gesture `useState`s, and a `useAnimatedStyle` worklet — every render. It now renders straight through `Animated.createAnimatedComponent(Component)` with `style` / `ref` / `onLayout` forwarded and no animation allocation, so a prop-less `Motion.View` is a genuine drop-in for `Animated.View` when hosting an animated-style fragment from `useColorTransition` / `useShadow` / `useInterpolatedStyle` / `useColorCascade` (no `/reanimated` import needed — closes proposal item 5). The plain host stays `<Presence>`-aware (it self-removes on exit via a context read + unmount effect, no worklet). Adding an animation prop opts the instance back into the full body; because the two paths are distinct component types, crossing that boundary remounts the element (give it a stable `key` if the remount matters). New guard test (`plain-host.test.tsx`) pins that a prop-less primitive calls neither `useSharedValue` nor `useAnimatedStyle`.
17
+ - **Value hooks and the `Motion.*` factory now cancel in-flight animations on unmount.** `useMotionValue`, `useSpring`, `useBooleanSpring`, and `useAnimation` — and every per-key / gesture-layer shared value inside a `Motion.*` primitive — register an unmount cleanup that calls `cancelAnimation` on the shared value they own. Previously a mid-flight (or `repeat: 'infinite'`) `withSpring` / `withTiming` / `withDecay` kept ticking its worklet for frames after the owning component was gone; consumers who cared had to import `cancelAnimation` from the `/reanimated` interop subpath and hand-write the effect (surfaced by the RootNative UI Slider's 22-line 8-value teardown). The shared values are identity-stable and component-owned, so cancelling on unmount is always safe. `cancelAnimation` stays exported from the interop subpath for _mid-life_ cancellation — this change only covers the unmount case. Behavior change (no API change).
18
+
7
19
  ## [0.0.1] - 2026-07-23
8
20
 
9
21
  **First stable release.** Graduates the `0.0.0-alpha.x` line, absorbing Milestones 1–3 in a single tag: the declarative core (primitives, per-property transitions, sequences/keyframes, unified `repeat`, variants, `gesture` prop, `<Presence>`, `<MotionConfig>` with reduced-motion + named transitions), the value-layer hooks, the `layout` prop and rect-only `layoutId` shared-element transitions, and the `inertia-gestures` / `inertia-gradients` / `inertia-svg` adapter packages (released in lockstep). See the alpha entries below for the per-change history.
@@ -1,4 +1,4 @@
1
- import { createMotionComponent } from './chunk-DWCLIBYO.mjs';
1
+ import { createMotionComponent } from './chunk-LYMLQ6WQ.mjs';
2
2
  import { Image } from 'react-native';
3
3
 
4
4
  var MotionImage = createMotionComponent(Image);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var chunkIWLU3VDE_js = require('./chunk-IWLU3VDE.js');
4
+ var reactNative = require('react-native');
5
+
6
+ var MotionImage = chunkIWLU3VDE_js.createMotionComponent(reactNative.Image);
7
+
8
+ exports.MotionImage = MotionImage;
@@ -1,4 +1,4 @@
1
- import { createMotionComponent } from './chunk-DWCLIBYO.mjs';
1
+ import { createMotionComponent } from './chunk-LYMLQ6WQ.mjs';
2
2
  import { ScrollView } from 'react-native';
3
3
 
4
4
  var MotionScrollView = createMotionComponent(ScrollView);