@rootnative/inertia 0.0.0-alpha.3 → 0.0.0-alpha.5

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 (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{chunk-S4AEU72O.js → chunk-2HYD2ZBK.js} +2 -2
  3. package/dist/chunk-3UTJJ4A3.js +8 -0
  4. package/dist/{chunk-K7ICHCTZ.js → chunk-4PEHWDAZ.js} +7 -7
  5. package/dist/chunk-4QGXK6TF.js +8 -0
  6. package/dist/{chunk-RJNR7CFN.mjs → chunk-6SMPIOIC.mjs} +1 -1
  7. package/dist/{chunk-JWHKMNYA.js → chunk-7AOERN53.js} +4 -3
  8. package/dist/{chunk-KVSJWO5X.js → chunk-7UDYEFBU.js} +22 -22
  9. package/dist/{chunk-UM3WVSKQ.mjs → chunk-ALRHDFZE.mjs} +1 -1
  10. package/dist/{chunk-KARV7QKF.mjs → chunk-CWLFUYIY.mjs} +1 -1
  11. package/dist/{chunk-6FENLMCA.mjs → chunk-CY7Y64C3.mjs} +17 -1
  12. package/dist/{chunk-UXK4YCT6.mjs → chunk-DWCLIBYO.mjs} +2 -2
  13. package/dist/{chunk-FSPQVLBF.mjs → chunk-JVBXPF2G.mjs} +1 -1
  14. package/dist/{chunk-E4MDU4YV.mjs → chunk-NXDJZD6A.mjs} +1 -1
  15. package/dist/{chunk-SFRNO6AW.js → chunk-PTRF47DA.js} +17 -0
  16. package/dist/{chunk-GJD4VVAS.mjs → chunk-R63GIUNU.mjs} +2 -1
  17. package/dist/{chunk-W6IS4HAK.mjs → chunk-RGNX6UZN.mjs} +2 -2
  18. package/dist/{chunk-5RCMIJGZ.js → chunk-TDSO63CJ.js} +2 -2
  19. package/dist/chunk-Z7HIOFKQ.js +8 -0
  20. package/dist/gestureLayer/index.js +10 -10
  21. package/dist/gestureLayer/index.mjs +3 -3
  22. package/dist/index.d.mts +19 -11
  23. package/dist/index.d.ts +19 -11
  24. package/dist/index.js +52 -44
  25. package/dist/index.mjs +28 -20
  26. package/dist/motion/Image.js +5 -5
  27. package/dist/motion/Image.mjs +4 -4
  28. package/dist/motion/Pressable.js +5 -5
  29. package/dist/motion/Pressable.mjs +4 -4
  30. package/dist/motion/ScrollView.js +5 -5
  31. package/dist/motion/ScrollView.mjs +4 -4
  32. package/dist/motion/Text.js +5 -5
  33. package/dist/motion/Text.mjs +4 -4
  34. package/dist/motion/View.js +5 -5
  35. package/dist/motion/View.mjs +4 -4
  36. package/dist/touch/index.js +3 -3
  37. package/dist/touch/index.mjs +1 -1
  38. package/package.json +2 -2
  39. package/src/gestures/focusVisibility.ts +15 -4
  40. package/src/internal/nonWorkletWarning.ts +41 -0
  41. package/src/layout/resolveLayout.ts +3 -2
  42. package/src/transitions/easing.ts +13 -8
  43. package/src/values/useTransform.ts +28 -12
  44. package/dist/chunk-NJYRN3WG.js +0 -8
  45. package/dist/chunk-R3ODWDTI.js +0 -8
  46. package/dist/chunk-UMFBAFZP.js +0 -8
@@ -10,6 +10,7 @@ import {
10
10
  // `react-native-worklets` is a required peer of Reanimated 4, so the direct
11
11
  // import is always available wherever Inertia is.
12
12
  import { isWorkletFunction } from 'react-native-worklets'
13
+ import { warnNonWorkletOnce } from '../internal/nonWorkletWarning'
13
14
 
14
15
  /**
15
16
  * Extrapolation behavior at the edges of the input range. Mirrors
@@ -36,9 +37,17 @@ export interface UseTransformOptions {
36
37
  * const distance = useTransform(() => Math.sqrt(x.value ** 2 + y.value ** 2))
37
38
  * ```
38
39
  *
39
- * The transformer must be a worklet (or a plain function we auto-wrap
40
- * see the easing wrapper for the rationale). It runs on the UI thread on
41
- * every frame where any read shared value changes.
40
+ * The transformer MUST be a worklet put the `'worklet'` directive as its
41
+ * first statement so the consumer's Babel plugin captures the shared values
42
+ * it reads as its closure. It runs on the UI thread on every frame where
43
+ * any read shared value changes.
44
+ *
45
+ * A plain function cannot work here, and the hook warns in dev when it gets
46
+ * one: the best-effort wrapper it falls back to closes over the opaque
47
+ * function reference, not the shared values read inside it, so Reanimated
48
+ * can't track them as dependencies — the derived value only refreshes on
49
+ * React re-renders, and native builds reject the plain function when the
50
+ * closure crosses to the UI thread.
42
51
  */
43
52
  export function useTransform<T>(transformer: () => T): SharedValue<T>
44
53
 
@@ -80,16 +89,23 @@ export function useTransform<T>(
80
89
  // interpolation) is decided once at JS time, never at frame time.
81
90
  let producer: () => unknown
82
91
  if (typeof arg1 === 'function') {
83
- // Transformer overload. The public surface accepts a plain function;
84
- // Reanimated 3.9+ requires worklets in nested-derivation contexts, so
85
- // we auto-wrap at JS time the same way `ensureWorkletEasing` does.
92
+ // Transformer overload. Must be a worklet the directive-wrapped
93
+ // fallback below is best-effort only (its closure holds the opaque
94
+ // function, not the shared values read inside it, so dependency
95
+ // tracking cannot work — see `warnNonWorkletOnce`).
86
96
  const userFn = arg1 as () => T
87
- producer = isWorkletFunction(userFn)
88
- ? userFn
89
- : () => {
90
- 'worklet'
91
- return userFn()
92
- }
97
+ if (isWorkletFunction(userFn)) {
98
+ producer = userFn
99
+ } else {
100
+ warnNonWorkletOnce(
101
+ 'useTransform-transformer',
102
+ "[inertia] useTransform: the transformer is not a worklet, so the shared values it reads can't be tracked as dependencies — 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.",
103
+ )
104
+ producer = () => {
105
+ 'worklet'
106
+ return userFn()
107
+ }
108
+ }
93
109
  } else {
94
110
  // Interpolation overload. We pre-resolve everything JS-side so the
95
111
  // worklet body only consumes flat values.
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkKVSJWO5X_js = require('./chunk-KVSJWO5X.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionView = chunkKVSJWO5X_js.createMotionComponent(reactNative.View);
7
-
8
- exports.MotionView = MotionView;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkKVSJWO5X_js = require('./chunk-KVSJWO5X.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionImage = chunkKVSJWO5X_js.createMotionComponent(reactNative.Image);
7
-
8
- exports.MotionImage = MotionImage;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkKVSJWO5X_js = require('./chunk-KVSJWO5X.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionText = chunkKVSJWO5X_js.createMotionComponent(reactNative.Text);
7
-
8
- exports.MotionText = MotionText;