@rootnative/inertia 0.0.3 → 0.0.4

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 (74) hide show
  1. package/CHANGELOG.md +41 -5
  2. package/README.md +5 -3
  3. package/dist/{chunk-SGUHE5CX.mjs → chunk-4ASOELLA.mjs} +1 -1
  4. package/dist/{chunk-CSODMRJ7.mjs → chunk-55W7BNO2.mjs} +475 -83
  5. package/dist/chunk-5SRD2WCO.js +8 -0
  6. package/dist/{chunk-PTRF47DA.js → chunk-7A6WTXNK.js} +10 -3
  7. package/dist/{chunk-3XTVY34H.js → chunk-CENTULW6.js} +2 -2
  8. package/dist/{chunk-4PEHWDAZ.js → chunk-D5KAHWMC.js} +7 -7
  9. package/dist/{chunk-O22NXXCZ.mjs → chunk-J5Q46OPW.mjs} +1 -1
  10. package/dist/{chunk-RGNX6UZN.mjs → chunk-K3CLP74S.mjs} +2 -2
  11. package/dist/{chunk-BP3Y2SHQ.js → chunk-MYE5NMXW.js} +495 -101
  12. package/dist/{chunk-OQV66TBQ.mjs → chunk-NAOXQJ7U.mjs} +1 -1
  13. package/dist/{chunk-R63GIUNU.mjs → chunk-QKC3APP4.mjs} +1 -1
  14. package/dist/{chunk-46P57VMY.mjs → chunk-RF7J5FRM.mjs} +1 -1
  15. package/dist/{chunk-CY7Y64C3.mjs → chunk-TU2XFPAK.mjs} +10 -4
  16. package/dist/chunk-TVFNJ25Z.js +8 -0
  17. package/dist/chunk-VLDIFL3F.js +8 -0
  18. package/dist/{chunk-7AOERN53.js → chunk-WVRCKOPO.js} +3 -3
  19. package/dist/{chunk-W5MC3P4N.js → chunk-XMEVPEMH.js} +2 -2
  20. package/dist/{chunk-BQQTHG2V.mjs → chunk-YKGY22SB.mjs} +1 -1
  21. package/dist/gestureLayer/index.d.mts +2 -2
  22. package/dist/gestureLayer/index.d.ts +2 -2
  23. package/dist/gestureLayer/index.js +10 -10
  24. package/dist/gestureLayer/index.mjs +3 -3
  25. package/dist/index.d.mts +4 -4
  26. package/dist/index.d.ts +4 -4
  27. package/dist/index.js +48 -169
  28. package/dist/index.mjs +17 -137
  29. package/dist/motion/Image.d.mts +1 -1
  30. package/dist/motion/Image.d.ts +1 -1
  31. package/dist/motion/Image.js +5 -5
  32. package/dist/motion/Image.mjs +4 -4
  33. package/dist/motion/Pressable.d.mts +1 -1
  34. package/dist/motion/Pressable.d.ts +1 -1
  35. package/dist/motion/Pressable.js +5 -5
  36. package/dist/motion/Pressable.mjs +4 -4
  37. package/dist/motion/ScrollView.d.mts +1 -1
  38. package/dist/motion/ScrollView.d.ts +1 -1
  39. package/dist/motion/ScrollView.js +5 -5
  40. package/dist/motion/ScrollView.mjs +4 -4
  41. package/dist/motion/Text.d.mts +1 -1
  42. package/dist/motion/Text.d.ts +1 -1
  43. package/dist/motion/Text.js +5 -5
  44. package/dist/motion/Text.mjs +4 -4
  45. package/dist/motion/View.d.mts +1 -1
  46. package/dist/motion/View.d.ts +1 -1
  47. package/dist/motion/View.js +5 -5
  48. package/dist/motion/View.mjs +4 -4
  49. package/dist/touch/index.d.mts +1 -1
  50. package/dist/touch/index.d.ts +1 -1
  51. package/dist/touch/index.js +3 -3
  52. package/dist/touch/index.mjs +1 -1
  53. package/dist/{types-G1dBU2IQ.d.mts → types-37pN82yh.d.mts} +49 -14
  54. package/dist/{types-G1dBU2IQ.d.ts → types-37pN82yh.d.ts} +49 -14
  55. package/dist/{useGesture-D1e4ixJo.d.ts → useGesture-Cl4uzZIr.d.ts} +1 -1
  56. package/dist/{useGesture-RFY6kTL3.d.mts → useGesture-_IKkS8Dv.d.mts} +1 -1
  57. package/llms.txt +3 -1
  58. package/package.json +1 -1
  59. package/src/index.ts +2 -1
  60. package/src/internal/boxShadow.ts +177 -6
  61. package/src/internal/nonWorkletWarning.ts +4 -6
  62. package/src/internal/warnOnce.ts +28 -0
  63. package/src/layout/index.ts +10 -0
  64. package/src/layout/measureWindow.ts +135 -0
  65. package/src/layout/sharedRegistry.ts +107 -18
  66. package/src/layout/useSharedLayout.ts +256 -91
  67. package/src/motion/createMotionComponent.tsx +378 -39
  68. package/src/motion/installCheck.ts +1 -1
  69. package/src/transitions/index.ts +1 -1
  70. package/src/types.ts +52 -12
  71. package/src/values/useColorTransition.ts +1 -1
  72. package/dist/chunk-FNVFV4EY.js +0 -8
  73. package/dist/chunk-FWQOXA43.js +0 -8
  74. package/dist/chunk-KBP4LR75.js +0 -8
