@tamagui/animations-react-native 2.7.7 → 3.0.0-beta.1097.1

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/dist/cjs/createAnimations.native.cjs +692 -0
  2. package/dist/cjs/createAnimations.native.js +643 -597
  3. package/dist/cjs/createAnimations.native.js.map +1 -1
  4. package/dist/cjs/index.cjs +19 -13
  5. package/dist/cjs/index.native.cjs +21 -0
  6. package/dist/cjs/index.native.js +12 -13
  7. package/dist/cjs/index.native.js.map +1 -1
  8. package/dist/cjs/polyfill.cjs +2 -2
  9. package/dist/cjs/polyfill.native.cjs +5 -0
  10. package/dist/cjs/polyfill.native.js +2 -1
  11. package/dist/cjs/polyfill.native.js.map +1 -1
  12. package/dist/cjs/types.cjs +16 -0
  13. package/dist/cjs/types.native.cjs +18 -0
  14. package/dist/cjs/types.native.js +20 -0
  15. package/dist/cjs/types.native.js.map +1 -0
  16. package/dist/esm/createAnimations.native.js +621 -567
  17. package/dist/esm/createAnimations.native.js.map +1 -1
  18. package/dist/esm/index.js +6 -2
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/index.mjs +6 -2
  21. package/dist/esm/index.mjs.map +1 -1
  22. package/dist/esm/index.native.js +2 -2
  23. package/dist/esm/polyfill.mjs +2 -1
  24. package/dist/esm/polyfill.mjs.map +1 -1
  25. package/dist/esm/polyfill.native.js +2 -1
  26. package/dist/esm/polyfill.native.js.map +1 -1
  27. package/dist/esm/types.mjs +0 -0
  28. package/dist/esm/types.native.js +0 -0
  29. package/package.json +15 -10
  30. package/src/{createAnimations.tsx → createAnimations.native.tsx} +277 -137
  31. package/src/index.native.ts +3 -0
  32. package/src/index.ts +20 -2
  33. package/src/types.ts +4 -0
  34. package/types/{createAnimations.d.ts → createAnimations.native.d.ts} +5 -14
  35. package/types/createAnimations.native.d.ts.map +11 -0
  36. package/types/index.d.ts +10 -2
  37. package/types/index.d.ts.map +2 -2
  38. package/types/index.native.d.ts +4 -0
  39. package/types/index.native.d.ts.map +11 -0
  40. package/types/types.d.ts +5 -0
  41. package/types/types.d.ts.map +11 -0
  42. package/dist/cjs/createAnimations.cjs +0 -566
  43. package/dist/esm/createAnimations.mjs +0 -524
  44. package/dist/esm/createAnimations.mjs.map +0 -1
  45. package/dist/esm/index.native.js.map +0 -1
  46. package/types/createAnimations.d.ts.map +0 -11
@@ -1,603 +1,657 @@
1
- import { getEffectiveAnimation, normalizeTransition } from "@tamagui/animation-helpers";
1
+ import { easingToBezier, forAnimationState, getTransitionForKey, resolveTransition } from "@tamagui/animation-helpers";
2
2
  import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
3
3
  import { ResetPresence, usePresence } from "@tamagui/use-presence";
4
- import { useEvent, useThemeWithState } from "@tamagui/web";
4
+ import { useEvent } from "@tamagui/web";
5
+ import { useThemeWithState } from "@tamagui/web/internal-runtime";
5
6
  import React from "react";
6
- import { Animated } from "react-native";
7
- function _type_of(obj) {
8
- "@swc/helpers - typeof";
7
+ import { Animated, Easing, processColor } from "react-native";
9
8
 
10
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
11
- }
12
9
  var isFabric = !isWeb && typeof global !== "undefined" && !!global.__nativeFabricUIManager;
13
- var resolveDynamicValue = function (value, isDark) {
14
- if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "dynamic" in value) {
15
- var dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light;
16
- return dynamicValue;
17
- }
18
- return value;
10
+ var resolveDynamicValue = function(value, isDark) {
11
+ if (value && typeof value === "object" && "dynamic" in value) {
12
+ var dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light;
13
+ return dynamicValue;
14
+ }
15
+ return value;
19
16
  };
20
17
  var animatedStyleKey = {
21
- transform: true,
22
- opacity: true
18
+ transform: true,
19
+ opacity: true
23
20
  };
24
21
  var colorStyleKey = {
25
- backgroundColor: true,
26
- color: true,
27
- borderColor: true,
28
- borderLeftColor: true,
29
- borderRightColor: true,
30
- borderTopColor: true,
31
- borderBottomColor: true
22
+ backgroundColor: true,
23
+ color: true,
24
+ borderColor: true,
25
+ borderLeftColor: true,
26
+ borderRightColor: true,
27
+ borderTopColor: true,
28
+ borderBottomColor: true
32
29
  };
33
30
  var layoutStyleKey = {
34
- height: true,
35
- width: true,
36
- minHeight: true,
37
- maxHeight: true,
38
- minWidth: true,
39
- maxWidth: true
31
+ height: true,
32
+ width: true,
33
+ minHeight: true,
34
+ maxHeight: true,
35
+ minWidth: true,
36
+ maxWidth: true
40
37
  };
