@rootnative/inertia 0.0.3 → 0.0.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.
- package/CHANGELOG.md +92 -5
- package/README.md +9 -3
- package/dist/{chunk-OQV66TBQ.mjs → chunk-27MKBTSG.mjs} +1 -1
- package/dist/{chunk-3XTVY34H.js → chunk-27U6766G.js} +2 -2
- package/dist/{chunk-4PEHWDAZ.js → chunk-4NAMD62I.js} +7 -7
- package/dist/chunk-67GHRCF6.js +8 -0
- package/dist/{chunk-SGUHE5CX.mjs → chunk-COEJVWRZ.mjs} +1 -1
- package/dist/chunk-GPOMFIIU.js +8 -0
- package/dist/{chunk-BQQTHG2V.mjs → chunk-GTJ6VAH5.mjs} +1 -1
- package/dist/chunk-K63LXGKS.js +8 -0
- package/dist/{chunk-46P57VMY.mjs → chunk-OAUWLPQH.mjs} +1 -1
- package/dist/{chunk-7AOERN53.js → chunk-OBRGJAST.js} +3 -3
- package/dist/{chunk-RGNX6UZN.mjs → chunk-OW5XTGVN.mjs} +2 -2
- package/dist/{chunk-PTRF47DA.js → chunk-PM6CVGXJ.js} +11 -3
- package/dist/{chunk-W5MC3P4N.js → chunk-QQVDZKSD.js} +2 -2
- package/dist/{chunk-CY7Y64C3.mjs → chunk-REYL77RE.mjs} +11 -4
- package/dist/{chunk-CSODMRJ7.mjs → chunk-RIVVBABB.mjs} +597 -134
- package/dist/{chunk-BP3Y2SHQ.js → chunk-VQ5D35UA.js} +617 -152
- package/dist/{chunk-O22NXXCZ.mjs → chunk-XSK5MNUH.mjs} +1 -1
- package/dist/{chunk-R63GIUNU.mjs → chunk-Z3HCJ43H.mjs} +1 -1
- package/dist/gestureLayer/index.d.mts +2 -2
- package/dist/gestureLayer/index.d.ts +2 -2
- package/dist/gestureLayer/index.js +10 -10
- package/dist/gestureLayer/index.mjs +3 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +48 -169
- package/dist/index.mjs +17 -137
- 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 +1 -1
- package/dist/touch/index.d.ts +1 -1
- package/dist/touch/index.js +3 -3
- package/dist/touch/index.mjs +1 -1
- package/dist/{types-G1dBU2IQ.d.mts → types-BQgLJeQG.d.mts} +85 -14
- package/dist/{types-G1dBU2IQ.d.ts → types-BQgLJeQG.d.ts} +85 -14
- package/dist/{useGesture-D1e4ixJo.d.ts → useGesture-B0_CzOUz.d.ts} +1 -1
- package/dist/{useGesture-RFY6kTL3.d.mts → useGesture-DfaTx-3t.d.mts} +1 -1
- package/llms.txt +3 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/internal/boxShadow.ts +177 -6
- package/src/internal/nonWorkletWarning.ts +4 -6
- package/src/internal/warnOnce.ts +28 -0
- package/src/layout/index.ts +10 -0
- package/src/layout/measureWindow.ts +135 -0
- package/src/layout/sharedRegistry.ts +107 -18
- package/src/layout/useSharedLayout.ts +256 -91
- package/src/motion/createMotionComponent.tsx +497 -74
- package/src/motion/installCheck.ts +1 -1
- package/src/transitions/index.ts +1 -1
- package/src/transitions/resolveSequence.ts +12 -0
- package/src/types.ts +155 -12
- package/src/values/useColorTransition.ts +1 -1
- package/dist/chunk-FNVFV4EY.js +0 -8
- package/dist/chunk-FWQOXA43.js +0 -8
- package/dist/chunk-KBP4LR75.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stableSig, isTopLevelTransition } from './chunk-
|
|
1
|
+
import { stableSig, isTopLevelTransition } from './chunk-REYL77RE.mjs';
|
|
2
2
|
import { createContext, useContext, useMemo } from 'react';
|
|
3
3
|
import { useReducedMotion } from 'react-native-reanimated';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
|
|
2
|
-
import { U as UseGestureHandlers } from '../useGesture-
|
|
3
|
-
import { a as TransitionInput, G as GestureLayerTransitions } from '../types-
|
|
2
|
+
import { U as UseGestureHandlers } from '../useGesture-DfaTx-3t.mjs';
|
|
3
|
+
import { a as TransitionInput, G as GestureLayerTransitions } from '../types-BQgLJeQG.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-native';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
|
|
2
|
-
import { U as UseGestureHandlers } from '../useGesture-
|
|
3
|
-
import { a as TransitionInput, G as GestureLayerTransitions } from '../types-
|
|
2
|
+
import { U as UseGestureHandlers } from '../useGesture-B0_CzOUz.js';
|
|
3
|
+
import { a as TransitionInput, G as GestureLayerTransitions } from '../types-BQgLJeQG.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-native';
|
|
6
6
|
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk4NAMD62I_js = require('../chunk-4NAMD62I.js');
|
|
4
|
+
var chunkOBRGJAST_js = require('../chunk-OBRGJAST.js');
|
|
5
|
+
var chunkPM6CVGXJ_js = require('../chunk-PM6CVGXJ.js');
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var reactNativeReanimated = require('react-native-reanimated');
|
|
8
8
|
|
|
9
9
|
function useGestureLayer(states, options = {}) {
|
|
10
10
|
const { disabled: isDisabled = false, transition: transitionInput } = options;
|
|
11
|
-
const shouldReduceMotion =
|
|
12
|
-
const transition =
|
|
11
|
+
const shouldReduceMotion = chunkOBRGJAST_js.useShouldReduceMotion();
|
|
12
|
+
const transition = chunkOBRGJAST_js.resolveNamedTransitionProp(
|
|
13
13
|
transitionInput,
|
|
14
|
-
|
|
14
|
+
chunkOBRGJAST_js.useNamedTransitions()
|
|
15
15
|
);
|
|
16
|
-
const gesture =
|
|
16
|
+
const gesture = chunk4NAMD62I_js.useGesture(transition);
|
|
17
17
|
const disabledProgress = reactNativeReanimated.useSharedValue(0);
|
|
18
|
-
const transitionSig =
|
|
18
|
+
const transitionSig = chunkPM6CVGXJ_js.stableSig(transition);
|
|
19
19
|
react.useEffect(() => {
|
|
20
20
|
const target = isDisabled ? 1 : 0;
|
|
21
21
|
const cfg = shouldReduceMotion ? { type: "no-animation" } : disabledTransition(transition) ?? { type: "spring" };
|
|
22
|
-
disabledProgress.value =
|
|
22
|
+
disabledProgress.value = chunkPM6CVGXJ_js.resolveTransition(cfg, target);
|
|
23
23
|
}, [isDisabled, shouldReduceMotion, transitionSig, disabledProgress]);
|
|
24
24
|
const meta = react.useMemo(() => {
|
|
25
25
|
const layers = {
|
|
@@ -154,7 +154,7 @@ function useGestureLayer(states, options = {}) {
|
|
|
154
154
|
}
|
|
155
155
|
function disabledTransition(transition) {
|
|
156
156
|
if (!transition) return void 0;
|
|
157
|
-
if (
|
|
157
|
+
if (chunkPM6CVGXJ_js.isTopLevelTransition(transition)) return transition;
|
|
158
158
|
return void 0;
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useGesture } from '../chunk-
|
|
2
|
-
import { useShouldReduceMotion, resolveNamedTransitionProp, useNamedTransitions } from '../chunk-
|
|
3
|
-
import { stableSig, resolveTransition, isTopLevelTransition } from '../chunk-
|
|
1
|
+
import { useGesture } from '../chunk-OW5XTGVN.mjs';
|
|
2
|
+
import { useShouldReduceMotion, resolveNamedTransitionProp, useNamedTransitions } from '../chunk-Z3HCJ43H.mjs';
|
|
3
|
+
import { stableSig, resolveTransition, isTopLevelTransition } from '../chunk-REYL77RE.mjs';
|
|
4
4
|
import { useEffect, useMemo } from 'react';
|
|
5
5
|
import { useSharedValue, useAnimatedStyle, interpolateColor } from 'react-native-reanimated';
|
|
6
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2,11 +2,11 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
|
|
5
|
-
import { M as MotionComponent, N as NamedTransitions, a as TransitionInput, T as TransitionConfig, A as AnimatableValue, E as EasingInput, S as SpringTransition, b as TransitionName, V as VariantController } from './types-
|
|
6
|
-
export { c as AnimateStyle, d as AnimationCallbackInfo, D as DecayTransition, e as EasingFunction, f as EasingFunctionFactory, g as GestureSubStates, h as MotionProps, i as NoAnimationTransition, P as PerPropertyTransition, R as RegisteredTransitions, j as RepeatConfig, k as SequenceStep, l as TimingTransition, m as Transition, n as VariantsMap } from './types-
|
|
5
|
+
import { M as MotionComponent, N as NamedTransitions, a as TransitionInput, T as TransitionConfig, A as AnimatableValue, E as EasingInput, S as SpringTransition, b as TransitionName, V as VariantController } from './types-BQgLJeQG.mjs';
|
|
6
|
+
export { c as AnimateStyle, d as AnimationCallbackInfo, B as BoxShadowInput, D as DecayTransition, e as EasingFunction, f as EasingFunctionFactory, g as GestureSubStates, h as MotionProps, i as NoAnimationTransition, P as PerPropertyTransition, R as RegisteredTransitions, j as RepeatConfig, k as SequenceStep, l as TimingTransition, m as Transition, n as VariantsMap } from './types-BQgLJeQG.mjs';
|
|
7
7
|
import { SharedValue, useAnimatedStyle } from 'react-native-reanimated';
|
|
8
8
|
export { SharedValue } from 'react-native-reanimated';
|
|
9
|
-
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-
|
|
9
|
+
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-DfaTx-3t.mjs';
|
|
10
10
|
export { MotionImage } from './motion/Image.mjs';
|
|
11
11
|
export { MotionPressable } from './motion/Pressable.mjs';
|
|
12
12
|
export { MotionScrollView } from './motion/ScrollView.mjs';
|
|
@@ -414,7 +414,7 @@ declare function useBooleanSpring(active: boolean, springConfig?: SpringTransiti
|
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
* Color style keys understood by React Native that this hook can target.
|
|
417
|
-
* Sticks to the keys that exist on the
|
|
417
|
+
* Sticks to the keys that exist on the animatable surface so the
|
|
418
418
|
* returned style fragment is always a legal RN style.
|
|
419
419
|
*/
|
|
420
420
|
type ColorStyleKey = 'backgroundColor' | 'color' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'tintColor' | 'shadowColor';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
|
|
5
|
-
import { M as MotionComponent, N as NamedTransitions, a as TransitionInput, T as TransitionConfig, A as AnimatableValue, E as EasingInput, S as SpringTransition, b as TransitionName, V as VariantController } from './types-
|
|
6
|
-
export { c as AnimateStyle, d as AnimationCallbackInfo, D as DecayTransition, e as EasingFunction, f as EasingFunctionFactory, g as GestureSubStates, h as MotionProps, i as NoAnimationTransition, P as PerPropertyTransition, R as RegisteredTransitions, j as RepeatConfig, k as SequenceStep, l as TimingTransition, m as Transition, n as VariantsMap } from './types-
|
|
5
|
+
import { M as MotionComponent, N as NamedTransitions, a as TransitionInput, T as TransitionConfig, A as AnimatableValue, E as EasingInput, S as SpringTransition, b as TransitionName, V as VariantController } from './types-BQgLJeQG.js';
|
|
6
|
+
export { c as AnimateStyle, d as AnimationCallbackInfo, B as BoxShadowInput, D as DecayTransition, e as EasingFunction, f as EasingFunctionFactory, g as GestureSubStates, h as MotionProps, i as NoAnimationTransition, P as PerPropertyTransition, R as RegisteredTransitions, j as RepeatConfig, k as SequenceStep, l as TimingTransition, m as Transition, n as VariantsMap } from './types-BQgLJeQG.js';
|
|
7
7
|
import { SharedValue, useAnimatedStyle } from 'react-native-reanimated';
|
|
8
8
|
export { SharedValue } from 'react-native-reanimated';
|
|
9
|
-
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-
|
|
9
|
+
export { U as UseGestureHandlers, a as UseGestureResult, u as useGesture } from './useGesture-B0_CzOUz.js';
|
|
10
10
|
export { MotionImage } from './motion/Image.js';
|
|
11
11
|
export { MotionPressable } from './motion/Pressable.js';
|
|
12
12
|
export { MotionScrollView } from './motion/ScrollView.js';
|
|
@@ -414,7 +414,7 @@ declare function useBooleanSpring(active: boolean, springConfig?: SpringTransiti
|
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
* Color style keys understood by React Native that this hook can target.
|
|
417
|
-
* Sticks to the keys that exist on the
|
|
417
|
+
* Sticks to the keys that exist on the animatable surface so the
|
|
418
418
|
* returned style fragment is always a legal RN style.
|
|
419
419
|
*/
|
|
420
420
|
type ColorStyleKey = 'backgroundColor' | 'color' | 'borderColor' | 'borderTopColor' | 'borderRightColor' | 'borderBottomColor' | 'borderLeftColor' | 'tintColor' | 'shadowColor';
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
3
|
+
var chunk4NAMD62I_js = require('./chunk-4NAMD62I.js');
|
|
4
|
+
var chunkK63LXGKS_js = require('./chunk-K63LXGKS.js');
|
|
5
|
+
var chunk67GHRCF6_js = require('./chunk-67GHRCF6.js');
|
|
6
|
+
var chunkGPOMFIIU_js = require('./chunk-GPOMFIIU.js');
|
|
7
|
+
var chunk27U6766G_js = require('./chunk-27U6766G.js');
|
|
8
|
+
var chunkQQVDZKSD_js = require('./chunk-QQVDZKSD.js');
|
|
9
|
+
var chunkVQ5D35UA_js = require('./chunk-VQ5D35UA.js');
|
|
10
|
+
var chunkOBRGJAST_js = require('./chunk-OBRGJAST.js');
|
|
11
|
+
var chunkPM6CVGXJ_js = require('./chunk-PM6CVGXJ.js');
|
|
12
12
|
var react = require('react');
|
|
13
13
|
var reactNativeReanimated = require('react-native-reanimated');
|
|
14
14
|
var reactNativeWorklets = require('react-native-worklets');
|
|
15
15
|
|
|
16
16
|
// src/motion/index.ts
|
|
17
17
|
var Motion = {
|
|
18
|
-
View:
|
|
19
|
-
Text:
|
|
20
|
-
Image:
|
|
21
|
-
Pressable:
|
|
22
|
-
ScrollView:
|
|
18
|
+
View: chunkK63LXGKS_js.MotionView,
|
|
19
|
+
Text: chunk67GHRCF6_js.MotionText,
|
|
20
|
+
Image: chunkGPOMFIIU_js.MotionImage,
|
|
21
|
+
Pressable: chunk27U6766G_js.MotionPressable,
|
|
22
|
+
ScrollView: chunkQQVDZKSD_js.MotionScrollView
|
|
23
23
|
};
|
|
24
24
|
function useAnimation(target, transition) {
|
|
25
25
|
const output = reactNativeReanimated.useSharedValue(target);
|
|
26
|
-
const shouldReduceMotion =
|
|
27
|
-
const resolved =
|
|
28
|
-
const cfgSig =
|
|
26
|
+
const shouldReduceMotion = chunkOBRGJAST_js.useShouldReduceMotion();
|
|
27
|
+
const resolved = chunkOBRGJAST_js.resolveNamedTransition(transition, chunkOBRGJAST_js.useNamedTransitions());
|
|
28
|
+
const cfgSig = chunkPM6CVGXJ_js.stableSig(resolved);
|
|
29
29
|
react.useEffect(() => {
|
|
30
30
|
const cfg = shouldReduceMotion ? { type: "no-animation" } : resolved ?? { type: "spring" };
|
|
31
|
-
output.value =
|
|
31
|
+
output.value = chunkPM6CVGXJ_js.resolveTransition(cfg, target);
|
|
32
32
|
}, [target, cfgSig, shouldReduceMotion]);
|
|
33
33
|
react.useEffect(
|
|
34
34
|
() => () => reactNativeReanimated.cancelAnimation(output),
|
|
@@ -39,22 +39,22 @@ function useAnimation(target, transition) {
|
|
|
39
39
|
return output;
|
|
40
40
|
}
|
|
41
41
|
function useAnimator() {
|
|
42
|
-
const registry =
|
|
43
|
-
const shouldReduceMotion =
|
|
42
|
+
const registry = chunkOBRGJAST_js.useNamedTransitions();
|
|
43
|
+
const shouldReduceMotion = chunkOBRGJAST_js.useShouldReduceMotion();
|
|
44
44
|
const registryRef = react.useRef(registry);
|
|
45
45
|
registryRef.current = registry;
|
|
46
46
|
const reduceMotionRef = react.useRef(shouldReduceMotion);
|
|
47
47
|
reduceMotionRef.current = shouldReduceMotion;
|
|
48
48
|
return react.useCallback((value, to, transition) => {
|
|
49
|
-
const resolved =
|
|
49
|
+
const resolved = chunkOBRGJAST_js.resolveNamedTransition(transition, registryRef.current);
|
|
50
50
|
const cfg = reduceMotionRef.current ? { type: "no-animation" } : resolved ?? { type: "spring" };
|
|
51
|
-
value.value =
|
|
51
|
+
value.value = chunkPM6CVGXJ_js.resolveTransition(cfg, to);
|
|
52
52
|
}, []);
|
|
53
53
|
}
|
|
54
54
|
function useSpring(target, config) {
|
|
55
|
-
const spring = resolveSpringInput(config,
|
|
55
|
+
const spring = resolveSpringInput(config, chunkOBRGJAST_js.useNamedTransitions());
|
|
56
56
|
const reanimConfig = react.useMemo(
|
|
57
|
-
() =>
|
|
57
|
+
() => chunkPM6CVGXJ_js.springToReanimated(spring ?? {}),
|
|
58
58
|
// Keyed on the resolved primitive fields rather than the `config` object
|
|
59
59
|
// identity: callers routinely pass a fresh object literal each render, so
|
|
60
60
|
// depending on `config` itself would rebuild the Reanimated config on
|
|
@@ -99,7 +99,7 @@ function useSpring(target, config) {
|
|
|
99
99
|
}
|
|
100
100
|
function resolveSpringInput(config, registry) {
|
|
101
101
|
if (typeof config !== "string") return config;
|
|
102
|
-
const cfg =
|
|
102
|
+
const cfg = chunkOBRGJAST_js.lookupNamedTransition(config, registry);
|
|
103
103
|
if (cfg.type === void 0 || cfg.type === "spring") return cfg;
|
|
104
104
|
if (__DEV__) {
|
|
105
105
|
console.warn(
|
|
@@ -296,7 +296,7 @@ function useTransform(arg1, inputRange, outputRange, options) {
|
|
|
296
296
|
if (reactNativeWorklets.isWorkletFunction(userFn)) {
|
|
297
297
|
producer = userFn;
|
|
298
298
|
} else {
|
|
299
|
-
|
|
299
|
+
chunkPM6CVGXJ_js.warnNonWorkletOnce(
|
|
300
300
|
"useTransform-transformer",
|
|
301
301
|
"[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."
|
|
302
302
|
);
|
|
@@ -352,127 +352,6 @@ function useScroll() {
|
|
|
352
352
|
onScroll: handler
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
|
-
|
|
356
|
-
// src/internal/boxShadow.ts
|
|
357
|
-
var LENGTH = /^[+-]?(\d+\.?\d*|\.\d+)(px)?$/i;
|
|
358
|
-
var UNIT_LIKE = /^[+-]?(\d+\.?\d*|\.\d+)[a-z%]+$/i;
|
|
359
|
-
function invalid(input, reason) {
|
|
360
|
-
return new Error(
|
|
361
|
-
`[inertia] parseBoxShadow: ${reason} in ${JSON.stringify(input)}. Expected CSS box-shadow syntax with px lengths: '[inset] <offset-x> <offset-y> [blur] [spread] [color], ...'`
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
function splitLayers(input) {
|
|
365
|
-
const layers = [];
|
|
366
|
-
let depth = 0;
|
|
367
|
-
let start = 0;
|
|
368
|
-
for (let i = 0; i < input.length; i++) {
|
|
369
|
-
const ch = input[i];
|
|
370
|
-
if (ch === "(") depth++;
|
|
371
|
-
else if (ch === ")") depth--;
|
|
372
|
-
else if (ch === "," && depth === 0) {
|
|
373
|
-
layers.push(input.slice(start, i));
|
|
374
|
-
start = i + 1;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
layers.push(input.slice(start));
|
|
378
|
-
return layers;
|
|
379
|
-
}
|
|
380
|
-
function tokenize(layer) {
|
|
381
|
-
const tokens = [];
|
|
382
|
-
let depth = 0;
|
|
383
|
-
let current = "";
|
|
384
|
-
for (const ch of layer) {
|
|
385
|
-
if (ch === "(") depth++;
|
|
386
|
-
else if (ch === ")") depth--;
|
|
387
|
-
if (depth === 0 && /\s/.test(ch)) {
|
|
388
|
-
if (current) tokens.push(current);
|
|
389
|
-
current = "";
|
|
390
|
-
} else {
|
|
391
|
-
current += ch;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
if (current) tokens.push(current);
|
|
395
|
-
return tokens;
|
|
396
|
-
}
|
|
397
|
-
function parseBoxShadow(input) {
|
|
398
|
-
const trimmed = input.trim();
|
|
399
|
-
if (trimmed === "") throw invalid(input, "empty string");
|
|
400
|
-
if (trimmed.toLowerCase() === "none") return [];
|
|
401
|
-
return splitLayers(trimmed).map((layerString) => {
|
|
402
|
-
const tokens = tokenize(layerString.trim());
|
|
403
|
-
if (tokens.length === 0) throw invalid(input, "empty layer");
|
|
404
|
-
const lengths = [];
|
|
405
|
-
let color;
|
|
406
|
-
let inset = false;
|
|
407
|
-
for (const token of tokens) {
|
|
408
|
-
if (token.toLowerCase() === "inset") {
|
|
409
|
-
if (inset) throw invalid(input, "duplicate 'inset'");
|
|
410
|
-
inset = true;
|
|
411
|
-
} else if (LENGTH.test(token)) {
|
|
412
|
-
lengths.push(parseFloat(token));
|
|
413
|
-
} else if (UNIT_LIKE.test(token)) {
|
|
414
|
-
throw invalid(input, `unsupported unit in ${JSON.stringify(token)}`);
|
|
415
|
-
} else {
|
|
416
|
-
if (color !== void 0) throw invalid(input, "multiple colors");
|
|
417
|
-
color = token;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
if (lengths.length < 2 || lengths.length > 4) {
|
|
421
|
-
throw invalid(input, `expected 2-4 lengths, got ${lengths.length}`);
|
|
422
|
-
}
|
|
423
|
-
const [offsetX = 0, offsetY = 0, blurRadius = 0, spreadDistance = 0] = lengths;
|
|
424
|
-
if (blurRadius < 0) throw invalid(input, "negative blur radius");
|
|
425
|
-
return {
|
|
426
|
-
offsetX,
|
|
427
|
-
offsetY,
|
|
428
|
-
blurRadius,
|
|
429
|
-
spreadDistance,
|
|
430
|
-
color: color ?? "black",
|
|
431
|
-
inset
|
|
432
|
-
};
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
function resolveBoxShadowInput(input) {
|
|
436
|
-
if (input === void 0) return [];
|
|
437
|
-
if (typeof input === "string") return parseBoxShadow(input);
|
|
438
|
-
return input.map((layer) => ({
|
|
439
|
-
offsetX: layer.offsetX,
|
|
440
|
-
offsetY: layer.offsetY,
|
|
441
|
-
blurRadius: layer.blurRadius ?? 0,
|
|
442
|
-
spreadDistance: layer.spreadDistance ?? 0,
|
|
443
|
-
color: layer.color ?? "black",
|
|
444
|
-
inset: layer.inset ?? false
|
|
445
|
-
}));
|
|
446
|
-
}
|
|
447
|
-
function pairBoxShadowLayers(from, to) {
|
|
448
|
-
const count = Math.max(from.length, to.length);
|
|
449
|
-
const pairs = [];
|
|
450
|
-
for (let i = 0; i < count; i++) {
|
|
451
|
-
const a = from[i];
|
|
452
|
-
const b = to[i];
|
|
453
|
-
const fromLayer = a ?? invisibleLayer(b.inset);
|
|
454
|
-
const toLayer = b ?? invisibleLayer(a.inset);
|
|
455
|
-
if (fromLayer.inset !== toLayer.inset) {
|
|
456
|
-
throw new Error(
|
|
457
|
-
`[inertia] useShadow: boxShadow layer ${i} is 'inset' on one side but not the other \u2014 inset cannot be interpolated. Give both sides the same inset-ness (pad with a transparent layer if needed).`
|
|
458
|
-
);
|
|
459
|
-
}
|
|
460
|
-
pairs.push({ from: fromLayer, to: toLayer });
|
|
461
|
-
}
|
|
462
|
-
return pairs;
|
|
463
|
-
}
|
|
464
|
-
function invisibleLayer(inset) {
|
|
465
|
-
return {
|
|
466
|
-
offsetX: 0,
|
|
467
|
-
offsetY: 0,
|
|
468
|
-
blurRadius: 0,
|
|
469
|
-
spreadDistance: 0,
|
|
470
|
-
color: "transparent",
|
|
471
|
-
inset
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// src/values/useShadow.ts
|
|
476
355
|
function useShadow({
|
|
477
356
|
from,
|
|
478
357
|
to,
|
|
@@ -483,9 +362,9 @@ function useShadow({
|
|
|
483
362
|
const hasElevation = from.elevation !== void 0 || to.elevation !== void 0;
|
|
484
363
|
const hasColor = from.shadowColor !== void 0 || to.shadowColor !== void 0;
|
|
485
364
|
const hasOffset = from.shadowOffset !== void 0 || to.shadowOffset !== void 0;
|
|
486
|
-
const boxShadowPairs = from.boxShadow !== void 0 || to.boxShadow !== void 0 ? pairBoxShadowLayers(
|
|
487
|
-
resolveBoxShadowInput(from.boxShadow),
|
|
488
|
-
resolveBoxShadowInput(to.boxShadow)
|
|
365
|
+
const boxShadowPairs = from.boxShadow !== void 0 || to.boxShadow !== void 0 ? chunkVQ5D35UA_js.pairBoxShadowLayers(
|
|
366
|
+
chunkVQ5D35UA_js.resolveBoxShadowInput(from.boxShadow),
|
|
367
|
+
chunkVQ5D35UA_js.resolveBoxShadowInput(to.boxShadow)
|
|
489
368
|
) : [];
|
|
490
369
|
const opacityFrom = from.shadowOpacity ?? 0;
|
|
491
370
|
const opacityTo = to.shadowOpacity ?? 0;
|
|
@@ -584,79 +463,79 @@ function useVariants(variants, initial) {
|
|
|
584
463
|
|
|
585
464
|
Object.defineProperty(exports, "useGesture", {
|
|
586
465
|
enumerable: true,
|
|
587
|
-
get: function () { return
|
|
466
|
+
get: function () { return chunk4NAMD62I_js.useGesture; }
|
|
588
467
|
});
|
|
589
468
|
Object.defineProperty(exports, "MotionView", {
|
|
590
469
|
enumerable: true,
|
|
591
|
-
get: function () { return
|
|
470
|
+
get: function () { return chunkK63LXGKS_js.MotionView; }
|
|
592
471
|
});
|
|
593
472
|
Object.defineProperty(exports, "MotionText", {
|
|
594
473
|
enumerable: true,
|
|
595
|
-
get: function () { return
|
|
474
|
+
get: function () { return chunk67GHRCF6_js.MotionText; }
|
|
596
475
|
});
|
|
597
476
|
Object.defineProperty(exports, "MotionImage", {
|
|
598
477
|
enumerable: true,
|
|
599
|
-
get: function () { return
|
|
478
|
+
get: function () { return chunkGPOMFIIU_js.MotionImage; }
|
|
600
479
|
});
|
|
601
480
|
Object.defineProperty(exports, "MotionPressable", {
|
|
602
481
|
enumerable: true,
|
|
603
|
-
get: function () { return
|
|
482
|
+
get: function () { return chunk27U6766G_js.MotionPressable; }
|
|
604
483
|
});
|
|
605
484
|
Object.defineProperty(exports, "MotionScrollView", {
|
|
606
485
|
enumerable: true,
|
|
607
|
-
get: function () { return
|
|
486
|
+
get: function () { return chunkQQVDZKSD_js.MotionScrollView; }
|
|
608
487
|
});
|
|
609
488
|
Object.defineProperty(exports, "Presence", {
|
|
610
489
|
enumerable: true,
|
|
611
|
-
get: function () { return
|
|
490
|
+
get: function () { return chunkVQ5D35UA_js.Presence; }
|
|
612
491
|
});
|
|
613
492
|
Object.defineProperty(exports, "createMotionComponent", {
|
|
614
493
|
enumerable: true,
|
|
615
|
-
get: function () { return
|
|
494
|
+
get: function () { return chunkVQ5D35UA_js.createMotionComponent; }
|
|
616
495
|
});
|
|
617
496
|
Object.defineProperty(exports, "usePresence", {
|
|
618
497
|
enumerable: true,
|
|
619
|
-
get: function () { return
|
|
498
|
+
get: function () { return chunkVQ5D35UA_js.usePresence; }
|
|
620
499
|
});
|
|
621
500
|
Object.defineProperty(exports, "MotionConfig", {
|
|
622
501
|
enumerable: true,
|
|
623
|
-
get: function () { return
|
|
502
|
+
get: function () { return chunkOBRGJAST_js.MotionConfig; }
|
|
624
503
|
});
|
|
625
504
|
Object.defineProperty(exports, "resolveNamedTransition", {
|
|
626
505
|
enumerable: true,
|
|
627
|
-
get: function () { return
|
|
506
|
+
get: function () { return chunkOBRGJAST_js.resolveNamedTransition; }
|
|
628
507
|
});
|
|
629
508
|
Object.defineProperty(exports, "useMotionConfig", {
|
|
630
509
|
enumerable: true,
|
|
631
|
-
get: function () { return
|
|
510
|
+
get: function () { return chunkOBRGJAST_js.useMotionConfig; }
|
|
632
511
|
});
|
|
633
512
|
Object.defineProperty(exports, "useNamedTransitions", {
|
|
634
513
|
enumerable: true,
|
|
635
|
-
get: function () { return
|
|
514
|
+
get: function () { return chunkOBRGJAST_js.useNamedTransitions; }
|
|
636
515
|
});
|
|
637
516
|
Object.defineProperty(exports, "useShouldReduceMotion", {
|
|
638
517
|
enumerable: true,
|
|
639
|
-
get: function () { return
|
|
518
|
+
get: function () { return chunkOBRGJAST_js.useShouldReduceMotion; }
|
|
640
519
|
});
|
|
641
520
|
Object.defineProperty(exports, "buildReleaseAnimation", {
|
|
642
521
|
enumerable: true,
|
|
643
|
-
get: function () { return
|
|
522
|
+
get: function () { return chunkPM6CVGXJ_js.buildReleaseAnimation; }
|
|
644
523
|
});
|
|
645
524
|
Object.defineProperty(exports, "cubicBezier", {
|
|
646
525
|
enumerable: true,
|
|
647
|
-
get: function () { return
|
|
526
|
+
get: function () { return chunkPM6CVGXJ_js.cubicBezier; }
|
|
648
527
|
});
|
|
649
528
|
Object.defineProperty(exports, "ensureWorkletEasing", {
|
|
650
529
|
enumerable: true,
|
|
651
|
-
get: function () { return
|
|
530
|
+
get: function () { return chunkPM6CVGXJ_js.ensureWorkletEasing; }
|
|
652
531
|
});
|
|
653
532
|
Object.defineProperty(exports, "resolveAnimatableValue", {
|
|
654
533
|
enumerable: true,
|
|
655
|
-
get: function () { return
|
|
534
|
+
get: function () { return chunkPM6CVGXJ_js.resolveAnimatableValue; }
|
|
656
535
|
});
|
|
657
536
|
Object.defineProperty(exports, "resolveTransition", {
|
|
658
537
|
enumerable: true,
|
|
659
|
-
get: function () { return
|
|
538
|
+
get: function () { return chunkPM6CVGXJ_js.resolveTransition; }
|
|
660
539
|
});
|
|
661
540
|
exports.Motion = Motion;
|
|
662
541
|
exports.useAnimation = useAnimation;
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
export { useGesture } from './chunk-
|
|
2
|
-
import { MotionView } from './chunk-
|
|
3
|
-
export { MotionView } from './chunk-
|
|
4
|
-
import { MotionText } from './chunk-
|
|
5
|
-
export { MotionText } from './chunk-
|
|
6
|
-
import { MotionImage } from './chunk-
|
|
7
|
-
export { MotionImage } from './chunk-
|
|
8
|
-
import { MotionPressable } from './chunk-
|
|
9
|
-
export { MotionPressable } from './chunk-
|
|
10
|
-
import { MotionScrollView } from './chunk-
|
|
11
|
-
export { MotionScrollView } from './chunk-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
export { useGesture } from './chunk-OW5XTGVN.mjs';
|
|
2
|
+
import { MotionView } from './chunk-GTJ6VAH5.mjs';
|
|
3
|
+
export { MotionView } from './chunk-GTJ6VAH5.mjs';
|
|
4
|
+
import { MotionText } from './chunk-COEJVWRZ.mjs';
|
|
5
|
+
export { MotionText } from './chunk-COEJVWRZ.mjs';
|
|
6
|
+
import { MotionImage } from './chunk-XSK5MNUH.mjs';
|
|
7
|
+
export { MotionImage } from './chunk-XSK5MNUH.mjs';
|
|
8
|
+
import { MotionPressable } from './chunk-OAUWLPQH.mjs';
|
|
9
|
+
export { MotionPressable } from './chunk-OAUWLPQH.mjs';
|
|
10
|
+
import { MotionScrollView } from './chunk-27MKBTSG.mjs';
|
|
11
|
+
export { MotionScrollView } from './chunk-27MKBTSG.mjs';
|
|
12
|
+
import { pairBoxShadowLayers, resolveBoxShadowInput } from './chunk-RIVVBABB.mjs';
|
|
13
|
+
export { Presence, createMotionComponent, usePresence } from './chunk-RIVVBABB.mjs';
|
|
14
|
+
import { useShouldReduceMotion, resolveNamedTransition, useNamedTransitions, lookupNamedTransition } from './chunk-Z3HCJ43H.mjs';
|
|
15
|
+
export { MotionConfig, resolveNamedTransition, useMotionConfig, useNamedTransitions, useShouldReduceMotion } from './chunk-Z3HCJ43H.mjs';
|
|
16
|
+
import { stableSig, resolveTransition, springToReanimated, warnNonWorkletOnce } from './chunk-REYL77RE.mjs';
|
|
17
|
+
export { buildReleaseAnimation, cubicBezier, ensureWorkletEasing, resolveAnimatableValue, resolveTransition } from './chunk-REYL77RE.mjs';
|
|
17
18
|
import { useEffect, useRef, useCallback, useMemo } from 'react';
|
|
18
19
|
import { useSharedValue, cancelAnimation, withSpring, useAnimatedReaction, useAnimatedStyle, interpolateColor, interpolate, useDerivedValue, Extrapolation, useAnimatedScrollHandler } from 'react-native-reanimated';
|
|
19
20
|
import { isWorkletFunction } from 'react-native-worklets';
|
|
@@ -357,127 +358,6 @@ function useScroll() {
|
|
|
357
358
|
onScroll: handler
|
|
358
359
|
};
|
|
359
360
|
}
|
|
360
|
-
|
|
361
|
-
// src/internal/boxShadow.ts
|
|
362
|
-
var LENGTH = /^[+-]?(\d+\.?\d*|\.\d+)(px)?$/i;
|
|
363
|
-
var UNIT_LIKE = /^[+-]?(\d+\.?\d*|\.\d+)[a-z%]+$/i;
|
|
364
|
-
function invalid(input, reason) {
|
|
365
|
-
return new Error(
|
|
366
|
-
`[inertia] parseBoxShadow: ${reason} in ${JSON.stringify(input)}. Expected CSS box-shadow syntax with px lengths: '[inset] <offset-x> <offset-y> [blur] [spread] [color], ...'`
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
function splitLayers(input) {
|
|
370
|
-
const layers = [];
|
|
371
|
-
let depth = 0;
|
|
372
|
-
let start = 0;
|
|
373
|
-
for (let i = 0; i < input.length; i++) {
|
|
374
|
-
const ch = input[i];
|
|
375
|
-
if (ch === "(") depth++;
|
|
376
|
-
else if (ch === ")") depth--;
|
|
377
|
-
else if (ch === "," && depth === 0) {
|
|
378
|
-
layers.push(input.slice(start, i));
|
|
379
|
-
start = i + 1;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
layers.push(input.slice(start));
|
|
383
|
-
return layers;
|
|
384
|
-
}
|
|
385
|
-
function tokenize(layer) {
|
|
386
|
-
const tokens = [];
|
|
387
|
-
let depth = 0;
|
|
388
|
-
let current = "";
|
|
389
|
-
for (const ch of layer) {
|
|
390
|
-
if (ch === "(") depth++;
|
|
391
|
-
else if (ch === ")") depth--;
|
|
392
|
-
if (depth === 0 && /\s/.test(ch)) {
|
|
393
|
-
if (current) tokens.push(current);
|
|
394
|
-
current = "";
|
|
395
|
-
} else {
|
|
396
|
-
current += ch;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
if (current) tokens.push(current);
|
|
400
|
-
return tokens;
|
|
401
|
-
}
|
|
402
|
-
function parseBoxShadow(input) {
|
|
403
|
-
const trimmed = input.trim();
|
|
404
|
-
if (trimmed === "") throw invalid(input, "empty string");
|
|
405
|
-
if (trimmed.toLowerCase() === "none") return [];
|
|
406
|
-
return splitLayers(trimmed).map((layerString) => {
|
|
407
|
-
const tokens = tokenize(layerString.trim());
|
|
408
|
-
if (tokens.length === 0) throw invalid(input, "empty layer");
|
|
409
|
-
const lengths = [];
|
|
410
|
-
let color;
|
|
411
|
-
let inset = false;
|
|
412
|
-
for (const token of tokens) {
|
|
413
|
-
if (token.toLowerCase() === "inset") {
|
|
414
|
-
if (inset) throw invalid(input, "duplicate 'inset'");
|
|
415
|
-
inset = true;
|
|
416
|
-
} else if (LENGTH.test(token)) {
|
|
417
|
-
lengths.push(parseFloat(token));
|
|
418
|
-
} else if (UNIT_LIKE.test(token)) {
|
|
419
|
-
throw invalid(input, `unsupported unit in ${JSON.stringify(token)}`);
|
|
420
|
-
} else {
|
|
421
|
-
if (color !== void 0) throw invalid(input, "multiple colors");
|
|
422
|
-
color = token;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
if (lengths.length < 2 || lengths.length > 4) {
|
|
426
|
-
throw invalid(input, `expected 2-4 lengths, got ${lengths.length}`);
|
|
427
|
-
}
|
|
428
|
-
const [offsetX = 0, offsetY = 0, blurRadius = 0, spreadDistance = 0] = lengths;
|
|
429
|
-
if (blurRadius < 0) throw invalid(input, "negative blur radius");
|
|
430
|
-
return {
|
|
431
|
-
offsetX,
|
|
432
|
-
offsetY,
|
|
433
|
-
blurRadius,
|
|
434
|
-
spreadDistance,
|
|
435
|
-
color: color ?? "black",
|
|
436
|
-
inset
|
|
437
|
-
};
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
function resolveBoxShadowInput(input) {
|
|
441
|
-
if (input === void 0) return [];
|
|
442
|
-
if (typeof input === "string") return parseBoxShadow(input);
|
|
443
|
-
return input.map((layer) => ({
|
|
444
|
-
offsetX: layer.offsetX,
|
|
445
|
-
offsetY: layer.offsetY,
|
|
446
|
-
blurRadius: layer.blurRadius ?? 0,
|
|
447
|
-
spreadDistance: layer.spreadDistance ?? 0,
|
|
448
|
-
color: layer.color ?? "black",
|
|
449
|
-
inset: layer.inset ?? false
|
|
450
|
-
}));
|
|
451
|
-
}
|
|
452
|
-
function pairBoxShadowLayers(from, to) {
|
|
453
|
-
const count = Math.max(from.length, to.length);
|
|
454
|
-
const pairs = [];
|
|
455
|
-
for (let i = 0; i < count; i++) {
|
|
456
|
-
const a = from[i];
|
|
457
|
-
const b = to[i];
|
|
458
|
-
const fromLayer = a ?? invisibleLayer(b.inset);
|
|
459
|
-
const toLayer = b ?? invisibleLayer(a.inset);
|
|
460
|
-
if (fromLayer.inset !== toLayer.inset) {
|
|
461
|
-
throw new Error(
|
|
462
|
-
`[inertia] useShadow: boxShadow layer ${i} is 'inset' on one side but not the other \u2014 inset cannot be interpolated. Give both sides the same inset-ness (pad with a transparent layer if needed).`
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
pairs.push({ from: fromLayer, to: toLayer });
|
|
466
|
-
}
|
|
467
|
-
return pairs;
|
|
468
|
-
}
|
|
469
|
-
function invisibleLayer(inset) {
|
|
470
|
-
return {
|
|
471
|
-
offsetX: 0,
|
|
472
|
-
offsetY: 0,
|
|
473
|
-
blurRadius: 0,
|
|
474
|
-
spreadDistance: 0,
|
|
475
|
-
color: "transparent",
|
|
476
|
-
inset
|
|
477
|
-
};
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// src/values/useShadow.ts
|
|
481
361
|
function useShadow({
|
|
482
362
|
from,
|
|
483
363
|
to,
|
package/dist/motion/Image.d.mts
CHANGED