package/src/types.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  type ReactElement,
5
5
  type Ref,
6
6
  } from 'react'
7
- import { type StyleProp } from 'react-native'
7
+ import { type BoxShadowValue, type StyleProp } from 'react-native'
8
8
 
9
9
  /**
10
10
  * A single animation step's destination, optionally overriding the transition
@@ -184,6 +184,39 @@ type AnimatableTransformExtras = {
184
184
  rotateY?: AnimatableValue<number>
185
185
  }
186
186
 
187
+ /**
188
+ * Target shape for the `boxShadow` key on `animate` / `initial` / `exit`: a
189
+ * CSS `box-shadow` string, or RN's own array-of-layers form.
190
+ *
191
+ * Both endpoints of a `boxShadow` animation are normalized to a common layer
192
+ * count on the JS thread, so a two-layer shadow can animate to a one-layer one
193
+ * (the short side is padded with a transparent layer, as CSS transitions do).
194
+ * A layer that is `inset` on one side and not the other is not interpolable
195
+ * and throws.
196
+ */
197
+ export type BoxShadowInput = string | ReadonlyArray<BoxShadowValue>
198
+
199
+ /**
200
+ * Keys whose animatable form deliberately departs from the generic
201
+ * `AnimatableValue<S[K]>` mapping.
202
+ *
203
+ * `boxShadow` is the only member. Its natural value is already an array, which
204
+ * collides head-on with `AnimatableValue`'s keyframe-sequence form — nothing
205
+ * distinguishes `[layerA, layerB]` (one two-layer shadow) from a two-step
206
+ * sequence. The array slot is given to layers, which is the shape RN itself
207
+ * uses and by far the common case, and sequences are unsupported on this key.
208
+ * This mirrors the single-value-only contract `shadowOffset` has carried since
209
+ * `0.0.1`. Per-property transitions are unaffected: `transition={{ boxShadow:
210
+ * { type: 'timing' } }}` works as it does for every other key.
211
+ *
212
+ * Conditional on `S` so the key only appears where the underlying style
213
+ * actually has it, rather than being bolted onto every primitive.
214
+ */
215
+ type AnimatableStructuredExtras<S> = 'boxShadow' extends keyof S
216
+ ? { boxShadow?: BoxShadowInput }
217
+ : // eslint-disable-next-line @typescript-eslint/no-empty-object-type
218
+ {}
219
+
187
220
  /**
188
221
  * The animation state shape inferred from the underlying component's style
189
222
  * prop. We narrow to the value side of `style` so consumers see ViewStyle on
@@ -200,7 +233,9 @@ type _StyleValue<T> = Exclude<T, (...args: any[]) => any>
200
233
 
201
234
  export type AnimateStyle<C> = C extends { style?: infer Raw }
202
235
  ? _StyleValue<Raw> extends StyleProp<infer S>
203
- ? { [K in keyof S]?: AnimatableValue<S[K]> } & AnimatableTransformExtras
236
+ ? Omit<{ [K in keyof S]?: AnimatableValue<S[K]> }, 'boxShadow'> &
237
+ AnimatableTransformExtras &
238
+ AnimatableStructuredExtras<S>
204
239
  : never
205
240
  : never
206
241
 
@@ -379,19 +414,24 @@ export interface MotionProps<C, V extends VariantsMap<C> = VariantsMap<C>> {
379
414
  * recorded rect to its natural position via a FLIP transform stack.
380
415
  *
381
416
  * Reanimated 4 removed the `sharedTransitionTag` API — `layoutId` is the
382
- * Inertia-side measure-based replacement. Rects are recorded in
383
- * parent-relative coordinates (from `onLayout`), which composes when the
384
- * source and target screens share an outer content container (the common
385
- * stack-navigator case); nested-parent layouts need the v2
386
- * window-coordinate path.
417
+ * Inertia-side measure-based replacement. Rects are recorded in **window**
418
+ * coordinates wherever the host can be measured synchronously (Fabric),
419
+ * which is what lets a source and target sit under containers at different
420
+ * screen offsets; elsewhere both fall back to the parent-relative
421
+ * coordinates `onLayout` reports. A source and target that ended up in
422
+ * different spaces skip the animation rather than play a wrong one.
387
423
  *
388
424
  * The same `transition` prop drives the FLIP animation (spring by
389
425
  * default; `'timing'` honored; `'decay'` downgrades to spring; reduced
390
- * motion skips the transition). Out of scope for the first iteration:
391
- * style-prop interpolation (border radius, colors, etc.) only the
392
- * rect-to-rect transform is animated. Two simultaneously-mounted
393
- * primitives sharing the same `layoutId` are undefined behavior; pick a
394
- * primitive per id at a time.
426
+ * motion skips the transition). Alongside the rect, a fixed set of style
427
+ * keys is carried from the source and crossfaded out on that same
428
+ * transition: `opacity`, `borderRadius`, `backgroundColor`, `borderColor`,
429
+ * `color`, `tintColor`. Transform keys are not carried the FLIP owns
430
+ * them and a key only participates when the element already has a value
431
+ * for it, from a record or from its static `style`.
432
+ *
433
+ * Two simultaneously-mounted primitives sharing the same `layoutId` are
434
+ * undefined behavior; pick a primitive per id at a time.
395
435
  */
396
436
  layoutId?: string
397
437
  /**
@@ -6,7 +6,7 @@ import {
6
6
 
7
7
  /**
8
8
  * Color style keys understood by React Native that this hook can target.
9
- * Sticks to the keys that exist on the v0.1 animatable surface so the
9
+ * Sticks to the keys that exist on the animatable surface so the
10
10
  * returned style fragment is always a legal RN style.
11
11
  */
12
12
  export type ColorStyleKey =
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkBP3Y2SHQ_js = require('./chunk-BP3Y2SHQ.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionView = chunkBP3Y2SHQ_js.createMotionComponent(reactNative.View);
7
-
8
- exports.MotionView = MotionView;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkBP3Y2SHQ_js = require('./chunk-BP3Y2SHQ.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionText = chunkBP3Y2SHQ_js.createMotionComponent(reactNative.Text);
7
-
8
- exports.MotionText = MotionText;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkBP3Y2SHQ_js = require('./chunk-BP3Y2SHQ.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionImage = chunkBP3Y2SHQ_js.createMotionComponent(reactNative.Image);
7
-
8
- exports.MotionImage = MotionImage;