41
- function hasAnimatedLayoutKey(style, isDark, animateOnly) {
42
- for (var key in layoutStyleKey) {
43
- if (animateOnly && !animateOnly.includes(key)) continue;
44
- if (typeof resolveDynamicValue(style[key], isDark) === "number") return true;
45
- }
46
- return false;
38
+ function hasAnimatedLayoutKey(style, isDark, resolved) {
39
+ for (var key in layoutStyleKey) {
40
+ if (!getTransitionForKey(resolved, key)) continue;
41
+ if (typeof resolveDynamicValue(style[key], isDark) === "number") return true;
42
+ }
43
+ return false;
47
44
  }
48
45
  function isAnimatableColor(value) {
49
- if (typeof value !== "string") return false;
50
- if (value === "") return false;
51
- if (value.includes("var(") || value.includes("calc(")) return false;
52
- return true;
46
+ return typeof value === "string" && processColor(value) != null;
53
47
  }
54
48
  var costlyToAnimateStyleKey = {
55
- borderRadius: true,
56
- borderTopLeftRadius: true,
57
- borderTopRightRadius: true,
58
- borderBottomLeftRadius: true,
59
- borderBottomRightRadius: true,
60
- borderWidth: true,
61
- borderLeftWidth: true,
62
- borderRightWidth: true,
63
- borderTopWidth: true,
64
- borderBottomWidth: true,
65
- ...colorStyleKey
49
+ borderRadius: true,
50
+ borderTopLeftRadius: true,
51
+ borderTopRightRadius: true,
52
+ borderBottomLeftRadius: true,
53
+ borderBottomRightRadius: true,
54
+ borderWidth: true,
55
+ borderLeftWidth: true,
56
+ borderRightWidth: true,
57
+ borderTopWidth: true,
58
+ borderBottomWidth: true,
59
+ ...colorStyleKey
66
60
  };
67
61
  var AnimatedView = Animated.View;
68
62
  var AnimatedText = Animated.Text;
69
63
  function useAnimatedNumber(initial) {
70
- var state = React.useRef(null);
71
- if (!state.current) {
72
- state.current = {
73
- composite: null,
74
- val: new Animated.Value(initial),
75
- strategy: {
76
- type: "spring"
77
- }
78
- };
79
- }
80
- return {
81
- getInstance() {
82
- return state.current.val;
83
- },
84
- getValue() {
85
- return state.current.val["_value"];
86
- },
87
- stop() {
88
- var _state_current_composite;
89
- (_state_current_composite = state.current.composite) === null || _state_current_composite === void 0 ? void 0 : _state_current_composite.stop();
90
- state.current.composite = null;
91
- },
92
- setValue(next) {
93
- var {
94
- type,
95
- ...config
96
- } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
97
- type: "spring"
98
- },
99
- onFinish = arguments.length > 2 ? arguments[2] : void 0;
100
- var val = state.current.val;
101
- var handleFinish = onFinish ? function (param) {
102
- var {
103
- finished
104
- } = param;
105
- return finished ? onFinish() : null;
106
- } : void 0;
107
- if (type === "direct") {
108
- val.setValue(next);
109
- } else if (type === "spring") {
110
- var _state_current_composite;
111
- (_state_current_composite = state.current.composite) === null || _state_current_composite === void 0 ? void 0 : _state_current_composite.stop();
112
- var composite = Animated.spring(val, {
113
- ...config,
114
- toValue: next,
115
- useNativeDriver: isFabric
116
- });
117
- composite.start(handleFinish);
118
- state.current.composite = composite;
119
- } else {
120
- var _state_current_composite1;
121
- (_state_current_composite1 = state.current.composite) === null || _state_current_composite1 === void 0 ? void 0 : _state_current_composite1.stop();
122
- var composite1 = Animated.timing(val, {
123
- ...config,
124
- toValue: next,
125
- useNativeDriver: isFabric
126
- });
127
- composite1.start(handleFinish);
128
- state.current.composite = composite1;
129
- }
130
- }
131
- };
64
+ var state = React.useRef(null);
65
+ if (!state.current) {
66
+ state.current = {
67
+ composite: null,
68
+ val: new Animated.Value(initial),
69
+ strategy: { type: "spring" }
70
+ };
71
+ }
72
+ return {
73
+ getInstance() {
74
+ return state.current.val;
75
+ },
76
+ getValue() {
77
+ return state.current.val["_value"];
78
+ },
79
+ stop() {
80
+ var _state_current_composite;
81
+ (_state_current_composite = state.current.composite) === null || _state_current_composite === void 0 ? void 0 : _state_current_composite.stop();
82
+ state.current.composite = null;
83
+ },
84
+ setValue(next) {
85
+ var { type, ...config } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { type: "spring" }, onFinish = arguments.length > 2 ? arguments[2] : void 0;
86
+ var val = state.current.val;
87
+ var handleFinish = onFinish ? function(param) {
88
+ var { finished } = param;
89
+ return finished ? onFinish() : null;
90
+ } : void 0;
91
+ if (type === "direct") {
92
+ var _state_current_composite;
93
+ (_state_current_composite = state.current.composite) === null || _state_current_composite === void 0 ? void 0 : _state_current_composite.stop();
94
+ state.current.composite = null;
95
+ val.setValue(next);
96
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish();
97
+ } else if (type === "spring") {
98
+ var _state_current_composite1;
99
+ (_state_current_composite1 = state.current.composite) === null || _state_current_composite1 === void 0 ? void 0 : _state_current_composite1.stop();
100
+ var composite = Animated.spring(val, {
101
+ ...config,
102
+ toValue: next,
103
+ useNativeDriver: isFabric
104
+ });
105
+ composite.start(handleFinish);
106
+ state.current.composite = composite;
107
+ } else {
108
+ var _state_current_composite2;
109
+ (_state_current_composite2 = state.current.composite) === null || _state_current_composite2 === void 0 ? void 0 : _state_current_composite2.stop();
110
+ var composite1 = Animated.timing(val, {
111
+ ...config,
112
+ toValue: next,
113
+ useNativeDriver: isFabric
114
+ });
115
+ composite1.start(handleFinish);
116
+ state.current.composite = composite1;
117
+ }
118
+ }
119
+ };
132
120
  }
