@tamagui/animations-reanimated 2.0.0-rc.8 → 2.0.0

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.
@@ -4,190 +4,349 @@ var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf,
8
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
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: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
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, {
17
18
  get: () => from[key],
18
19
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
20
  });
20
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
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
32
+ }) : target, mod));
33
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
+ value: true
35
+ }), mod);
34
36
  var createAnimations_exports = {};
35
37
  __export(createAnimations_exports, {
36
38
  createAnimations: () => createAnimations
37
39
  });
38
40
  module.exports = __toCommonJS(createAnimations_exports);
39
- var import_jsx_runtime = require("react/jsx-runtime"),
40
- import_animation_helpers = require("@tamagui/animation-helpers"),
41
- import_core = require("@tamagui/core"),
42
- import_use_presence = require("@tamagui/use-presence"),
43
- import_react = __toESM(require("react"), 1),
44
- import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_animation_helpers = require("@tamagui/animation-helpers");
43
+ var import_core = require("@tamagui/core");
44
+ var import_use_presence = require("@tamagui/use-presence");
45
+ var import_react = __toESM(require("react"), 1);
46
+ var import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1);
45
47
  function _type_of(obj) {
46
48
  "@swc/helpers - typeof";
47
49
 
48
- return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
50
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
49
51
  }
