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