133
- var useAnimatedNumberReaction = function (param, onValue) {
134
- var {
135
- value
136
- } = param;
137
- var onChange = useEvent(function (current) {
138
- onValue(current.value);
139
- });
140
- React.useEffect(function () {
141
- var id = value.getInstance().addListener(onChange);
142
- return function () {
143
- value.getInstance().removeListener(id);
144
- };
145
- }, [value, onChange]);
121
+ var useAnimatedNumberReaction = function(param, onValue) {
122
+ var { value } = param;
123
+ var onChange = useEvent(function(current) {
124
+ onValue(current.value);
125
+ });
126
+ React.useEffect(function() {
127
+ var id = value.getInstance().addListener(onChange);
128
+ return function() {
129
+ value.getInstance().removeListener(id);
130
+ };
131
+ }, [value, onChange]);
146
132
  };
147
- var useAnimatedNumberStyle = function (value, getStyle) {
148
- return getStyle(value.getInstance());
133
+ var useAnimatedNumberStyle = function(value, getStyle) {
134
+ var instance = value.getInstance();
135
+ var animatedStyle = getStyle(instance);
136
+ var usesAnimatedNode = hasAnimatedNode(animatedStyle);
137
+ var [current, setCurrent] = React.useState(value.getValue());
138
+ React.useEffect(function() {
139
+ if (usesAnimatedNode) return;
140
+ var id = instance.addListener(function(param) {
141
+ var { value: next } = param;
142
+ setCurrent(next);
143
+ });
144
+ return function() {
145
+ instance.removeListener(id);
146
+ };
147
+ }, [instance, usesAnimatedNode]);
148
+ return usesAnimatedNode ? animatedStyle : getStyle(current);
149
149
  };
150
- var useAnimatedNumbersStyle = function (vals, getStyle) {
151
- return getStyle(...vals.map(function (v) {
152
- return v.getInstance();
153
- }));
150
+ function hasAnimatedNode(value) {
151
+ if (!value || typeof value !== "object") return false;
152
+ if (typeof value.__getValue === "function") return true;
153
+ if (Array.isArray(value)) return value.some(hasAnimatedNode);
154
+ return Object.values(value).some(hasAnimatedNode);
155
+ }
156
+ var useAnimatedNumbersStyle = function(vals, getStyle) {
157
+ return getStyle(...vals.map(function(v) {
158
+ return v.getInstance();
159
+ }));
154
160
  };
155
161
  function createAnimations(animations, options) {
156
- var _options_useNativeDriver;
157
- var nativeDriver = (_options_useNativeDriver = options === null || options === void 0 ? void 0 : options.useNativeDriver) !== null && _options_useNativeDriver !== void 0 ? _options_useNativeDriver : isFabric;
158
- return {
159
- isReactNative: true,
160
- inputStyle: "value",
161
- outputStyle: "inline",
162
- avoidReRenders: true,
163
- animations,
164
- needsCustomComponent: true,
165
- View: AnimatedView,
166
- Text: AnimatedText,
167
- useAnimatedNumber,
168
- useAnimatedNumberReaction,
169
- useAnimatedNumberStyle,
170
- useAnimatedNumbersStyle,
171
- usePresence,
172
- ResetPresence,
173
- useAnimations: function (param) {
174
- var {
175
- props,
176
- onDidAnimate,
177
- style,
178
- componentState,
179
- presence,
180
- stateRef,
181
- useStyleEmitter
182
- } = param;
183
- var _themeState_name;
184
- var isDisabled = isWeb && componentState.unmounted === true;
185
- var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
186
- var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
187
- var [, themeState] = useThemeWithState({});
188
- var isDark = (themeState === null || themeState === void 0 ? void 0 : themeState.scheme) === "dark" || (themeState === null || themeState === void 0 ? void 0 : (_themeState_name = themeState.name) === null || _themeState_name === void 0 ? void 0 : _themeState_name.startsWith("dark"));
189
- var animateStyles = React.useRef({});
190
- var animatedTranforms = React.useRef([]);
191
- var animationsState = React.useRef(/* @__PURE__ */new WeakMap());
192
- var pseudoActiveRef = React.useRef(false);
193
- var exitCycleIdRef = React.useRef(0);
194
- var exitCompletedRef = React.useRef(false);
195
- var wasExitingRef = React.useRef(false);
196
- var justStartedExiting = isExiting && !wasExitingRef.current;
197
- var justStoppedExiting = !isExiting && wasExitingRef.current;
198
- if (justStartedExiting) {
199
- exitCycleIdRef.current++;
200
- exitCompletedRef.current = false;
201
- }
202
- if (justStoppedExiting) {
203
- exitCycleIdRef.current++;
204
- }
205
- var animateOnly = props.animateOnly || [];
206
- var hasTransitionOnly = !!props.animateOnly;
207
- var isEntering = !!componentState.unmounted;
208
- var wasEnteringRef = React.useRef(isEntering);
209
- var justFinishedEntering = wasEnteringRef.current && !isEntering;
210
- React.useEffect(function () {
211
- wasEnteringRef.current = isEntering;
212
- });
213
- var args = [JSON.stringify(style), componentState, isExiting, !!onDidAnimate, isDark, justFinishedEntering, hasTransitionOnly];
214
- var res = React.useMemo(function () {
215
- var runners = [];
216
- var completions = [];
217
- var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
218
- var nonAnimatedStyle = {};
219
- var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(style, isDark, hasTransitionOnly ? animateOnly : void 0);
220
- var seenAnimateKeys = /* @__PURE__ */new Set();
221
- var sawTransform = false;
222
- var transformCount = 0;
223
- for (var key in style) {
224
- var rawVal = style[key];
225
- var val = resolveDynamicValue(rawVal, isDark);
226
- if (val === void 0) continue;
227
- if (isDisabled) {
228
- continue;
229
- }
230
- if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key] && !layoutStyleKey[key]) {
231
- nonAnimatedStyle[key] = val;
232
- continue;
233
- }
234
- if (hasTransitionOnly && !animateOnly.includes(key)) {
235
- nonAnimatedStyle[key] = val;
236
- continue;
237
- }
238
- if (layoutStyleKey[key] && typeof val !== "number") {
239
- nonAnimatedStyle[key] = val;
240
- continue;
241
- }
242
- if (colorStyleKey[key] && !isAnimatableColor(val)) {
243
- nonAnimatedStyle[key] = val;
244
- continue;
245
- }
246
- if (key !== "transform") {
247
- animateStyles.current[key] = update(key, animateStyles.current[key], val);
248
- seenAnimateKeys.add(key);
249
- continue;
250
- }
251
- if (!val) continue;
252
- if (typeof val === "string") {
253
- console.warn(`Warning: Tamagui can't animate string transforms yet!`);
254
- continue;
255
- }
256
- sawTransform = true;
257
- var _iteratorNormalCompletion = true,
258
- _didIteratorError = false,
259
- _iteratorError = void 0;
260
- try {
261
- for (var _iterator = val[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
262
- var transform = _step.value;
263
- var _animatedTranforms_current_index;
264
- if (!transform) continue;
265
- var index = transformCount++;
266
- var tkey = Object.keys(transform)[0];
267
- var currentTransform = (_animatedTranforms_current_index = animatedTranforms.current[index]) === null || _animatedTranforms_current_index === void 0 ? void 0 : _animatedTranforms_current_index[tkey];
268
- animatedTranforms.current[index] = {
269
- [tkey]: update(tkey, currentTransform, transform[tkey])
270
- };
271
- animatedTranforms.current = [...animatedTranforms.current];
272
- }
273
- } catch (err) {
274
- _didIteratorError = true;
275
- _iteratorError = err;
276
- } finally {
277
- try {
278
- if (!_iteratorNormalCompletion && _iterator.return != null) {
279
- _iterator.return();
280
- }
281
- } finally {
282
- if (_didIteratorError) {
283
- throw _iteratorError;
284
- }
285
- }
286
- }
287
- }
288
- if (!isExiting && !isDisabled && !pseudoActiveRef.current) {
289
- for (var k in animateStyles.current) {
290
- if (!seenAnimateKeys.has(k)) delete animateStyles.current[k];
291
- }
292
- if (!sawTransform) {
293
- if (animatedTranforms.current.length) animatedTranforms.current = [];
294
- } else if (animatedTranforms.current.length > transformCount) {
295
- animatedTranforms.current = animatedTranforms.current.slice(0, transformCount);
296
- }
297
- }
298
- var animatedTransformStyle = animatedTranforms.current.length > 0 ? {
299
- transform: animatedTranforms.current.map(function (r) {
300
- var _animationsState_current_get;
301
- var key2 = Object.keys(r)[0];
302
- var val2 = ((_animationsState_current_get = animationsState.current.get(r[key2])) === null || _animationsState_current_get === void 0 ? void 0 : _animationsState_current_get.interpolation) || r[key2];
303
- return {
304
- [key2]: val2
305
- };
306
- })
307
- } : {};
308
- var animatedStyle = {
309
- ...Object.fromEntries(Object.entries(animateStyles.current).map(function (param2) {
310
- var [k2, v] = param2;
311
- var _animationsState_current_get;
312
- return [k2, ((_animationsState_current_get = animationsState.current.get(v)) === null || _animationsState_current_get === void 0 ? void 0 : _animationsState_current_get.interpolation) || v];
313
- })),
314
- ...animatedTransformStyle
315
- };
316
- return {
317
- runners,
318
- completions,
319
- style: [nonAnimatedStyle, animatedStyle]
320
- };
321
- function update(key2, animated, valIn) {
322
- var isColorStyleKey = colorStyleKey[key2];
323
- var [val2, type] = isColorStyleKey ? [0, void 0] : getValue(valIn);
324
- var animateToValue = val2;
325
- var value = animated || new Animated.Value(val2);
326
- var curInterpolation = animationsState.current.get(value);
327
- var interpolateArgs;
328
- if (type) {
329
- var _curInterpolation_current;
330
- interpolateArgs = getInterpolated((_curInterpolation_current = curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current) !== null && _curInterpolation_current !== void 0 ? _curInterpolation_current : value["_value"], val2, type);
331
- animationsState.current.set(value, {
332
- interpolation: value.interpolate(interpolateArgs),
333
- current: val2
334
- });
335
- }
336
- if (isColorStyleKey) {
337
- animateToValue = (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1;
338
- interpolateArgs = getColorInterpolated(curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current,
339
- // valIn is the next color
340
- valIn, animateToValue);
341
- animationsState.current.set(value, {
342
- current: valIn,
343
- interpolation: value.interpolate(interpolateArgs),
344
- animateToValue: (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1
345
- });
346
- }
347
- if (value) {
348
- var animationConfig = getAnimationConfig(key2, animations, props.transition, animationState);
349
- var resolve;
350
- var promise = new Promise(function (res2) {
351
- resolve = res2;
352
- });
353
- completions.push(promise);
354
- runners.push(function () {
355
- value.stopAnimation();
356
- function getAnimation() {
357
- return Animated[animationConfig.type || "spring"](value, {
358
- toValue: animateToValue,
359
- ...animationConfig,
360
- useNativeDriver: useNativeDriverForNode
361
- });
362
- }
363
- var animation = animationConfig.delay ? Animated.sequence([Animated.delay(animationConfig.delay), getAnimation()]) : getAnimation();
364
- animation.start(function (param2) {
365
- var {
366
- finished
367
- } = param2;
368
- if (finished || isExiting) {
369
- resolve();
370
- }
371
- });
372
- });
373
- }
374
- if (process.env.NODE_ENV === "development") {
375
- if (props["debug"] === "verbose") {
376
- console.info(" \u{1F4A0} animate", key2, `from (${value["_value"]}) to`, valIn, `(${val2})`, "type", type, "interpolate", interpolateArgs);
377
- }
378
- }
379
- return value;
380
- }
381
- }, args);
382
- React.useEffect(function () {
383
- wasExitingRef.current = isExiting;
384
- });
385
- useIsomorphicLayoutEffect(function () {
386
- res.runners.forEach(function (r) {
387
- return r();
388
- });
389
- var cycleId = exitCycleIdRef.current;
390
- if (res.completions.length === 0) {
391
- onDidAnimate === null || onDidAnimate === void 0 ? void 0 : onDidAnimate();
392
- if (isExiting && !exitCompletedRef.current) {
393
- exitCompletedRef.current = true;
394
- sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
395
- }
396
- return;
397
- }
398
- var cancel = false;
399
- Promise.all(res.completions).then(function () {
400
- if (cancel) return;
401
- if (isExiting && cycleId !== exitCycleIdRef.current) return;
402
- if (isExiting && exitCompletedRef.current) return;
403
- onDidAnimate === null || onDidAnimate === void 0 ? void 0 : onDidAnimate();
404
- if (isExiting) {
405
- exitCompletedRef.current = true;
406
- sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
407
- }
408
- });
409
- return function () {
410
- cancel = true;
411
- };
412
- }, args);
413
- useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function (nextStyle, _effectiveTransition, pseudoActive) {
414
- pseudoActiveRef.current = pseudoActive === true;
415
- var runners = [];
416
- var seenAnimateKeys = /* @__PURE__ */new Set();
417
- var transformCount = 0;
418
- var animatedShapeChanged = false;
419
- var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(nextStyle, isDark) && !Object.keys(animateStyles.current).some(function (key2) {
420
- return layoutStyleKey[key2];
421
- });
422
- for (var key in nextStyle) {
423
- var rawVal = nextStyle[key];
424
- var val = resolveDynamicValue(rawVal, isDark);
425
- if (val === void 0) continue;
426
- if (key === "transform" && Array.isArray(val)) {
427
- var _iteratorNormalCompletion = true,
428
- _didIteratorError = false,
429
- _iteratorError = void 0;
430
- try {
431
- for (var _iterator = val[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
432
- var transform = _step.value;
433
- var _animatedTranforms_current_index;
434
- if (!transform) continue;
435
- var index = transformCount++;
436
- var tkey = Object.keys(transform)[0];
437
- var currentTransform = (_animatedTranforms_current_index = animatedTranforms.current[index]) === null || _animatedTranforms_current_index === void 0 ? void 0 : _animatedTranforms_current_index[tkey];
438
- if (!currentTransform) animatedShapeChanged = true;
439
- animatedTranforms.current[index] = {
440
- [tkey]: update(tkey, currentTransform, transform[tkey])
441
- };
442
- }
443
- } catch (err) {
444
- _didIteratorError = true;
445
- _iteratorError = err;
446
- } finally {
447
- try {
448
- if (!_iteratorNormalCompletion && _iterator.return != null) {
449
- _iterator.return();
450
- }
451
- } finally {
452
- if (_didIteratorError) {
453
- throw _iteratorError;
454
- }
455
- }
456
- }
457
- } else if (animatedStyleKey[key] != null || costlyToAnimateStyleKey[key] || layoutStyleKey[key]) {
458
- if (layoutStyleKey[key] && typeof val !== "number") continue;
459
- if (colorStyleKey[key] && !isAnimatableColor(val)) continue;
460
- if (!animateStyles.current[key]) animatedShapeChanged = true;
461
- animateStyles.current[key] = update(key, animateStyles.current[key], val);
462
- seenAnimateKeys.add(key);
463
- }
464
- }
465
- for (var key1 in animateStyles.current) {
466
- if (!seenAnimateKeys.has(key1)) {
467
- delete animateStyles.current[key1];
468
- animatedShapeChanged = true;
469
- }
470
- }
471
- if (animatedTranforms.current.length > transformCount) {
472
- animatedTranforms.current = animatedTranforms.current.slice(0, transformCount);
473
- animatedShapeChanged = true;
474
- }
475
- runners.forEach(function (r) {
476
- return r();
477
- });
478
- if (animatedShapeChanged && stateRef.current.nextState) {
479
- var _stateRef_current_baseSetStateShallow, _stateRef_current;
480
- (_stateRef_current_baseSetStateShallow = (_stateRef_current = stateRef.current).baseSetStateShallow) === null || _stateRef_current_baseSetStateShallow === void 0 ? void 0 : _stateRef_current_baseSetStateShallow.call(_stateRef_current, stateRef.current.nextState);
481
- }
482
- function update(key2, animated, valIn) {
483
- var isColor = colorStyleKey[key2];
484
- var [numVal, type] = isColor ? [0, void 0] : getValue(valIn);
485
- var animateToValue = numVal;
486
- var value = animated || new Animated.Value(numVal);
487
- var curInterpolation = animationsState.current.get(value);
488
- if (type) {
489
- var _curInterpolation_current;
490
- animationsState.current.set(value, {
491
- interpolation: value.interpolate(getInterpolated((_curInterpolation_current = curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current) !== null && _curInterpolation_current !== void 0 ? _curInterpolation_current : value["_value"], numVal, type)),
492
- current: numVal
493
- });
494
- }
495
- if (isColor) {
496
- animateToValue = (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1;
497
- animationsState.current.set(value, {
498
- current: valIn,
499
- interpolation: value.interpolate(getColorInterpolated(curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current, valIn, animateToValue)),
500
- animateToValue: (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1
501
- });
502
- }
503
- var animationConfig = getAnimationConfig(key2, animations, props.transition, "default");
504
- runners.push(function () {
505
- value.stopAnimation();
506
- var anim = Animated[animationConfig.type || "spring"](value, {
507
- toValue: animateToValue,
508
- ...animationConfig,
509
- useNativeDriver: useNativeDriverForNode
510
- });
511
- (animationConfig.delay ? Animated.sequence([Animated.delay(animationConfig.delay), anim]) : anim).start();
512
- });
513
- return value;
514
- }
515
- });
516
- if (process.env.NODE_ENV === "development") {
517
- if (props["debug"] === "verbose") {
518
- console.info(`Animated`, {
519
- response: res,
520
- inputStyle: style,
521
- isExiting
522
- });
523
- }
524
- }
525
- return res;
526
- }
527
- };
162
+ var _options_useNativeDriver;
163
+ var nativeDriver = (_options_useNativeDriver = options === null || options === void 0 ? void 0 : options.useNativeDriver) !== null && _options_useNativeDriver !== void 0 ? _options_useNativeDriver : isFabric;
164
+ return {
165
+ inputStyle: "value",
166
+ outputStyle: "inline",
167
+ avoidReRenders: true,
168
+ animations,
169
+ needsCustomComponent: true,
170
+ View: AnimatedView,
171
+ Text: AnimatedText,
172
+ useAnimatedNumber,
173
+ useAnimatedNumberReaction,
174
+ useAnimatedNumberStyle,
175
+ useAnimatedNumbersStyle,
176
+ usePresence,
177
+ ResetPresence,
178
+ useAnimations: function(param) {
179
+ var { props, onTransition, style, componentState, presence, stateRef, styleState, useStyleEmitter } = param;
180
+ var _themeState_name;
181
+ var isDisabled = isWeb && componentState.unmounted === true;
182
+ var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
183
+ var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
184
+ var onTransitionRef = React.useRef(onTransition);
185
+ onTransitionRef.current = onTransition;
186
+ var emit = function(phase, cause, finished) {
187
+ var _onTransitionRef_current;
188
+ (_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === "end" ? {
189
+ phase,
190
+ cause,
191
+ finished
192
+ } : {
193
+ phase,
194
+ cause
195
+ });
196
+ };
197
+ var _styleState_effectiveTransition;
198
+ var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
199
+ var [, themeState] = useThemeWithState({});
200
+ var isDark = (themeState === null || themeState === void 0 ? void 0 : themeState.scheme) === "dark" || (themeState === null || themeState === void 0 ? void 0 : (_themeState_name = themeState.name) === null || _themeState_name === void 0 ? void 0 : _themeState_name.startsWith("dark"));
201
+ var animateStyles = React.useRef({});
202
+ var animatedTranforms = React.useRef([]);
203
+ var animationsState = React.useRef(/* @__PURE__ */ new WeakMap());
204
+ var pseudoActiveRef = React.useRef(false);
205
+ var exitCycleIdRef = React.useRef(0);
206
+ var exitCompletedRef = React.useRef(false);
207
+ var wasExitingRef = React.useRef(false);
208
+ var enterStartedRef = React.useRef(false);
209
+ var exitStartedRef = React.useRef(false);
210
+ var updateInFlightRef = React.useRef(false);
211
+ var updateCycleIdRef = React.useRef(0);
212
+ var prevStyleSigRef = React.useRef(null);
213
+ var justStartedExiting = isExiting && !wasExitingRef.current;
214
+ var justStoppedExiting = !isExiting && wasExitingRef.current;
215
+ if (justStartedExiting) {
216
+ exitCycleIdRef.current++;
217
+ exitCompletedRef.current = false;
218
+ }
219
+ if (justStoppedExiting) {
220
+ exitCycleIdRef.current++;
221
+ }
222
+ var isEntering = !!componentState.unmounted;
223
+ var wasEnteringRef = React.useRef(isEntering);
224
+ var justFinishedEntering = wasEnteringRef.current && !isEntering;
225
+ React.useEffect(function() {
226
+ wasEnteringRef.current = isEntering;
227
+ });
228
+ var args = [
229
+ JSON.stringify(style),
230
+ JSON.stringify(effectiveTransition),
231
+ componentState,
232
+ isExiting,
233
+ !!onTransition,
234
+ isDark,
235
+ justFinishedEntering
236
+ ];
237
+ var res = React.useMemo(function() {
238
+ var runners = [];
239
+ var completions = [];
240
+ var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
241
+ var resolved = forAnimationState(resolveTransition(effectiveTransition, { animations }), animationState);
242
+ var nonAnimatedStyle = {};
243
+ var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(style, isDark, resolved);
244
+ var seenAnimateKeys = /* @__PURE__ */ new Set();
245
+ var sawTransform = false;
246
+ var transformCount = 0;
247
+ for (var key in style) {
248
+ var rawVal = style[key];
249
+ var val = resolveDynamicValue(rawVal, isDark);
250
+ if (val === void 0) continue;
251
+ if (isDisabled) {
252
+ continue;
253
+ }
254
+ if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key] && !layoutStyleKey[key]) {
255
+ nonAnimatedStyle[key] = val;
256
+ continue;
257
+ }
258
+ if (key !== "transform" && !getTransitionForKey(resolved, key)) {
259
+ nonAnimatedStyle[key] = val;
260
+ continue;
261
+ }
262
+ if (layoutStyleKey[key] && typeof val !== "number") {
263
+ nonAnimatedStyle[key] = val;
264
+ continue;
265
+ }
266
+ if (colorStyleKey[key] && !isAnimatableColor(val)) {
267
+ nonAnimatedStyle[key] = val;
268
+ continue;
269
+ }
270
+ if (key !== "transform") {
271
+ animateStyles.current[key] = update(key, animateStyles.current[key], val);
272
+ seenAnimateKeys.add(key);
273
+ continue;
274
+ }
275
+ if (!val) continue;
276
+ if (typeof val === "string") {
277
+ console.warn(`Warning: Tamagui can't animate string transforms yet!`);
278
+ continue;
279
+ }
280
+ sawTransform = true;
281
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
282
+ try {
283
+ for (var _iterator = val[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
284
+ var transform = _step.value;
285
+ var _animatedTranforms_current_index;
286
+ if (!transform) continue;
287
+ var index = transformCount++;
288
+ var tkey = Object.keys(transform)[0];
289
+ var currentTransform = (_animatedTranforms_current_index = animatedTranforms.current[index]) === null || _animatedTranforms_current_index === void 0 ? void 0 : _animatedTranforms_current_index[tkey];
290
+ animatedTranforms.current[index] = { [tkey]: update(tkey, currentTransform, transform[tkey]) };
291
+ animatedTranforms.current = [...animatedTranforms.current];
292
+ }
293
+ } catch (err) {
294
+ _didIteratorError = true;
295
+ _iteratorError = err;
296
+ } finally {
297
+ try {
298
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
299
+ _iterator.return();
300
+ }
301
+ } finally {
302
+ if (_didIteratorError) {
303
+ throw _iteratorError;
304
+ }
305
+ }
306
+ }
307
+ }
308
+ if (!isExiting && !isDisabled && !pseudoActiveRef.current) {
309
+ for (var k in animateStyles.current) {
310
+ if (!seenAnimateKeys.has(k)) delete animateStyles.current[k];
311
+ }
312
+ if (!sawTransform) {
313
+ if (animatedTranforms.current.length) animatedTranforms.current = [];
314
+ } else if (animatedTranforms.current.length > transformCount) {
315
+ animatedTranforms.current = animatedTranforms.current.slice(0, transformCount);
316
+ }
317
+ }
318
+ var animatedTransformStyle = animatedTranforms.current.length > 0 ? { transform: animatedTranforms.current.map(function(r) {
319
+ var _animationsState_current_get;
320
+ var key2 = Object.keys(r)[0];
321
+ var val2 = ((_animationsState_current_get = animationsState.current.get(r[key2])) === null || _animationsState_current_get === void 0 ? void 0 : _animationsState_current_get.interpolation) || r[key2];
322
+ return { [key2]: val2 };
323
+ }) } : {};
324
+ var animatedStyle = {
325
+ ...Object.fromEntries(Object.entries(animateStyles.current).map(function(param2) {
326
+ var [k2, v] = param2;
327
+ var _animationsState_current_get;
328
+ return [k2, ((_animationsState_current_get = animationsState.current.get(v)) === null || _animationsState_current_get === void 0 ? void 0 : _animationsState_current_get.interpolation) || v];
329
+ })),
330
+ ...animatedTransformStyle
331
+ };
332
+ return {
333
+ runners,
334
+ completions,
335
+ style: [nonAnimatedStyle, animatedStyle]
336
+ };
337
+ function update(key2, animated, valIn) {
338
+ var isColorStyleKey = colorStyleKey[key2];
339
+ var [val2, type] = isColorStyleKey ? [0, void 0] : getValue(valIn);
340
+ var animateToValue = val2;
341
+ var value = animated || new Animated.Value(val2);
342
+ var curInterpolation = animationsState.current.get(value);
343
+ var interpolateArgs;
344
+ if (type) {
345
+ var _curInterpolation_current;
346
+ interpolateArgs = getInterpolated((_curInterpolation_current = curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current) !== null && _curInterpolation_current !== void 0 ? _curInterpolation_current : value["_value"], val2, type);
347
+ animationsState.current.set(value, {
348
+ interpolation: value.interpolate(interpolateArgs),
349
+ current: val2
350
+ });
351
+ }
352
+ if (isColorStyleKey) {
353
+ animateToValue = (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1;
354
+ interpolateArgs = getColorInterpolated(curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current, valIn, animateToValue);
355
+ animationsState.current.set(value, {
356
+ current: valIn,
357
+ interpolation: value.interpolate(interpolateArgs),
358
+ animateToValue: (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1
359
+ });
360
+ }
361
+ if (value) {
362
+ var animationConfig = getAnimationConfig(key2, animations, effectiveTransition, animationState);
363
+ var resolve;
364
+ var promise = new Promise(function(res2) {
365
+ resolve = res2;
366
+ });
367
+ completions.push(promise);
368
+ runners.push(function() {
369
+ value.stopAnimation();
370
+ var { type: type2, delay, ...config } = animationConfig;
371
+ var animation = Animated[type2 || "spring"](value, {
372
+ toValue: animateToValue,
373
+ ...config,
374
+ useNativeDriver: useNativeDriverForNode
375
+ });
376
+ var animation2 = delay ? Animated.sequence([Animated.delay(delay), animation]) : animation;
377
+ animation2.start(function(param2) {
378
+ var { finished } = param2;
379
+ if (finished || isExiting) {
380
+ resolve();
381
+ }
382
+ });
383
+ });
384
+ }
385
+ if (process.env.NODE_ENV === "development") {
386
+ if (props["debug"] === "verbose") {
387
+ console.info(" 💠 animate", key2, `from (${value["_value"]}) to`, valIn, `(${val2})`, "type", type, "interpolate", interpolateArgs);
388
+ }
389
+ }
390
+ return value;
391
+ }
392
+ }, args);
393
+ React.useEffect(function() {
394
+ wasExitingRef.current = isExiting;
395
+ });
396
+ useIsomorphicLayoutEffect(function() {
397
+ if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {
398
+ exitStartedRef.current = false;
399
+ emit("end", "exit", false);
400
+ }
401
+ }, [justStoppedExiting]);
402
+ useIsomorphicLayoutEffect(function() {
403
+ res.runners.forEach(function(r) {
404
+ return r();
405
+ });
406
+ var cycleId = exitCycleIdRef.current;
407
+ var cause = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "update";
408
+ if (cause === "exit") {
409
+ if (enterStartedRef.current) {
410
+ enterStartedRef.current = false;
411
+ emit("end", "enter", false);
412
+ }
413
+ if (updateInFlightRef.current) {
414
+ updateInFlightRef.current = false;
415
+ updateCycleIdRef.current++;
416
+ emit("end", "update", false);
417
+ }
418
+ }
419
+ if (cause === "update") {
420
+ var sig = args[0];
421
+ if (prevStyleSigRef.current === null || prevStyleSigRef.current === sig) {
422
+ prevStyleSigRef.current = sig;
423
+ return;
424
+ }
425
+ prevStyleSigRef.current = sig;
426
+ if (res.completions.length === 0) return;
427
+ if (updateInFlightRef.current) {
428
+ emit("end", "update", false);
429
+ }
430
+ updateInFlightRef.current = true;
431
+ var uid = ++updateCycleIdRef.current;
432
+ emit("start", "update");
433
+ Promise.all(res.completions).then(function() {
434
+ if (uid !== updateCycleIdRef.current) return;
435
+ updateInFlightRef.current = false;
436
+ emit("end", "update", true);
437
+ });
438
+ return;
439
+ }
440
+ prevStyleSigRef.current = args[0];
441
+ if (res.completions.length === 0) {
442
+ emit("start", cause);
443
+ emit("end", cause, true);
444
+ if (isExiting && !exitCompletedRef.current) {
445
+ exitCompletedRef.current = true;
446
+ sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
447
+ }
448
+ return;
449
+ }
450
+ if (cause === "enter" && !enterStartedRef.current) {
451
+ enterStartedRef.current = true;
452
+ emit("start", "enter");
453
+ }
454
+ if (cause === "exit" && !exitStartedRef.current) {
455
+ exitStartedRef.current = true;
456
+ emit("start", "exit");
457
+ }
458
+ Promise.all(res.completions).then(function() {
459
+ if (isExiting && cycleId !== exitCycleIdRef.current) return;
460
+ if (isExiting && exitCompletedRef.current) return;
461
+ if (isExiting) {
462
+ if (exitStartedRef.current) {
463
+ exitStartedRef.current = false;
464
+ emit("end", "exit", true);
465
+ }
466
+ exitCompletedRef.current = true;
467
+ sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
468
+ } else if (enterStartedRef.current) {
469
+ enterStartedRef.current = false;
470
+ emit("end", "enter", true);
471
+ }
472
+ });
473
+ }, args);
474
+ useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function(nextStyle, emittedTransition, pseudoActive) {
475
+ pseudoActiveRef.current = pseudoActive === true;
476
+ var runners = [];
477
+ var seenAnimateKeys = /* @__PURE__ */ new Set();
478
+ var transformCount = 0;
479
+ var animatedShapeChanged = false;
480
+ var emittedResolved = forAnimationState(resolveTransition(emittedTransition !== null && emittedTransition !== void 0 ? emittedTransition : effectiveTransition, { animations }), "default");
481
+ var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(nextStyle, isDark, emittedResolved) && !Object.keys(animateStyles.current).some(function(key2) {
482
+ return layoutStyleKey[key2];
483
+ });
484
+ for (var key in nextStyle) {
485
+ var rawVal = nextStyle[key];
486
+ var val = resolveDynamicValue(rawVal, isDark);
487
+ if (val === void 0) continue;
488
+ if (key === "transform" && Array.isArray(val)) {
489
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
490
+ try {
491
+ for (var _iterator = val[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
492
+ var transform = _step.value;
493
+ var _animatedTranforms_current_index;
494
+ if (!transform) continue;
495
+ var index = transformCount++;
496
+ var tkey = Object.keys(transform)[0];
497
+ var currentTransform = (_animatedTranforms_current_index = animatedTranforms.current[index]) === null || _animatedTranforms_current_index === void 0 ? void 0 : _animatedTranforms_current_index[tkey];
498
+ if (!currentTransform) animatedShapeChanged = true;
499
+ animatedTranforms.current[index] = { [tkey]: update(tkey, currentTransform, transform[tkey]) };
500
+ }
501
+ } catch (err) {
502
+ _didIteratorError = true;
503
+ _iteratorError = err;
504
+ } finally {
505
+ try {
506
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
507
+ _iterator.return();
508
+ }
509
+ } finally {
510
+ if (_didIteratorError) {
511
+ throw _iteratorError;
512
+ }
513
+ }
514
+ }
515
+ } else if (animatedStyleKey[key] != null || costlyToAnimateStyleKey[key] || layoutStyleKey[key]) {
516
+ if (layoutStyleKey[key] && typeof val !== "number") continue;
517
+ if (colorStyleKey[key] && !isAnimatableColor(val)) continue;
518
+ if (!animateStyles.current[key]) animatedShapeChanged = true;
519
+ animateStyles.current[key] = update(key, animateStyles.current[key], val);
520
+ seenAnimateKeys.add(key);
521
+ }
522
+ }
523
+ for (var key1 in animateStyles.current) {
524
+ if (!seenAnimateKeys.has(key1)) {
525
+ delete animateStyles.current[key1];
526
+ animatedShapeChanged = true;
527
+ }
528
+ }
529
+ if (animatedTranforms.current.length > transformCount) {
530
+ animatedTranforms.current = animatedTranforms.current.slice(0, transformCount);
531
+ animatedShapeChanged = true;
532
+ }
533
+ runners.forEach(function(r) {
534
+ return r();
535
+ });
536
+ if (animatedShapeChanged && stateRef.current.nextState) {
537
+ var _stateRef_current_baseSetStateShallow, _stateRef_current;
538
+ (_stateRef_current_baseSetStateShallow = (_stateRef_current = stateRef.current).baseSetStateShallow) === null || _stateRef_current_baseSetStateShallow === void 0 ? void 0 : _stateRef_current_baseSetStateShallow.call(_stateRef_current, stateRef.current.nextState);
539
+ }
540
+ function update(key2, animated, valIn) {
541
+ var isColor = colorStyleKey[key2];
542
+ var [numVal, type] = isColor ? [0, void 0] : getValue(valIn);
543
+ var animateToValue = numVal;
544
+ var value = animated || new Animated.Value(numVal);
545
+ var curInterpolation = animationsState.current.get(value);
546
+ if (type) {
547
+ var _curInterpolation_current;
548
+ animationsState.current.set(value, {
549
+ interpolation: value.interpolate(getInterpolated((_curInterpolation_current = curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current) !== null && _curInterpolation_current !== void 0 ? _curInterpolation_current : value["_value"], numVal, type)),
550
+ current: numVal
551
+ });
552
+ }
553
+ if (isColor) {
554
+ animateToValue = (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1;
555
+ animationsState.current.set(value, {
556
+ current: valIn,
557
+ interpolation: value.interpolate(getColorInterpolated(curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current, valIn, animateToValue)),
558
+ animateToValue: (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1
559
+ });
560
+ }
561
+ var animationConfig = getAnimationConfig(key2, animations, emittedTransition !== null && emittedTransition !== void 0 ? emittedTransition : effectiveTransition, "default");
562
+ runners.push(function() {
563
+ value.stopAnimation();
564
+ var { type: type2, delay, ...config } = animationConfig;
565
+ var anim = Animated[type2 || "spring"](value, {
566
+ toValue: animateToValue,
567
+ ...config,
568
+ useNativeDriver: useNativeDriverForNode
569
+ });
570
+ (delay ? Animated.sequence([Animated.delay(delay), anim]) : anim).start();
571
+ });
572
+ return value;
573
+ }
574
+ });
575
+ if (process.env.NODE_ENV === "development") {
576
+ if (props["debug"] === "verbose") {
577
+ console.info(`Animated`, {
578
+ response: res,
579
+ inputStyle: style,
580
+ isExiting
581
+ });
582
+ }
583
+ }
584
+ return res;
585
+ }
586
+ };
528
587
  }
529
588
  function getColorInterpolated(currentColor, nextColor, animateToValue) {
530
- var inputRange = [0, 1];
531
- var outputRange = [currentColor ? currentColor : nextColor, nextColor];
532
- if (animateToValue === 0) {
533
- outputRange.reverse();
534
- }
535
- return {
536
- inputRange,
537
- outputRange
538
- };
589
+ var inputRange = [0, 1];
590
+ var outputRange = [currentColor ? currentColor : nextColor, nextColor];
591
+ if (animateToValue === 0) {
592
+ outputRange.reverse();
593
+ }
594
+ return {
595
+ inputRange,
596
+ outputRange
597
+ };
539
598
  }
540
599
  function getInterpolated(current, next) {
541
- var postfix = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "deg";
542
- if (next === current) {
543
- current = next - 1e-9;
544
- }
545
- var inputRange = [current, next];
546
- var outputRange = [`${current}${postfix}`, `${next}${postfix}`];
547
- if (next < current) {
548
- inputRange.reverse();
549
- outputRange.reverse();
550
- }
551
- return {
552
- inputRange,
553
- outputRange
554
- };
600
+ var postfix = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "deg";
601
+ if (next === current) {
602
+ current = next - 1e-9;
603
+ }
604
+ var inputRange = [current, next];
605
+ var outputRange = [`${current}${postfix}`, `${next}${postfix}`];
606
+ if (next < current) {
607
+ inputRange.reverse();
608
+ outputRange.reverse();
609
+ }
610
+ return {
611
+ inputRange,
612
+ outputRange
613
+ };
555
614
  }
556
- function getAnimationConfig(key, animations, transition) {
557
- var animationState = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "default";
558
- var normalized = normalizeTransition(transition);
559
- var shortKey = transformShorthands[key];
560
- var _normalized_properties_key;
561
- var propAnimation = (_normalized_properties_key = normalized.properties[key]) !== null && _normalized_properties_key !== void 0 ? _normalized_properties_key : normalized.properties[shortKey];
562
- var animationType = null;
563
- var extraConf = {};
564
- if (typeof propAnimation === "string") {
565
- animationType = propAnimation;
566
- } else if (propAnimation && (typeof propAnimation === "undefined" ? "undefined" : _type_of(propAnimation)) === "object") {
567
- animationType = propAnimation.type || getEffectiveAnimation(normalized, animationState);
568
- extraConf = propAnimation;
569
- } else {
570
- animationType = getEffectiveAnimation(normalized, animationState);
571
- }
572
- if (normalized.delay && !extraConf.delay) {
573
- extraConf = {
574
- ...extraConf,
575
- delay: normalized.delay
576
- };
577
- }
578
- var found = animationType ? animations[animationType] : {};
579
- return {
580
- ...found,
581
- // Apply global spring config overrides (from transition={['bouncy', { stiffness: 1000 }]})
582
- ...normalized.config,
583
- // Property-specific config takes highest precedence
584
- ...extraConf
585
- };
615
+ function entryToRN(entry) {
616
+ var extra = entry.timing.kind === "spring" ? entry.timing.extra : void 0;
617
+ if (entry.timing.kind === "spring") {
618
+ return {
619
+ type: "spring",
620
+ stiffness: entry.timing.stiffness,
621
+ damping: entry.timing.damping,
622
+ mass: entry.timing.mass,
623
+ ...typeof (extra === null || extra === void 0 ? void 0 : extra.velocity) === "number" ? { velocity: extra.velocity } : null,
624
+ ...typeof (extra === null || extra === void 0 ? void 0 : extra.overshootClamping) === "boolean" ? { overshootClamping: extra.overshootClamping } : null,
625
+ ...entry.delayMs ? { delay: entry.delayMs } : null
626
+ };
627
+ }
628
+ var bezier = easingToBezier(entry.timing.easing);
629
+ return {
630
+ type: "timing",
631
+ duration: entry.timing.durationMs,
632
+ ...bezier ? { easing: Easing.bezier(bezier[0], bezier[1], bezier[2], bezier[3]) } : null,
633
+ ...entry.delayMs ? { delay: entry.delayMs } : null
634
+ };
586
635
  }
587
- var transformShorthands = {
588
- x: "translateX",
589
- y: "translateY",
590
- translateX: "x",
591
- translateY: "y"
636
+ var snapConfig = {
637
+ type: "timing",
638
+ duration: 0
592
639
  };
640
+ function getAnimationConfig(key, animations, transition) {
641
+ var animationState = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "default";
642
+ var resolved = forAnimationState(resolveTransition(transition, { animations }), animationState);
643
+ var entry = getTransitionForKey(resolved, key);
644
+ return entry ? entryToRN(entry) : snapConfig;
645
+ }
593
646
  function getValue(input) {
594
- var isColor = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
595
- if (typeof input !== "string") {
596
- return [input];
597
- }
598
- var _input_match;
599
- var [_, number, after] = (_input_match = input.match(/([-0-9]+)(deg|%|px)/)) !== null && _input_match !== void 0 ? _input_match : [];
600
- return [+number, after];
647
+ var isColor = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
648
+ if (typeof input !== "string") {
649
+ return [input];
650
+ }
651
+ var _input_match;
652
+ var [_, number, after] = (_input_match = input.match(/(-?(?:\d+\.?\d*|\.\d+))(deg|%|px)?/)) !== null && _input_match !== void 0 ? _input_match : [];
653
+ return [+number, after];
601
654
  }
655
+
602
656
  export { AnimatedText, AnimatedView, createAnimations, useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle, useAnimatedNumbersStyle };
603
657
  //# sourceMappingURL=createAnimations.native.js.map