50
52
  var getDefaultExport = function (module2) {
51
- var mod = module2;
52
- return (mod.__esModule || mod[Symbol.toStringTag] === "Module") && mod.default || mod;
53
- },
54
- Animated = getDefaultExport(import_react_native_reanimated.default),
55
- resolveDynamicValue = function (value, isDark) {
56
- if (value !== null && (typeof value > "u" ? "undefined" : _type_of(value)) === "object" && "dynamic" in value && _type_of(value.dynamic) === "object") {
57
- var dynamic = value.dynamic;
58
- return isDark ? dynamic.dark : dynamic.light;
53
+ var mod = module2;
54
+ if (mod.__esModule || mod[Symbol.toStringTag] === "Module") {
55
+ return mod.default || mod;
56
+ }
57
+ return mod;
58
+ };
59
+ var Animated = getDefaultExport(import_react_native_reanimated.default);
60
+ var silenceAnimatedComponentDevCheck = function (style) {
61
+ if (process.env.NODE_ENV !== "development" || import_core.isWeb || !style || (typeof style === "undefined" ? "undefined" : _type_of(style)) !== "object") {
62
+ return;
63
+ }
64
+ Object.defineProperty(style, "_requiresAnimatedComponent", {
65
+ configurable: true,
66
+ enumerable: false,
67
+ value: true
68
+ });
69
+ };
70
+ var resolveDynamicValue = function (value, isDark) {
71
+ if (value !== null && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "dynamic" in value && _type_of(value.dynamic) === "object") {
72
+ var dynamic = value.dynamic;
73
+ return isDark ? dynamic.dark : dynamic.light;
74
+ }
75
+ return value;
76
+ };
77
+ var cloneAnimationValue = function (value) {
78
+ if (Array.isArray(value)) {
79
+ return value.map(cloneAnimationValue);
80
+ }
81
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
82
+ var next = {};
83
+ for (var key in value) {
84
+ next[key] = cloneAnimationValue(value[key]);
59
85
  }
60
- return value;
61
- },
62
- applyAnimation = function (targetValue, config) {
63
- "worklet";
86
+ return next;
87
+ }
88
+ return value;
89
+ };
90
+ var cloneTransitionConfig = function (config) {
91
+ return cloneAnimationValue(config);
92
+ };
93
+ var createReanimatedConfig = function (config) {
94
+ "worklet";
64
95
 
65
- var delay = config.delay,
66
- animatedValue;
67
- return config.type === "timing" ? animatedValue = (0, import_react_native_reanimated.withTiming)(targetValue, config) : animatedValue = (0, import_react_native_reanimated.withSpring)(targetValue, config), delay && delay > 0 && (animatedValue = (0, import_react_native_reanimated.withDelay)(delay, animatedValue)), animatedValue;
68
- },
69
- ANIMATABLE_PROPERTIES = {
70
- // Transform
71
- transform: !0,
72
- // Opacity
73
- opacity: !0,
74
- // Dimensions
75
- height: !0,
76
- width: !0,
77
- minWidth: !0,
78
- minHeight: !0,
79
- maxWidth: !0,
80
- maxHeight: !0,
81
- // Background
82
- backgroundColor: !0,
83
- // Border colors
84
- borderColor: !0,
85
- borderLeftColor: !0,
86
- borderRightColor: !0,
87
- borderTopColor: !0,
88
- borderBottomColor: !0,
89
- // Border radius
90
- borderRadius: !0,
91
- borderTopLeftRadius: !0,
92
- borderTopRightRadius: !0,
93
- borderBottomLeftRadius: !0,
94
- borderBottomRightRadius: !0,
95
- // Border width
96
- borderWidth: !0,
97
- borderLeftWidth: !0,
98
- borderRightWidth: !0,
99
- borderTopWidth: !0,
100
- borderBottomWidth: !0,
101
- // Text
102
- color: !0,
103
- fontSize: !0,
104
- fontWeight: !0,
105
- lineHeight: !0,
106
- letterSpacing: !0,
107
- // Position
108
- left: !0,
109
- right: !0,
110
- top: !0,
111
- bottom: !0,
112
- // Margin
113
- margin: !0,
114
- marginTop: !0,
115
- marginBottom: !0,
116
- marginLeft: !0,
117
- marginRight: !0,
118
- marginHorizontal: !0,
119
- marginVertical: !0,
120
- // Padding
121
- padding: !0,
122
- paddingTop: !0,
123
- paddingBottom: !0,
124
- paddingLeft: !0,
125
- paddingRight: !0,
126
- paddingHorizontal: !0,
127
- paddingVertical: !0,
128
- // Flex/Gap
129
- gap: !0,
130
- rowGap: !0,
131
- columnGap: !0,
132
- flex: !0,
133
- flexGrow: !0,
134
- flexShrink: !0
135
- },
136
- canAnimateProperty = function (key, value, animateOnly) {
137
- return !(!ANIMATABLE_PROPERTIES[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key));
138
- };
96
+ var next = {};
97
+ var source = config;
98
+ for (var key in source) {
99
+ if (key === "type" || key === "delay") continue;
100
+ var value = source[key];
101
+ if (value !== void 0) {
102
+ next[key] = value;
103
+ }
104
+ }
105
+ return next;
106
+ };
107
+ var applyAnimation = function (targetValue, config, callback) {
108
+ "worklet";
109
+
110
+ var delay = config.delay;
111
+ var reanimatedConfig = createReanimatedConfig(config);
112
+ var animatedValue;
113
+ if (config.type === "timing") {
114
+ animatedValue = (0, import_react_native_reanimated.withTiming)(targetValue, reanimatedConfig, callback);
115
+ } else {
116
+ animatedValue = (0, import_react_native_reanimated.withSpring)(targetValue, reanimatedConfig, callback);
117
+ }
118
+ if (delay && delay > 0) {
119
+ animatedValue = (0, import_react_native_reanimated.withDelay)(delay, animatedValue);
120
+ }
121
+ return animatedValue;
122
+ };
123
+ var ANIMATABLE_PROPERTIES = {
124
+ // Transform
125
+ transform: true,
126
+ // Opacity
127
+ opacity: true,
128
+ // Dimensions
129
+ height: true,
130
+ width: true,
131
+ minWidth: true,
132
+ minHeight: true,
133
+ maxWidth: true,
134
+ maxHeight: true,
135
+ // Background
136
+ backgroundColor: true,
137
+ // Border colors
138
+ borderColor: true,
139
+ borderLeftColor: true,
140
+ borderRightColor: true,
141
+ borderTopColor: true,
142
+ borderBottomColor: true,
143
+ // Border radius
144
+ borderRadius: true,
145
+ borderTopLeftRadius: true,
146
+ borderTopRightRadius: true,
147
+ borderBottomLeftRadius: true,
148
+ borderBottomRightRadius: true,
149
+ // Border width
150
+ borderWidth: true,
151
+ borderLeftWidth: true,
152
+ borderRightWidth: true,
153
+ borderTopWidth: true,
154
+ borderBottomWidth: true,
155
+ // Text
156
+ color: true,
157
+ fontSize: true,
158
+ fontWeight: true,
159
+ lineHeight: true,
160
+ letterSpacing: true,
161
+ // Position
162
+ left: true,
163
+ right: true,
164
+ top: true,
165
+ bottom: true,
166
+ // Margin
167
+ margin: true,
168
+ marginTop: true,
169
+ marginBottom: true,
170
+ marginLeft: true,
171
+ marginRight: true,
172
+ marginHorizontal: true,
173
+ marginVertical: true,
174
+ // Padding
175
+ padding: true,
176
+ paddingTop: true,
177
+ paddingBottom: true,
178
+ paddingLeft: true,
179
+ paddingRight: true,
180
+ paddingHorizontal: true,
181
+ paddingVertical: true,
182
+ // Flex/Gap
183
+ gap: true,
184
+ rowGap: true,
185
+ columnGap: true,
186
+ flex: true,
187
+ flexGrow: true,
188
+ flexShrink: true
189
+ };
190
+ var canAnimateProperty = function (key, value, animateOnly) {
191
+ if (!ANIMATABLE_PROPERTIES[key]) return false;
192
+ if (value === "auto") return false;
193
+ if (typeof value === "string" && value.startsWith("calc")) return false;
194
+ if (animateOnly && !animateOnly.includes(key)) return false;
195
+ return true;
196
+ };
139
197
  function createWebAnimatedComponent(defaultTag) {
140
- var isText = defaultTag === "span",
141
- Component = Animated.createAnimatedComponent(/* @__PURE__ */(0, import_react.forwardRef)(function (propsIn, ref) {
142
- var _hooks_usePropsTransform,
143
- {
144
- forwardedRef,
145
- render = defaultTag,
146
- ...rest
147
- } = propsIn,
148
- hostRef = (0, import_react.useRef)(null),
149
- composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref, hostRef),
150
- stateRef = (0, import_react.useRef)({
151
- get host() {
152
- return hostRef.current;
153
- }
154
- }),
155
- [, themeState] = (0, import_core.useThemeWithState)({}),
156
- _themeState_theme,
157
- _themeState_name,
158
- result = (0, import_core.getSplitStyles)(rest, isText ? import_core.Text.staticConfig : import_core.View.staticConfig, (_themeState_theme = themeState?.theme) !== null && _themeState_theme !== void 0 ? _themeState_theme : {}, (_themeState_name = themeState?.name) !== null && _themeState_name !== void 0 ? _themeState_name : "", {
159
- unmounted: !1
160
- }, {
161
- isAnimated: !1,
162
- noClass: !0
163
- }),
164
- _result_viewProps,
165
- viewProps = (_result_viewProps = result?.viewProps) !== null && _result_viewProps !== void 0 ? _result_viewProps : {},
166
- Element = render,
167
- transformedProps = (_hooks_usePropsTransform = import_core.hooks.usePropsTransform) === null || _hooks_usePropsTransform === void 0 ? void 0 : _hooks_usePropsTransform.call(import_core.hooks, render, viewProps, stateRef, !1);
168
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Element, {
169
- ...transformedProps,
170
- ref: composedRefs
198
+ var isText = defaultTag === "span";
199
+ var Component = Animated.createAnimatedComponent(/* @__PURE__ */(0, import_react.forwardRef)(function (propsIn, ref) {
200
+ var _hooks_usePropsTransform;
201
+ var {
202
+ forwardedRef,
203
+ render = defaultTag,
204
+ ...rest
205
+ } = propsIn;
206
+ var hostRef = (0, import_react.useRef)(null);
207
+ var composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref, hostRef);
208
+ var stateRef = (0, import_react.useRef)({
209
+ get host() {
210
+ return hostRef.current;
211
+ }
212
+ });
213
+ var [, themeState] = (0, import_core.useThemeWithState)({});
214
+ var _themeState_theme, _themeState_name;
215
+ var result = (0, import_core.getSplitStyles)(rest, isText ? import_core.Text.staticConfig : import_core.View.staticConfig, (_themeState_theme = themeState === null || themeState === void 0 ? void 0 : themeState.theme) !== null && _themeState_theme !== void 0 ? _themeState_theme : {}, (_themeState_name = themeState === null || themeState === void 0 ? void 0 : themeState.name) !== null && _themeState_name !== void 0 ? _themeState_name : "", {
216
+ unmounted: false
217
+ }, {
218
+ isAnimated: false,
219
+ noClass: true
220
+ });
221
+ var _result_viewProps;
222
+ var viewProps = (_result_viewProps = result === null || result === void 0 ? void 0 : result.viewProps) !== null && _result_viewProps !== void 0 ? _result_viewProps : {};
223
+ var Element = render;
224
+ var transformedProps = (_hooks_usePropsTransform = import_core.hooks.usePropsTransform) === null || _hooks_usePropsTransform === void 0 ? void 0 : _hooks_usePropsTransform.call(import_core.hooks, render, viewProps, stateRef, false);
225
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Element, {
226
+ ...transformedProps,
227
+ ref: composedRefs
228
+ });
229
+ }));
230
+ Component.acceptRenderProp = true;
231
+ return Component;
232
+ }
233
+ var AnimatedView = createWebAnimatedComponent("div");
234
+ var AnimatedText = createWebAnimatedComponent("span");
235
+ function buildTransitionConfig(transition, animations, animationState, styleKeys) {
236
+ var normalized = (0, import_animation_helpers.normalizeTransition)(transition);
237
+ var effectiveKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
238
+ var _animations_effectiveKey;
239
+ var base = cloneTransitionConfig(effectiveKey ? (_animations_effectiveKey = animations[effectiveKey]) !== null && _animations_effectiveKey !== void 0 ? _animations_effectiveKey : {
240
+ type: "spring"
241
+ } : {
242
+ type: "spring"
243
+ });
244
+ if (normalized.delay) {
245
+ base = cloneTransitionConfig({
246
+ ...base,
247
+ delay: normalized.delay
248
+ });
249
+ }
250
+ if (normalized.config) {
251
+ base = cloneTransitionConfig({
252
+ ...base,
253
+ ...normalized.config
254
+ });
255
+ if (base.type !== "timing" && normalized.config.duration !== void 0 && normalized.config.damping === void 0 && normalized.config.stiffness === void 0 && normalized.config.mass === void 0) {
256
+ base = cloneTransitionConfig({
257
+ ...base,
258
+ type: "timing"
171
259
  });
172
- }));
173
- return Component.acceptTagProp = !0, Component;
260
+ }
261
+ }
262
+ var propertyConfigs = {};
263
+ var _iteratorNormalCompletion = true,
264
+ _didIteratorError = false,
265
+ _iteratorError = void 0;
266
+ try {
267
+ for (var _iterator = styleKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
268
+ var key = _step.value;
269
+ var propAnimation = normalized.properties[key];
270
+ if (typeof propAnimation === "string") {
271
+ var _animations_propAnimation;
272
+ propertyConfigs[key] = cloneTransitionConfig((_animations_propAnimation = animations[propAnimation]) !== null && _animations_propAnimation !== void 0 ? _animations_propAnimation : base);
273
+ } else if (propAnimation && (typeof propAnimation === "undefined" ? "undefined" : _type_of(propAnimation)) === "object") {
274
+ var configType = propAnimation.type;
275
+ var _animations_configType;
276
+ var baseForProp = configType ? (_animations_configType = animations[configType]) !== null && _animations_configType !== void 0 ? _animations_configType : base : base;
277
+ propertyConfigs[key] = cloneTransitionConfig({
278
+ ...baseForProp,
279
+ ...propAnimation
280
+ });
281
+ } else {
282
+ propertyConfigs[key] = cloneTransitionConfig(base);
283
+ }
284
+ }
285
+ } catch (err) {
286
+ _didIteratorError = true;
287
+ _iteratorError = err;
288
+ } finally {
289
+ try {
290
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
291
+ _iterator.return();
292
+ }
293
+ } finally {
294
+ if (_didIteratorError) {
295
+ throw _iteratorError;
296
+ }
297
+ }
298
+ }
299
+ return {
300
+ baseConfig: base,
301
+ propertyConfigs
302
+ };
303
+ }
304
+ function getStyleKeys(style) {
305
+ var keys = new Set(Object.keys(style));
306
+ if (style.transform && Array.isArray(style.transform)) {
307
+ var _iteratorNormalCompletion = true,
308
+ _didIteratorError = false,
309
+ _iteratorError = void 0;
310
+ try {
311
+ for (var _iterator = style.transform[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
312
+ var t = _step.value;
313
+ if (t && (typeof t === "undefined" ? "undefined" : _type_of(t)) === "object") {
314
+ keys.add(Object.keys(t)[0]);
315
+ }
316
+ }
317
+ } catch (err) {
318
+ _didIteratorError = true;
319
+ _iteratorError = err;
320
+ } finally {
321
+ try {
322
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
323
+ _iterator.return();
324
+ }
325
+ } finally {
326
+ if (_didIteratorError) {
327
+ throw _iteratorError;
328
+ }
329
+ }
330
+ }
331
+ }
332
+ return keys;
174
333
  }
