@tamagui/animations-react-native 3.0.0-beta.924.1 → 3.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.
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  enumerable: true
27
27
  }) : target, mod));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var createAnimations_exports = {};
30
- __export(createAnimations_exports, {
29
+ var createAnimations_native_exports = {};
30
+ __export(createAnimations_native_exports, {
31
31
  AnimatedText: () => AnimatedText,
32
32
  AnimatedView: () => AnimatedView,
33
33
  createAnimations: () => createAnimations,
@@ -36,7 +36,7 @@ __export(createAnimations_exports, {
36
36
  useAnimatedNumberStyle: () => useAnimatedNumberStyle,
37
37
  useAnimatedNumbersStyle: () => useAnimatedNumbersStyle
38
38
  });
39
- module.exports = __toCommonJS(createAnimations_exports);
39
+ module.exports = __toCommonJS(createAnimations_native_exports);
40
40
  var import_animation_helpers = require("@tamagui/animation-helpers");
41
41
  var import_constants = require("@tamagui/constants");
42
42
  var import_use_presence = require("@tamagui/use-presence");
@@ -44,13 +44,9 @@ var import_web = require("@tamagui/web");
44
44
  var import_internal_runtime = require("@tamagui/web/internal-runtime");
45
45
  var import_react = __toESM(require("react"), 1);
46
46
  var import_react_native = require("react-native");
47
- function _type_of(obj) {
48
- "@swc/helpers - typeof";
49
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
50
- }
51
47
  var isFabric = !import_constants.isWeb && typeof global !== "undefined" && !!global.__nativeFabricUIManager;
52
48
  var resolveDynamicValue = function(value, isDark) {
53
- if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "dynamic" in value) {
49
+ if (value && typeof value === "object" && "dynamic" in value) {
54
50
  var dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light;
55
51
  return dynamicValue;
56
52
  }
@@ -77,13 +73,31 @@ var layoutStyleKey = {
77
73
  minWidth: true,
78
74
  maxWidth: true
79
75
  };
80
- function hasAnimatedLayoutKey(style, isDark, animateOnly) {
76
+ var textMetricStyleKey = {
77
+ fontSize: true,
78
+ lineHeight: true
79
+ };
80
+ var jsDriverStyleKey = {
81
+ ...layoutStyleKey,
82
+ ...textMetricStyleKey
83
+ };
84
+ function hasAnimatedLayoutKey(style, isDark, resolved) {
81
85
  for (var key in layoutStyleKey) {
82
- if (animateOnly && !animateOnly.includes(key)) continue;
86
+ if (!(0, import_animation_helpers.getTransitionForKey)(resolved, key)) continue;
83
87
  if (typeof resolveDynamicValue(style[key], isDark) === "number") return true;
84
88
  }
85
89
  return false;
86
90
  }
91
+ var getLeadingRatio = function(metrics) {
92
+ var ratio = metrics === null || metrics === void 0 ? void 0 : metrics.lineHeight;
93
+ return typeof ratio === "number" && Number.isFinite(ratio) && ratio >= 0 ? ratio : void 0;
94
+ };
95
+ var paintsLeadingProduct = function(style, ratio) {
96
+ return ratio !== void 0 && typeof style.fontSize === "number" && typeof style.lineHeight === "number";
97
+ };
98
+ var inheritedFontSizeNode = function(style, ratio, inheritedText) {
99
+ return ratio !== void 0 && typeof style.fontSize !== "number" && (inheritedText === null || inheritedText === void 0 ? void 0 : inheritedText.driver) === "react-native" ? inheritedText.fontSize : void 0;
100
+ };
87
101
  function isAnimatableColor(value) {
88
102
  return typeof value === "string" && (0, import_react_native.processColor)(value) != null;
89
103
  }
@@ -102,6 +116,7 @@ var costlyToAnimateStyleKey = {
102
116
  };
103
117
  var AnimatedView = import_react_native.Animated.View;
104
118
  var AnimatedText = import_react_native.Animated.Text;
119
+ var animatedTextInput;
105
120
  function useAnimatedNumber(initial) {
106
121
  var state = import_react.default.useRef(null);
107
122
  if (!state.current) {
@@ -131,10 +146,14 @@ function useAnimatedNumber(initial) {
131
146
  return finished ? onFinish() : null;
132
147
  } : void 0;
133
148
  if (type === "direct") {
134
- val.setValue(next);
135
- } else if (type === "spring") {
136
149
  var _state_current_composite;
137
150
  (_state_current_composite = state.current.composite) === null || _state_current_composite === void 0 ? void 0 : _state_current_composite.stop();
151
+ state.current.composite = null;
152
+ val.setValue(next);
153
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish();
154
+ } else if (type === "spring") {
155
+ var _state_current_composite1;
156
+ (_state_current_composite1 = state.current.composite) === null || _state_current_composite1 === void 0 ? void 0 : _state_current_composite1.stop();
138
157
  var composite = import_react_native.Animated.spring(val, {
139
158
  ...config,
140
159
  toValue: next,
@@ -143,8 +162,8 @@ function useAnimatedNumber(initial) {
143
162
  composite.start(handleFinish);
144
163
  state.current.composite = composite;
145
164
  } else {
146
- var _state_current_composite1;
147
- (_state_current_composite1 = state.current.composite) === null || _state_current_composite1 === void 0 ? void 0 : _state_current_composite1.stop();
165
+ var _state_current_composite2;
166
+ (_state_current_composite2 = state.current.composite) === null || _state_current_composite2 === void 0 ? void 0 : _state_current_composite2.stop();
148
167
  var composite1 = import_react_native.Animated.timing(val, {
149
168
  ...config,
150
169
  toValue: next,
@@ -186,7 +205,7 @@ var useAnimatedNumberStyle = function(value, getStyle) {
186
205
  return usesAnimatedNode ? animatedStyle : getStyle(current);
187
206
  };
188
207
  function hasAnimatedNode(value) {
189
- if (!value || (typeof value === "undefined" ? "undefined" : _type_of(value)) !== "object") return false;
208
+ if (!value || typeof value !== "object") return false;
190
209
  if (typeof value.__getValue === "function") return true;
191
210
  if (Array.isArray(value)) return value.some(hasAnimatedNode);
192
211
  return Object.values(value).some(hasAnimatedNode);
@@ -213,8 +232,31 @@ function createAnimations(animations, options) {
213
232
  useAnimatedNumbersStyle,
214
233
  usePresence: import_use_presence.usePresence,
215
234
  ResetPresence: import_use_presence.ResetPresence,
235
+ useTextMetrics: function(param) {
236
+ var { inheritedText, lineHeight } = param;
237
+ var node = (inheritedText === null || inheritedText === void 0 ? void 0 : inheritedText.driver) === "react-native" ? inheritedText.fontSize : null;
238
+ var ratio = typeof lineHeight === "number" ? lineHeight : null;
239
+ var style = import_react.default.useMemo(function() {
240
+ return node ? ratio === null ? { fontSize: node } : {
241
+ fontSize: node,
242
+ lineHeight: import_react_native.Animated.multiply(node, ratio)
243
+ } : null;
244
+ }, [node, ratio]);
245
+ var textChannel = inheritedText !== null && inheritedText !== void 0 ? inheritedText : null;
246
+ if (!style) return {
247
+ style: null,
248
+ textChannel
249
+ };
250
+ animatedTextInput || (animatedTextInput = import_react_native.Animated.createAnimatedComponent(import_react_native.TextInput));
251
+ return {
252
+ style,
253
+ textChannel,
254
+ Text: AnimatedText,
255
+ TextInput: animatedTextInput
256
+ };
257
+ },
216
258
  useAnimations: function(param) {
217
- var { props, onTransition, style, componentState, presence, stateRef, useStyleEmitter } = param;
259
+ var { props, onTransition, style, componentState, presence, stateRef, styleState, useStyleEmitter, inheritedText } = param;
218
260
  var _themeState_name;
219
261
  var isDisabled = import_constants.isWeb && componentState.unmounted === true;
220
262
  var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
@@ -232,9 +274,41 @@ function createAnimations(animations, options) {
232
274
  cause
233
275
  });
234
276
  };
277
+ var _styleState_effectiveTransition;
278
+ var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
235
279
  var [, themeState] = (0, import_internal_runtime.useThemeWithState)({});
236
280
  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"));
237
281
  var animateStyles = import_react.default.useRef({});
282
+ var leadingRatioValue = import_react.default.useRef(null);
283
+ var leadingRatioRef = import_react.default.useRef(void 0);
284
+ var paintsDerivedLeading = import_react.default.useRef(false);
285
+ var textChannelRef = import_react.default.useRef(null);
286
+ leadingRatioRef.current = getLeadingRatio(styleState === null || styleState === void 0 ? void 0 : styleState.nativeTextMetrics);
287
+ var paintedTextRef = import_react.default.useRef({});
288
+ var movesTextValue = function(key, target) {
289
+ if (typeof target !== "number") return false;
290
+ var node = animateStyles.current[key];
291
+ var last = node ? node["_value"] : paintedTextRef.current[key];
292
+ return last !== void 0 && last !== target;
293
+ };
294
+ var movesLeadingRatio = function(ratio) {
295
+ if (ratio === void 0) return false;
296
+ var node = leadingRatioValue.current;
297
+ var last = node ? node["_value"] : paintedTextRef.current.ratio;
298
+ return last !== void 0 && last !== ratio;
299
+ };
300
+ var fontSizeNode = import_react.default.useRef(null);
301
+ var animatedValueFor = function(key) {
302
+ var painted = animateStyles.current[key];
303
+ if (painted) return painted;
304
+ if (key === "fontSize" && fontSizeNode.current) return fontSizeNode.current;
305
+ if (textMetricStyleKey[key]) return new import_react_native.Animated.Value(paintedTextRef.current[key]);
306
+ return void 0;
307
+ };
308
+ var leadingRatioValueFrom = function() {
309
+ var _leadingRatioValue_current;
310
+ return (_leadingRatioValue_current = leadingRatioValue.current) !== null && _leadingRatioValue_current !== void 0 ? _leadingRatioValue_current : new import_react_native.Animated.Value(paintedTextRef.current.ratio);
311
+ };
238
312
  var animatedTranforms = import_react.default.useRef([]);
239
313
  var animationsState = import_react.default.useRef(/* @__PURE__ */ new WeakMap());
240
314
  var pseudoActiveRef = import_react.default.useRef(false);
@@ -255,8 +329,6 @@ function createAnimations(animations, options) {
255
329
  if (justStoppedExiting) {
256
330
  exitCycleIdRef.current++;
257
331
  }
258
- var animateOnly = props.animateOnly || [];
259
- var hasTransitionOnly = !!props.animateOnly;
260
332
  var isEntering = !!componentState.unmounted;
261
333
  var wasEnteringRef = import_react.default.useRef(isEntering);
262
334
  var justFinishedEntering = wasEnteringRef.current && !isEntering;
@@ -265,22 +337,43 @@ function createAnimations(animations, options) {
265
337
  });
266
338
  var args = [
267
339
  JSON.stringify(style),
340
+ JSON.stringify(effectiveTransition),
268
341
  componentState,
269
342
  isExiting,
270
343
  !!onTransition,
271
344
  isDark,
272
345
  justFinishedEntering,
273
- hasTransitionOnly
346
+ leadingRatioRef.current,
347
+ inheritedText
274
348
  ];
275
349
  var res = import_react.default.useMemo(function() {
350
+ var _textChannelRef_current;
276
351
  var runners = [];
277
352
  var completions = [];
278
353
  var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
354
+ var resolved = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(effectiveTransition, { animations }), animationState);
279
355
  var nonAnimatedStyle = {};
280
- var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(style, isDark, hasTransitionOnly ? animateOnly : void 0);
356
+ var paintedRatio = leadingRatioRef.current;
357
+ var paintsProduct = paintsLeadingProduct(style, paintedRatio);
358
+ var movesFontSize = movesTextValue("fontSize", style.fontSize);
359
+ var movesLeading = paintsProduct ? movesLeadingRatio(paintedRatio) : movesTextValue("lineHeight", style.lineHeight);
360
+ if (!isExiting && !isDisabled && !pseudoActiveRef.current) {
361
+ if (!movesFontSize) delete animateStyles.current.fontSize;
362
+ if (!movesLeading) delete animateStyles.current.lineHeight;
363
+ }
364
+ if (isDisabled || typeof style.fontSize !== "number" || !(0, import_animation_helpers.getTransitionForKey)(resolved, "fontSize")) {
365
+ fontSizeNode.current = null;
366
+ } else if (!fontSizeNode.current) {
367
+ fontSizeNode.current = new import_react_native.Animated.Value(style.fontSize);
368
+ }
281
369
  var seenAnimateKeys = /* @__PURE__ */ new Set();
282
370
  var sawTransform = false;
283
371
  var transformCount = 0;
372
+ var derivesLeading = !isDisabled && paintsProduct && (movesFontSize || movesLeading) && (!!(0, import_animation_helpers.getTransitionForKey)(resolved, "fontSize") || !!(0, import_animation_helpers.getTransitionForKey)(resolved, "lineHeight"));
373
+ var inheritedFontSize = isDisabled ? void 0 : inheritedFontSizeNode(style, paintedRatio, inheritedText);
374
+ var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(style, isDark, resolved) && !movesFontSize && !movesLeading && !inheritedFontSize && !Object.keys(animateStyles.current).some(function(key2) {
375
+ return jsDriverStyleKey[key2];
376
+ });
284
377
  for (var key in style) {
285
378
  var rawVal = style[key];
286
379
  var val = resolveDynamicValue(rawVal, isDark);
@@ -288,15 +381,25 @@ function createAnimations(animations, options) {
288
381
  if (isDisabled) {
289
382
  continue;
290
383
  }
291
- if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key] && !layoutStyleKey[key]) {
384
+ if ((derivesLeading || inheritedFontSize) && (key === "fontSize" || key === "lineHeight")) {
385
+ if (key === "fontSize" && derivesLeading && !movesFontSize) {
386
+ nonAnimatedStyle[key] = val;
387
+ }
388
+ continue;
389
+ }
390
+ if (textMetricStyleKey[key] && !(key === "fontSize" ? movesFontSize : movesLeading)) {
292
391
  nonAnimatedStyle[key] = val;
293
392
  continue;
294
393
  }
295
- if (hasTransitionOnly && !animateOnly.includes(key)) {
394
+ if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key] && !jsDriverStyleKey[key]) {
296
395
  nonAnimatedStyle[key] = val;
297
396
  continue;
298
397
  }
299
- if (layoutStyleKey[key] && typeof val !== "number") {
398
+ if (key !== "transform" && !(0, import_animation_helpers.getTransitionForKey)(resolved, key)) {
399
+ nonAnimatedStyle[key] = val;
400
+ continue;
401
+ }
402
+ if (jsDriverStyleKey[key] && typeof val !== "number") {
300
403
  nonAnimatedStyle[key] = val;
301
404
  continue;
302
405
  }
@@ -305,7 +408,7 @@ function createAnimations(animations, options) {
305
408
  continue;
306
409
  }
307
410
  if (key !== "transform") {
308
- animateStyles.current[key] = update(key, animateStyles.current[key], val);
411
+ animateStyles.current[key] = update(key, animatedValueFor(key), val);
309
412
  seenAnimateKeys.add(key);
310
413
  continue;
311
414
  }
@@ -342,6 +445,35 @@ function createAnimations(animations, options) {
342
445
  }
343
446
  }
344
447
  }
448
+ var ratioFactor = function() {
449
+ if (!movesLeading) {
450
+ leadingRatioValue.current = null;
451
+ return paintedRatio;
452
+ }
453
+ leadingRatioValue.current = update("lineHeight", leadingRatioValueFrom(), paintedRatio);
454
+ return leadingRatioValue.current;
455
+ };
456
+ var derivedLeading;
457
+ if (derivesLeading) {
458
+ var fontSizeFactor = style.fontSize;
459
+ if (movesFontSize) {
460
+ fontSizeFactor = update("fontSize", animatedValueFor("fontSize"), style.fontSize);
461
+ animateStyles.current.fontSize = fontSizeFactor;
462
+ seenAnimateKeys.add("fontSize");
463
+ }
464
+ derivedLeading = import_react_native.Animated.multiply(fontSizeFactor, ratioFactor());
465
+ } else if (inheritedFontSize) {
466
+ derivedLeading = import_react_native.Animated.multiply(inheritedFontSize, ratioFactor());
467
+ } else if (!isDisabled) {
468
+ leadingRatioValue.current = null;
469
+ }
470
+ paintsDerivedLeading.current = !!derivedLeading;
471
+ var ownFontSizeNode = fontSizeNode.current;
472
+ var textChannel = ownFontSizeNode ? ((_textChannelRef_current = textChannelRef.current) === null || _textChannelRef_current === void 0 ? void 0 : _textChannelRef_current.fontSize) === ownFontSizeNode ? textChannelRef.current : {
473
+ fontSize: ownFontSizeNode,
474
+ driver: "react-native"
475
+ } : typeof style.fontSize === "number" ? null : inheritedText !== null && inheritedText !== void 0 ? inheritedText : null;
476
+ textChannelRef.current = textChannel;
345
477
  if (!isExiting && !isDisabled && !pseudoActiveRef.current) {
346
478
  for (var k in animateStyles.current) {
347
479
  if (!seenAnimateKeys.has(k)) delete animateStyles.current[k];
@@ -364,11 +496,20 @@ function createAnimations(animations, options) {
364
496
  var _animationsState_current_get;
365
497
  return [k2, ((_animationsState_current_get = animationsState.current.get(v)) === null || _animationsState_current_get === void 0 ? void 0 : _animationsState_current_get.interpolation) || v];
366
498
  })),
499
+ ...derivedLeading ? { lineHeight: derivedLeading } : null,
367
500
  ...animatedTransformStyle
368
501
  };
502
+ if (!isDisabled) {
503
+ paintedTextRef.current = {
504
+ fontSize: style.fontSize,
505
+ lineHeight: style.lineHeight,
506
+ ratio: paintedRatio
507
+ };
508
+ }
369
509
  return {
370
510
  runners,
371
511
  completions,
512
+ textChannel,
372
513
  style: [nonAnimatedStyle, animatedStyle]
373
514
  };
374
515
  function update(key2, animated, valIn) {
@@ -396,7 +537,7 @@ function createAnimations(animations, options) {
396
537
  });
397
538
  }
398
539
  if (value) {
399
- var animationConfig = getAnimationConfig(key2, animations, props.transition, animationState);
540
+ var animationConfig = getAnimationConfig(key2, animations, effectiveTransition, animationState);
400
541
  var resolve;
401
542
  var promise = new Promise(function(res2) {
402
543
  resolve = res2;
@@ -404,15 +545,14 @@ function createAnimations(animations, options) {
404
545
  completions.push(promise);
405
546
  runners.push(function() {
406
547
  value.stopAnimation();
407
- function getAnimation() {
408
- return import_react_native.Animated[animationConfig.type || "spring"](value, {
409
- toValue: animateToValue,
410
- ...animationConfig,
411
- useNativeDriver: useNativeDriverForNode
412
- });
413
- }
414
- var animation = animationConfig.delay ? import_react_native.Animated.sequence([import_react_native.Animated.delay(animationConfig.delay), getAnimation()]) : getAnimation();
415
- animation.start(function(param2) {
548
+ var { type: type2, delay, ...config } = animationConfig;
549
+ var animation = import_react_native.Animated[type2 || "spring"](value, {
550
+ toValue: animateToValue,
551
+ ...config,
552
+ useNativeDriver: useNativeDriverForNode
553
+ });
554
+ var animation2 = delay ? import_react_native.Animated.sequence([import_react_native.Animated.delay(delay), animation]) : animation;
555
+ animation2.start(function(param2) {
416
556
  var { finished } = param2;
417
557
  if (finished || isExiting) {
418
558
  resolve();
@@ -509,19 +649,31 @@ function createAnimations(animations, options) {
509
649
  }
510
650
  });
511
651
  }, args);
512
- useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function(nextStyle, _effectiveTransition, pseudoActive) {
652
+ var onEmittedStyle = function(nextStyle, emittedTransition, pseudoActive, nextMetrics) {
513
653
  pseudoActiveRef.current = pseudoActive === true;
514
654
  var runners = [];
515
655
  var seenAnimateKeys = /* @__PURE__ */ new Set();
516
656
  var transformCount = 0;
517
657
  var animatedShapeChanged = false;
518
- var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(nextStyle, isDark) && !Object.keys(animateStyles.current).some(function(key2) {
519
- return layoutStyleKey[key2];
658
+ var emittedResolved = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(emittedTransition !== null && emittedTransition !== void 0 ? emittedTransition : effectiveTransition, { animations }), "default");
659
+ var emittedRatio = getLeadingRatio(nextMetrics);
660
+ var emitterPaintsProduct = paintsLeadingProduct(nextStyle, emittedRatio);
661
+ var emitterMovesFontSize = movesTextValue("fontSize", nextStyle.fontSize);
662
+ var emitterMovesLeading = emitterPaintsProduct ? movesLeadingRatio(emittedRatio) : movesTextValue("lineHeight", nextStyle.lineHeight);
663
+ var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(nextStyle, isDark, emittedResolved) && !emitterMovesFontSize && !emitterMovesLeading && !inheritedFontSizeNode(nextStyle, emittedRatio, inheritedText) && !Object.keys(animateStyles.current).some(function(key2) {
664
+ return jsDriverStyleKey[key2];
520
665
  });
666
+ var emitterDerivesLeading = emitterPaintsProduct && (emitterMovesFontSize || emitterMovesLeading) && (!!(0, import_animation_helpers.getTransitionForKey)(emittedResolved, "fontSize") || !!(0, import_animation_helpers.getTransitionForKey)(emittedResolved, "lineHeight"));
521
667
  for (var key in nextStyle) {
522
668
  var rawVal = nextStyle[key];
523
669
  var val = resolveDynamicValue(rawVal, isDark);
524
670
  if (val === void 0) continue;
671
+ if (emitterDerivesLeading && (key === "fontSize" || key === "lineHeight")) {
672
+ continue;
673
+ }
674
+ if (textMetricStyleKey[key] && !(key === "fontSize" ? emitterMovesFontSize : emitterMovesLeading)) {
675
+ continue;
676
+ }
525
677
  if (key === "transform" && Array.isArray(val)) {
526
678
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
527
679
  try {
@@ -549,14 +701,28 @@ function createAnimations(animations, options) {
549
701
  }
550
702
  }
551
703
  }
552
- } else if (animatedStyleKey[key] != null || costlyToAnimateStyleKey[key] || layoutStyleKey[key]) {
553
- if (layoutStyleKey[key] && typeof val !== "number") continue;
704
+ } else if (animatedStyleKey[key] != null || costlyToAnimateStyleKey[key] || jsDriverStyleKey[key]) {
705
+ if (jsDriverStyleKey[key] && typeof val !== "number") continue;
554
706
  if (colorStyleKey[key] && !isAnimatableColor(val)) continue;
555
707
  if (!animateStyles.current[key]) animatedShapeChanged = true;
556
- animateStyles.current[key] = update(key, animateStyles.current[key], val);
708
+ animateStyles.current[key] = update(key, animatedValueFor(key), val);
557
709
  seenAnimateKeys.add(key);
558
710
  }
559
711
  }
712
+ if (emitterDerivesLeading) {
713
+ if (emitterMovesFontSize) {
714
+ if (!animateStyles.current.fontSize) animatedShapeChanged = true;
715
+ animateStyles.current.fontSize = update("fontSize", animatedValueFor("fontSize"), nextStyle.fontSize);
716
+ seenAnimateKeys.add("fontSize");
717
+ }
718
+ if (emitterMovesLeading) {
719
+ if (!leadingRatioValue.current) animatedShapeChanged = true;
720
+ leadingRatioValue.current = update("lineHeight", leadingRatioValueFrom(), emittedRatio);
721
+ }
722
+ }
723
+ if (emitterDerivesLeading !== paintsDerivedLeading.current) {
724
+ animatedShapeChanged = true;
725
+ }
560
726
  for (var key1 in animateStyles.current) {
561
727
  if (!seenAnimateKeys.has(key1)) {
562
728
  delete animateStyles.current[key1];
@@ -567,6 +733,11 @@ function createAnimations(animations, options) {
567
733
  animatedTranforms.current = animatedTranforms.current.slice(0, transformCount);
568
734
  animatedShapeChanged = true;
569
735
  }
736
+ paintedTextRef.current = {
737
+ fontSize: nextStyle.fontSize,
738
+ lineHeight: nextStyle.lineHeight,
739
+ ratio: emittedRatio
740
+ };
570
741
  runners.forEach(function(r) {
571
742
  return r();
572
743
  });
@@ -595,19 +766,21 @@ function createAnimations(animations, options) {
595
766
  animateToValue: (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1
596
767
  });
597
768
  }
598
- var animationConfig = getAnimationConfig(key2, animations, props.transition, "default");
769
+ var animationConfig = getAnimationConfig(key2, animations, emittedTransition !== null && emittedTransition !== void 0 ? emittedTransition : effectiveTransition, "default");
599
770
  runners.push(function() {
600
771
  value.stopAnimation();
601
- var anim = import_react_native.Animated[animationConfig.type || "spring"](value, {
772
+ var { type: type2, delay, ...config } = animationConfig;
773
+ var anim = import_react_native.Animated[type2 || "spring"](value, {
602
774
  toValue: animateToValue,
603
- ...animationConfig,
775
+ ...config,
604
776
  useNativeDriver: useNativeDriverForNode
605
777
  });
606
- (animationConfig.delay ? import_react_native.Animated.sequence([import_react_native.Animated.delay(animationConfig.delay), anim]) : anim).start();
778
+ (delay ? import_react_native.Animated.sequence([import_react_native.Animated.delay(delay), anim]) : anim).start();
607
779
  });
608
780
  return value;
609
781
  }
610
- });
782
+ };
783
+ useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(onEmittedStyle);
611
784
  if (process.env.NODE_ENV === "development") {
612
785
  if (props["debug"] === "verbose") {
613
786
  console.info(`Animated`, {
@@ -648,41 +821,37 @@ function getInterpolated(current, next) {
648
821
  outputRange
649
822
  };
650
823
  }
651
- function getAnimationConfig(key, animations, transition) {
652
- var animationState = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "default";
653
- var normalized = (0, import_animation_helpers.normalizeTransition)(transition);
654
- var shortKey = transformShorthands[key];
655
- var _normalized_properties_key;
656
- var propAnimation = (_normalized_properties_key = normalized.properties[key]) !== null && _normalized_properties_key !== void 0 ? _normalized_properties_key : normalized.properties[shortKey];
657
- var animationType = null;
658
- var extraConf = {};
659
- if (typeof propAnimation === "string") {
660
- animationType = propAnimation;
661
- } else if (propAnimation && (typeof propAnimation === "undefined" ? "undefined" : _type_of(propAnimation)) === "object") {
662
- animationType = propAnimation.type || (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
663
- extraConf = propAnimation;
664
- } else {
665
- animationType = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
666
- }
667
- if (normalized.delay && !extraConf.delay) {
668
- extraConf = {
669
- ...extraConf,
670
- delay: normalized.delay
824
+ function entryToRN(entry) {
825
+ var extra = entry.timing.kind === "spring" ? entry.timing.extra : void 0;
826
+ if (entry.timing.kind === "spring") {
827
+ return {
828
+ type: "spring",
829
+ stiffness: entry.timing.stiffness,
830
+ damping: entry.timing.damping,
831
+ mass: entry.timing.mass,
832
+ ...typeof (extra === null || extra === void 0 ? void 0 : extra.velocity) === "number" ? { velocity: extra.velocity } : null,
833
+ ...typeof (extra === null || extra === void 0 ? void 0 : extra.overshootClamping) === "boolean" ? { overshootClamping: extra.overshootClamping } : null,
834
+ ...entry.delayMs ? { delay: entry.delayMs } : null
671
835
  };
672
836
  }
673
- var found = animationType ? animations[animationType] : {};
837
+ var bezier = (0, import_animation_helpers.easingToBezier)(entry.timing.easing);
674
838
  return {
675
- ...found,
676
- ...normalized.config,
677
- ...extraConf
839
+ type: "timing",
840
+ duration: entry.timing.durationMs,
841
+ ...bezier ? { easing: import_react_native.Easing.bezier(bezier[0], bezier[1], bezier[2], bezier[3]) } : null,
842
+ ...entry.delayMs ? { delay: entry.delayMs } : null
678
843
  };
679
844
  }
680
- var transformShorthands = {
681
- x: "translateX",
682
- y: "translateY",
683
- translateX: "x",
684
- translateY: "y"
845
+ var snapConfig = {
846
+ type: "timing",
847
+ duration: 0
685
848
  };
849
+ function getAnimationConfig(key, animations, transition) {
850
+ var animationState = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "default";
851
+ var resolved = (0, import_animation_helpers.forAnimationState)((0, import_animation_helpers.resolveTransition)(transition, { animations }), animationState);
852
+ var entry = (0, import_animation_helpers.getTransitionForKey)(resolved, key);
853
+ return entry ? entryToRN(entry) : snapConfig;
854
+ }
686
855
  function getValue(input) {
687
856
  var isColor = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
688
857
  if (typeof input !== "string") {