175
- var AnimatedView = createWebAnimatedComponent("div"),
176
- AnimatedText = createWebAnimatedComponent("span");
177
334
  function createAnimations(animationsConfig) {
178
335
  var animations = {};
179
- for (var key in animationsConfig) animations[key] = {
180
- type: "spring",
181
- ...animationsConfig[key]
182
- };
336
+ for (var key in animationsConfig) {
337
+ animations[key] = cloneTransitionConfig({
338
+ type: "spring",
339
+ ...animationsConfig[key]
340
+ });
341
+ }
183
342
  return {
343
+ needsCustomComponent: true,
184
344
  View: import_core.isWeb ? AnimatedView : Animated.View,
185
345
  Text: import_core.isWeb ? AnimatedText : Animated.Text,
186
- isReactNative: !0,
187
- supportsCSS: !1,
346
+ isReactNative: true,
188
347
  inputStyle: "value",
189
348
  outputStyle: "inline",
190
- avoidReRenders: !0,
349
+ avoidReRenders: true,
191
350
  animations,
192
351
  usePresence: import_use_presence.usePresence,
193
352
  ResetPresence: import_use_presence.ResetPresence,
@@ -209,22 +368,32 @@ function createAnimations(animationsConfig) {
209
368
  return sharedValue.value;
210
369
  },
211
370
  setValue(next) {
212
- "worklet";
213
-
214
371
  var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
215
372
  type: "spring"
216
373
  },
217
- onFinish = arguments.length > 2 ? arguments[2] : void 0,
218
- handleFinish = onFinish ? function () {
374
+ onFinish = arguments.length > 2 ? arguments[2] : void 0;
375
+ if (config.type === "direct") {
376
+ sharedValue.value = next;
377
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish();
378
+ } else {
379
+ var cb = onFinish ? function () {
219
380
  "worklet";
220
381
 
221
382
  (0, import_react_native_reanimated.runOnJS)(onFinish)();
222
383
  } : void 0;
223
- config.type === "direct" ? (sharedValue.value = next, onFinish?.()) : config.type === "spring" ? sharedValue.value = (0, import_react_native_reanimated.withSpring)(next, config, handleFinish) : sharedValue.value = (0, import_react_native_reanimated.withTiming)(next, config, handleFinish);
384
+ var animationConfig = cloneTransitionConfig(config);
385
+ if (import_core.isWeb) {
386
+ sharedValue.value = applyAnimation(next, animationConfig, cb);
387
+ } else {
388
+ (0, import_react_native_reanimated.runOnUI)(function (targetValue, animationConfig2) {
389
+ "worklet";
390
+
391
+ sharedValue.value = applyAnimation(targetValue, animationConfig2, cb);
392
+ })(next, animationConfig);
393
+ }
394
+ }
224
395
  },
225
396
  stop() {
226
- "worklet";
227
-
228
397
  (0, import_react_native_reanimated.cancelAnimation)(sharedValue);
229
398
  }
230
399
  };
@@ -235,310 +404,416 @@ function createAnimations(animationsConfig) {
235
404
  // =========================================================================
236
405
  useAnimatedNumberReaction(param, onValue) {
237
406
  var {
238
- value
239
- } = param,
240
- instance = value.getInstance();
407
+ value
408
+ } = param;
409
+ var instance = value.getInstance();
241
410
  return (0, import_react_native_reanimated.useAnimatedReaction)(function () {
242
411
  return instance.value;
243
412
  }, function (next, prev) {
244
- prev !== next && (0, import_react_native_reanimated.runOnJS)(onValue)(next);
413
+ if (prev !== next) {
414
+ (0, import_react_native_reanimated.runOnJS)(onValue)(next);
415
+ }
245
416
  }, [onValue, instance]);
246
417
  },
247
418
  // =========================================================================
248
419
  // useAnimatedNumberStyle - Create animated styles from values
249
420
  // =========================================================================
250
421
  useAnimatedNumberStyle(val, getStyle) {
251
- var instance = val.getInstance(),
252
- derivedValue = (0, import_react_native_reanimated.useDerivedValue)(function () {
253
- return instance.value;
422
+ var instance = val.getInstance();
423
+ if (import_core.isWeb) {
424
+ return (0, import_react_native_reanimated.useAnimatedStyle)(function () {
425
+ "worklet";
426
+
427
+ return getStyle(instance.value);
254
428
  }, [instance, getStyle]);
255
- return (0, import_react_native_reanimated.useAnimatedStyle)(function () {
256
- return getStyle(derivedValue.value);
257
- }, [val, getStyle, derivedValue, instance]);
429
+ }
430
+ var styleVal = (0, import_react_native_reanimated.useDerivedValue)(function () {
431
+ "worklet";
432
+
433
+ return getStyle(instance.value);
434
+ });
435
+ var animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(function () {
436
+ "worklet";
437
+
438
+ return styleVal.value;
439
+ });
440
+ silenceAnimatedComponentDevCheck(animatedStyle);
441
+ return animatedStyle;
442
+ },
443
+ useAnimatedNumbersStyle(vals, getStyle) {
444
+ var instances = vals.map(function (v) {
445
+ return v.getInstance();
446
+ });
447
+ var animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(function () {
448
+ "worklet";
449
+
450
+ var currentValues = instances.map(function (inst) {
451
+ return inst.value;
452
+ });
453
+ return getStyle(...currentValues);
454
+ }, import_core.isWeb ? [getStyle, ...instances] : void 0);
455
+ silenceAnimatedComponentDevCheck(animatedStyle);
456
+ return animatedStyle;
258
457
  },
259
458
  // =========================================================================
260
459
  // useAnimations - Main animation hook for components
261
460
  // =========================================================================
262
461
  useAnimations(animationProps) {
263
462
  var {
264
- props,
265
- presence,
266
- style,
267
- componentState,
268
- useStyleEmitter,
269
- themeName
270
- } = animationProps,
271
- isHydrating = componentState.unmounted === !0,
272
- isMounting = componentState.unmounted === "should-enter",
273
- isEntering = !!componentState.unmounted,
274
- isExiting = presence?.[0] === !1,
275
- wasEnteringRef = (0, import_react.useRef)(isEntering),
276
- justFinishedEntering = wasEnteringRef.current && !isEntering;
463
+ props,
464
+ presence,
465
+ style,
466
+ componentState,
467
+ useStyleEmitter,
468
+ themeName,
469
+ stateRef,
470
+ styleState
471
+ } = animationProps;
472
+ var isHydrating = componentState.unmounted === true;
473
+ var isMounting = componentState.unmounted === "should-enter";
474
+ var isEntering = !!componentState.unmounted;
475
+ var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
476
+ var wasEnteringRef = (0, import_react.useRef)(isEntering);
477
+ var justFinishedEntering = wasEnteringRef.current && !isEntering;
277
478
  import_react.default.useEffect(function () {
278
479
  wasEnteringRef.current = isEntering;
279
480
  });
280
- var normalized = (0, import_animation_helpers.normalizeTransition)(props.transition),
281
- animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default",
282
- animationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState),
283
- disableAnimation = isHydrating || !animationKey,
284
- isDark = themeName?.startsWith("dark") || !1,
285
- sendExitComplete = presence?.[1],
286
- exitProgress = (0, import_react_native_reanimated.useSharedValue)(0),
287
- animatedTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null),
288
- staticTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null),
289
- transformTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null),
290
- {
291
- animatedStyles,
292
- staticStyles
293
- } = (0, import_react.useMemo)(function () {
294
- var animated = {},
295
- staticStyles2 = {},
296
- animateOnly = props.animateOnly;
297
- for (var key2 in style) {
298
- var rawValue = style[key2],
299
- value = resolveDynamicValue(rawValue, isDark);
300
- if (value !== void 0) {
301
- if (disableAnimation) {
302
- staticStyles2[key2] = value;
303
- continue;
304
- }
305
- canAnimateProperty(key2, value, animateOnly) ? animated[key2] = value : staticStyles2[key2] = value;
306
- }
481
+ var _styleState_effectiveTransition;
482
+ var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
483
+ var normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);
484
+ var animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default";
485
+ var animationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
486
+ var disableAnimation = isHydrating || !animationKey;
487
+ var isDark = (themeName === null || themeName === void 0 ? void 0 : themeName.startsWith("dark")) || false;
488
+ var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
489
+ var exitCycleIdRef = (0, import_react.useRef)(0);
490
+ var pendingExitKeysRef = (0, import_react.useRef)(/* @__PURE__ */new Set());
491
+ var exitCompletedRef = (0, import_react.useRef)(false);
492
+ var wasExitingRef = (0, import_react.useRef)(false);
493
+ var justStartedExiting = isExiting && !wasExitingRef.current;
494
+ var justStoppedExiting = !isExiting && wasExitingRef.current;
495
+ var markExitKeyDone = (0, import_core.useEvent)(function (key3, cycleId, finished) {
496
+ if (cycleId !== exitCycleIdRef.current) return;
497
+ if (exitCompletedRef.current) return;
498
+ pendingExitKeysRef.current.delete(key3);
499
+ if (pendingExitKeysRef.current.size === 0) {
500
+ exitCompletedRef.current = true;
501
+ sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
502
+ }
503
+ });
504
+ var isExitingRef = (0, import_react_native_reanimated.useSharedValue)(isExiting);
505
+ var exitCycleIdShared = (0, import_react_native_reanimated.useSharedValue)(exitCycleIdRef.current);
506
+ if (justStartedExiting) {
507
+ exitCycleIdRef.current++;
508
+ exitCompletedRef.current = false;
509
+ pendingExitKeysRef.current.clear();
510
+ }
511
+ if (justStoppedExiting) {
512
+ exitCycleIdRef.current++;
513
+ pendingExitKeysRef.current.clear();
514
+ }
515
+ (0, import_core.useIsomorphicLayoutEffect)(function () {
516
+ isExitingRef.value = isExiting;
517
+ exitCycleIdShared.value = exitCycleIdRef.current;
518
+ }, [isExiting, exitCycleIdRef.current]);
519
+ import_react.default.useEffect(function () {
520
+ wasExitingRef.current = isExiting;
521
+ });
522
+ var animatedTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null);
523
+ var staticTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null);
524
+ var transformTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null);
525
+ var {
526
+ animatedStyles,
527
+ staticStyles
528
+ } = (0, import_react.useMemo)(function () {
529
+ var animated = {};
530
+ var staticStyles2 = {};
531
+ var animateOnly2 = props.animateOnly;
532
+ for (var key3 in style) {
533
+ var rawValue = style[key3];
534
+ var value = resolveDynamicValue(rawValue, isDark);
535
+ if (value === void 0) continue;
536
+ if (disableAnimation) {
537
+ staticStyles2[key3] = cloneAnimationValue(value);
538
+ continue;
539
+ }
540
+ if (canAnimateProperty(key3, value, animateOnly2)) {
541
+ animated[key3] = cloneAnimationValue(value);
542
+ } else {
543
+ staticStyles2[key3] = cloneAnimationValue(value);
307
544
  }
308
- if (isMounting) for (var key1 in animated) staticStyles2[key1] = animated[key1];
545
+ }
546
+ if (isMounting) {
547
+ for (var key1 in animated) {
548
+ staticStyles2[key1] = animated[key1];
549
+ }
550
+ }
551
+ return {
552
+ animatedStyles: animated,
553
+ staticStyles: staticStyles2
554
+ };
555
+ }, [disableAnimation, style, isDark, isMounting, props.animateOnly]);
556
+ var {
557
+ baseConfig,
558
+ propertyConfigs
559
+ } = (0, import_react.useMemo)(function () {
560
+ if (isHydrating) {
309
561
  return {
310
- animatedStyles: animated,
311
- staticStyles: staticStyles2
312
- };
313
- }, [disableAnimation, style, isDark, isMounting, props.animateOnly]),
314
- {
315
- baseConfig,
316
- propertyConfigs
317
- } = (0, import_react.useMemo)(function () {
318
- if (isHydrating) return {
319
562
  baseConfig: {
320
563
  type: "timing",
321
564
  duration: 0
322
565
  },
323
566
  propertyConfigs: {}
324
567
  };
325
- var normalized2 = (0, import_animation_helpers.normalizeTransition)(props.transition),
326
- effectiveKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized2, animationState),
327
- _animations_effectiveKey,
328
- base = effectiveKey ? (_animations_effectiveKey = animations[effectiveKey]) !== null && _animations_effectiveKey !== void 0 ? _animations_effectiveKey : {
329
- type: "spring"
330
- } : {
331
- type: "spring"
332
- };
333
- normalized2.delay && (base = {
334
- ...base,
335
- delay: normalized2.delay
336
- }), normalized2.config && (base = {
337
- ...base,
338
- ...normalized2.config
339
- });
340
- var overrides = {};
341
- for (var key2 in normalized2.properties) {
342
- var animationNameOrConfig = normalized2.properties[key2];
343
- if (typeof animationNameOrConfig == "string") {
344
- var _animations_animationNameOrConfig;
345
- overrides[key2] = (_animations_animationNameOrConfig = animations[animationNameOrConfig]) !== null && _animations_animationNameOrConfig !== void 0 ? _animations_animationNameOrConfig : base;
346
- } else if (animationNameOrConfig && (typeof animationNameOrConfig > "u" ? "undefined" : _type_of(animationNameOrConfig)) === "object") {
347
- var configType = animationNameOrConfig.type,
348
- _animations_configType,
349
- baseForProp = configType && (_animations_configType = animations[configType]) !== null && _animations_configType !== void 0 ? _animations_configType : base;
350
- overrides[key2] = {
351
- ...baseForProp,
352
- ...animationNameOrConfig
353
- };
354
- }
568
+ }
569
+ return buildTransitionConfig(props.transition, animations, animationState, getStyleKeys(animatedStyles));
570
+ }, [isHydrating, props.transition, animatedStyles, animationState]);
571
+ var configRef = (0, import_react_native_reanimated.useSharedValue)({
572
+ baseConfig,
573
+ propertyConfigs,
574
+ disableAnimation,
575
+ isHydrating
576
+ });
577
+ (0, import_core.useIsomorphicLayoutEffect)(function () {
578
+ configRef.value = {
579
+ baseConfig,
580
+ propertyConfigs,
581
+ disableAnimation,
582
+ isHydrating
583
+ };
584
+ }, [baseConfig, propertyConfigs, disableAnimation, isHydrating]);
585
+ useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function (nextStyle, effectiveTransition2) {
586
+ var animateOnly2 = props.animateOnly;
587
+ var animated = {};
588
+ var statics = {};
589
+ var transforms2 = [];
590
+ var transitionToUse = effectiveTransition2 !== null && effectiveTransition2 !== void 0 ? effectiveTransition2 : props.transition;
591
+ var {
592
+ baseConfig: newBase,
593
+ propertyConfigs: newPropertyConfigs
594
+ } = buildTransitionConfig(transitionToUse, animations, animationState, getStyleKeys(nextStyle));
595
+ configRef.value = {
596
+ baseConfig: newBase,
597
+ propertyConfigs: newPropertyConfigs,
598
+ disableAnimation: configRef.value.disableAnimation,
599
+ isHydrating: configRef.value.isHydrating
600
+ };
601
+ for (var key3 in nextStyle) {
602
+ var rawValue = nextStyle[key3];
603
+ var value = resolveDynamicValue(rawValue, isDark);
604
+ if (value == void 0) continue;
605
+ if (configRef.value.disableAnimation) {
606
+ statics[key3] = cloneAnimationValue(value);
607
+ continue;
355
608
  }
356
- var configs = {},
357
- allKeys = new Set(Object.keys(animatedStyles));
358
- if (animatedStyles.transform && Array.isArray(animatedStyles.transform)) {
359
- var _iteratorNormalCompletion = !0,
360
- _didIteratorError = !1,
361
- _iteratorError = void 0;
609
+ if (key3 === "transform" && Array.isArray(value)) {
610
+ var _iteratorNormalCompletion2 = true,
611
+ _didIteratorError2 = false,
612
+ _iteratorError2 = void 0;
362
613
  try {
363
- for (var _iterator = animatedStyles.transform[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
364
- var t = _step.value;
365
- allKeys.add(Object.keys(t)[0]);
614
+ for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
615
+ var t2 = _step2.value;
616
+ if (t2 && (typeof t2 === "undefined" ? "undefined" : _type_of(t2)) === "object") {
617
+ var tKey2 = Object.keys(t2)[0];
618
+ var tVal = t2[tKey2];
619
+ if (typeof tVal === "number" || typeof tVal === "string") {
620
+ transforms2.push(cloneAnimationValue(t2));
621
+ }
622
+ }
366
623
  }
367
624
  } catch (err) {
368
- _didIteratorError = !0, _iteratorError = err;
625
+ _didIteratorError2 = true;
626
+ _iteratorError2 = err;
369
627
  } finally {
370
628
  try {
371
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
629
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
630
+ _iterator2.return();
631
+ }
372
632
  } finally {
373
- if (_didIteratorError) throw _iteratorError;
633
+ if (_didIteratorError2) {
634
+ throw _iteratorError2;
635
+ }
374
636
  }
375
637
  }
638
+ continue;
639
+ }
640
+ if (canAnimateProperty(key3, value, animateOnly2)) {
641
+ animated[key3] = cloneAnimationValue(value);
642
+ } else {
643
+ statics[key3] = cloneAnimationValue(value);
644
+ }
645
+ }
646
+ animatedTargetsRef.value = animated;
647
+ staticTargetsRef.value = statics;
648
+ transformTargetsRef.value = transforms2;
649
+ if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
650
+ console.info("[animations-reanimated] useStyleEmitter update", {
651
+ animated,
652
+ statics,
653
+ transforms: transforms2
654
+ });
655
+ }
656
+ });
657
+ var exitKeysRegistered = (0, import_react.useRef)(false);
658
+ if (justStartedExiting && sendExitComplete) {
659
+ var exitKeys = [];
660
+ var animateOnly = props.animateOnly;
661
+ for (var key2 in animatedStyles) {
662
+ if (key2 === "transform") continue;
663
+ if (canAnimateProperty(key2, animatedStyles[key2], animateOnly)) {
664
+ exitKeys.push(key2);
376
665
  }
377
- var _iteratorNormalCompletion1 = !0,
378
- _didIteratorError1 = !1,
379
- _iteratorError1 = void 0;
666
+ }
667
+ var transforms = animatedStyles.transform;
668
+ if (transforms && Array.isArray(transforms)) {
669
+ var _iteratorNormalCompletion = true,
670
+ _didIteratorError = false,
671
+ _iteratorError = void 0;
380
672
  try {
381
- for (var _iterator1 = allKeys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
382
- var key1 = _step1.value,
383
- _overrides_key;
384
- configs[key1] = (_overrides_key = overrides[key1]) !== null && _overrides_key !== void 0 ? _overrides_key : base;
673
+ for (var _iterator = transforms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
674
+ var t = _step.value;
675
+ if (!t) continue;
676
+ var tKey = Object.keys(t)[0];
677
+ if (tKey) {
678
+ if (animateOnly && !animateOnly.includes(tKey)) {
679
+ continue;
680
+ }
681
+ exitKeys.push(`transform:${tKey}`);
682
+ }
385
683
  }
386
684
  } catch (err) {
387
- _didIteratorError1 = !0, _iteratorError1 = err;
685
+ _didIteratorError = true;
686
+ _iteratorError = err;
388
687
  } finally {
389
688
  try {
390
- !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
689
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
690
+ _iterator.return();
691
+ }
391
692
  } finally {
392
- if (_didIteratorError1) throw _iteratorError1;
393
- }
394
- }
395
- return {
396
- baseConfig: base,
397
- propertyConfigs: configs
398
- };
399
- }, [isHydrating, props.transition, animatedStyles, animationState]),
400
- configRef = (0, import_react_native_reanimated.useSharedValue)({
401
- baseConfig,
402
- propertyConfigs,
403
- disableAnimation,
404
- isHydrating
405
- });
406
- (0, import_core.useIsomorphicLayoutEffect)(function () {
407
- configRef.set({
408
- baseConfig,
409
- propertyConfigs,
410
- disableAnimation,
411
- isHydrating
412
- });
413
- }, [baseConfig, propertyConfigs, disableAnimation, isHydrating]), useStyleEmitter?.(function (nextStyle) {
414
- var animateOnly = props.animateOnly,
415
- animated = {},
416
- statics = {},
417
- transforms = [];
418
- for (var key2 in nextStyle) {
419
- var rawValue = nextStyle[key2],
420
- value = resolveDynamicValue(rawValue, isDark);
421
- if (value != null) {
422
- if (configRef.get().disableAnimation) {
423
- statics[key2] = value;
424
- continue;
425
- }
426
- if (key2 === "transform" && Array.isArray(value)) {
427
- var _iteratorNormalCompletion = !0,
428
- _didIteratorError = !1,
429
- _iteratorError = void 0;
430
- try {
431
- for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
432
- var t = _step.value;
433
- if (t && (typeof t > "u" ? "undefined" : _type_of(t)) === "object") {
434
- var tKey = Object.keys(t)[0],
435
- tVal = t[tKey];
436
- (typeof tVal == "number" || typeof tVal == "string") && transforms.push(t);
437
- }
438
- }
439
- } catch (err) {
440
- _didIteratorError = !0, _iteratorError = err;
441
- } finally {
442
- try {
443
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
444
- } finally {
445
- if (_didIteratorError) throw _iteratorError;
446
- }
693
+ if (_didIteratorError) {
694
+ throw _iteratorError;
447
695
  }
448
- continue;
449
696
  }
450
- canAnimateProperty(key2, value, animateOnly) ? animated[key2] = value : statics[key2] = value;
451
697
  }
452
698
  }
453
- animatedTargetsRef.set(animated), staticTargetsRef.set(statics), transformTargetsRef.set(transforms), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-reanimated] useStyleEmitter update", {
454
- animated,
455
- statics,
456
- transforms
457
- });
458
- }), import_react.default.useEffect(function () {
459
- if (!(!isExiting || !sendExitComplete)) {
460
- var config = configRef.get().baseConfig;
461
- return config.type === "timing" ? exitProgress.set((0, import_react_native_reanimated.withTiming)(1, config, function (finished) {
462
- "worklet";
463
-
464
- finished && (0, import_react_native_reanimated.runOnJS)(sendExitComplete)();
465
- })) : exitProgress.set((0, import_react_native_reanimated.withSpring)(1, config, function (finished) {
466
- "worklet";
467
-
468
- finished && (0, import_react_native_reanimated.runOnJS)(sendExitComplete)();
469
- })), function () {
470
- (0, import_react_native_reanimated.cancelAnimation)(exitProgress);
471
- };
699
+ pendingExitKeysRef.current = new Set(exitKeys);
700
+ exitKeysRegistered.current = exitKeys.length > 0;
701
+ }
702
+ import_react.default.useEffect(function () {
703
+ if (!justStartedExiting || !sendExitComplete) return;
704
+ if (!exitKeysRegistered.current && pendingExitKeysRef.current.size === 0) {
705
+ if (!exitCompletedRef.current) {
706
+ exitCompletedRef.current = true;
707
+ sendExitComplete();
708
+ }
472
709
  }
473
- }, [isExiting, sendExitComplete]);
710
+ }, [justStartedExiting, sendExitComplete]);
474
711
  var animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(function () {
475
712
  "worklet";
476
713
 
477
- if (disableAnimation || isHydrating) return {};
478
- var result = {},
479
- config = configRef.get(),
480
- emitterAnimated = animatedTargetsRef.value,
481
- emitterStatic = staticTargetsRef.value,
482
- emitterTransforms = transformTargetsRef.value,
483
- hasEmitterUpdates = emitterAnimated !== null,
484
- animatedValues = hasEmitterUpdates ? emitterAnimated : animatedStyles,
485
- staticValues = hasEmitterUpdates ? emitterStatic : {};
486
- for (var key2 in staticValues) result[key2] = staticValues[key2];
487
- for (var key1 in animatedValues) if (key1 !== "transform") {
488
- var targetValue = animatedValues[key1],
489
- _config_propertyConfigs_key,
490
- propConfig = (_config_propertyConfigs_key = config.propertyConfigs[key1]) !== null && _config_propertyConfigs_key !== void 0 ? _config_propertyConfigs_key : config.baseConfig;
491
- result[key1] = applyAnimation(targetValue, propConfig);
714
+ var _loop = function (key12) {
715
+ if (key12 === "transform") return "continue";
716
+ var targetValue = animatedValues[key12];
717
+ var _config_propertyConfigs_key;
718
+ var propConfig = (_config_propertyConfigs_key = config.propertyConfigs[key12]) !== null && _config_propertyConfigs_key !== void 0 ? _config_propertyConfigs_key : config.baseConfig;
719
+ var callback = void 0;
720
+ if (currentlyExiting) {
721
+ var capturedKey = key12;
722
+ var capturedCycleId = currentCycleId;
723
+ callback = function (finished) {
724
+ "worklet";
725
+
726
+ (0, import_react_native_reanimated.runOnJS)(markExitKeyDone)(capturedKey, capturedCycleId, finished !== null && finished !== void 0 ? finished : false);
727
+ };
728
+ }
729
+ result[key12] = applyAnimation(targetValue, propConfig, callback);
730
+ };
731
+ if (disableAnimation || isHydrating) {
732
+ return {};
492
733
  }
493
- var transforms = hasEmitterUpdates ? emitterTransforms : animatedStyles.transform;
494
- if (transforms && Array.isArray(transforms)) {
495
- var validTransforms = [],
496
- _iteratorNormalCompletion = !0,
497
- _didIteratorError = !1,
498
- _iteratorError = void 0;
734
+ var result = {};
735
+ var config = configRef.value;
736
+ var emitterAnimated = animatedTargetsRef.value;
737
+ var emitterStatic = staticTargetsRef.value;
738
+ var emitterTransforms = transformTargetsRef.value;
739
+ var hasEmitterUpdates = emitterAnimated !== null;
740
+ var animatedValues = hasEmitterUpdates ? emitterAnimated : animatedStyles;
741
+ var staticValues = hasEmitterUpdates ? emitterStatic : {};
742
+ var currentlyExiting = isExitingRef.value;
743
+ var currentCycleId = exitCycleIdShared.value;
744
+ for (var key3 in staticValues) {
745
+ result[key3] = staticValues[key3];
746
+ }
747
+ for (var key1 in animatedValues) _loop(key1);
748
+ var transforms2 = hasEmitterUpdates ? emitterTransforms : animatedStyles.transform;
749
+ if (transforms2 && Array.isArray(transforms2)) {
750
+ var validTransforms = [];
751
+ var _iteratorNormalCompletion2 = true,
752
+ _didIteratorError2 = false,
753
+ _iteratorError2 = void 0;
499
754
  try {
500
- for (var _iterator = transforms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
501
- var t = _step.value;
502
- if (t) {
503
- var keys = Object.keys(t);
504
- if (keys.length !== 0) {
505
- var value = t[keys[0]];
506
- if (typeof value == "number" || typeof value == "string") {
507
- var transformKey = Object.keys(t)[0],
508
- targetValue1 = t[transformKey],
509
- _config_propertyConfigs_transformKey,
510
- propConfig1 = (_config_propertyConfigs_transformKey = config.propertyConfigs[transformKey]) !== null && _config_propertyConfigs_transformKey !== void 0 ? _config_propertyConfigs_transformKey : config.baseConfig;
511
- validTransforms.push({
512
- [transformKey]: applyAnimation(targetValue1, propConfig1)
513
- });
514
- }
755
+ var _loop1 = function () {
756
+ var t2 = _step2.value;
757
+ if (!t2) return "continue";
758
+ var keys = Object.keys(t2);
759
+ if (keys.length === 0) return "continue";
760
+ var value = t2[keys[0]];
761
+ if (typeof value === "number" || typeof value === "string") {
762
+ var transformKey = Object.keys(t2)[0];
763
+ var targetValue = t2[transformKey];
764
+ var _config_propertyConfigs_transformKey;
765
+ var propConfig = (_config_propertyConfigs_transformKey = config.propertyConfigs[transformKey]) !== null && _config_propertyConfigs_transformKey !== void 0 ? _config_propertyConfigs_transformKey : config.baseConfig;
766
+ var callback = void 0;
767
+ if (currentlyExiting) {
768
+ var capturedKey = `transform:${transformKey}`;
769
+ var capturedCycleId = currentCycleId;
770
+ callback = function (finished) {
771
+ "worklet";
772
+
773
+ (0, import_react_native_reanimated.runOnJS)(markExitKeyDone)(capturedKey, capturedCycleId, finished !== null && finished !== void 0 ? finished : false);
774
+ };
515
775
  }
776
+ validTransforms.push({
777
+ [transformKey]: applyAnimation(targetValue, propConfig, callback)
778
+ });
516
779
  }
517
- }
780
+ };
781
+ for (var _iterator2 = transforms2[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) _loop1();
518
782
  } catch (err) {
519
- _didIteratorError = !0, _iteratorError = err;
783
+ _didIteratorError2 = true;
784
+ _iteratorError2 = err;
520
785
  } finally {
521
786
  try {
522
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
787
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
788
+ _iterator2.return();
789
+ }
523
790
  } finally {
524
- if (_didIteratorError) throw _iteratorError;
791
+ if (_didIteratorError2) {
792
+ throw _iteratorError2;
793
+ }
525
794
  }
526
795
  }
527
- validTransforms.length > 0 && (result.transform = validTransforms);
796
+ if (validTransforms.length > 0) {
797
+ result.transform = validTransforms;
798
+ }
528
799
  }
529
800
  return result;
530
- }, [animatedStyles, baseConfig, propertyConfigs, disableAnimation, isHydrating,
531
- // Pass SharedValues so the mapper watches them on web (see useAnimatedStyle.ts line 470-472)
532
- animatedTargetsRef, staticTargetsRef, transformTargetsRef]);
533
- return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-reanimated] useAnimations", {
534
- animationKey,
535
- componentState,
536
- isExiting,
537
- animatedStyles,
538
- staticStyles,
539
- baseConfig,
540
- propertyConfigs
541
- }), {
801
+ }, import_core.isWeb ? [animatedStyles, baseConfig, propertyConfigs, disableAnimation, isHydrating,
802
+ // pass SharedValues so the mapper watches them on web (no babel plugin)
803
+ animatedTargetsRef, staticTargetsRef, transformTargetsRef, isExitingRef, exitCycleIdShared, markExitKeyDone] : void 0);
804
+ silenceAnimatedComponentDevCheck(animatedStyle);
805
+ if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
806
+ console.info("[animations-reanimated] useAnimations", {
807
+ animationKey,
808
+ componentState,
809
+ isExiting,
810
+ animatedStyles,
811
+ staticStyles,
812
+ baseConfig,
813
+ propertyConfigs
814
+ });
815
+ }
816
+ return {
542
817
  style: [staticStyles, animatedStyle]
543
818
  };
544
819
  }