react-native-gtkx 0.3.0-alpha.1 → 0.4.0-alpha.2

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 (151) hide show
  1. package/README.md +1 -1
  2. package/dist/adw/index.d.ts +3 -2
  3. package/dist/adw/index.js +21 -4
  4. package/dist/adw/index.js.map +1 -1
  5. package/dist/adw/widgets.generated.d.ts +1 -1
  6. package/dist/adw/widgets.generated.js +2 -2
  7. package/dist/adw/widgets.generated.js.map +1 -1
  8. package/dist/animated/create-animated.d.ts +2 -0
  9. package/dist/animated/create-animated.js +2 -0
  10. package/dist/animated/create-animated.js.map +1 -1
  11. package/dist/animated/event.d.ts +15 -0
  12. package/dist/animated/event.js +80 -0
  13. package/dist/animated/event.js.map +1 -0
  14. package/dist/animated/index.d.ts +4 -0
  15. package/dist/animated/index.js +8 -0
  16. package/dist/animated/index.js.map +1 -1
  17. package/dist/animated/spring.d.ts +10 -0
  18. package/dist/animated/spring.js +20 -6
  19. package/dist/animated/spring.js.map +1 -1
  20. package/dist/animated/timing.d.ts +10 -0
  21. package/dist/animated/timing.js +21 -13
  22. package/dist/animated/timing.js.map +1 -1
  23. package/dist/apis/host.gtkx.js +70 -11
  24. package/dist/apis/host.gtkx.js.map +1 -1
  25. package/dist/common/navigation-stack.d.ts +6 -3
  26. package/dist/common/navigation-stack.js +8 -1
  27. package/dist/common/navigation-stack.js.map +1 -1
  28. package/dist/common/widget.js +2 -11
  29. package/dist/common/widget.js.map +1 -1
  30. package/dist/components/animated.d.ts +1 -0
  31. package/dist/components/animated.js +28 -4
  32. package/dist/components/animated.js.map +1 -1
  33. package/dist/components/app-registry.js +32 -8
  34. package/dist/components/app-registry.js.map +1 -1
  35. package/dist/components/request-animation-frame.d.ts +33 -0
  36. package/dist/components/request-animation-frame.js +83 -0
  37. package/dist/components/request-animation-frame.js.map +1 -0
  38. package/dist/components/scroll-view.js +60 -2
  39. package/dist/components/scroll-view.js.map +1 -1
  40. package/dist/components/virtualized-list.js +1 -4
  41. package/dist/components/virtualized-list.js.map +1 -1
  42. package/dist/dnd/autoscroll.d.ts +44 -0
  43. package/dist/dnd/autoscroll.js +176 -0
  44. package/dist/dnd/autoscroll.js.map +1 -0
  45. package/dist/dnd/grid-order.d.ts +45 -0
  46. package/dist/dnd/grid-order.js +151 -0
  47. package/dist/dnd/grid-order.js.map +1 -0
  48. package/dist/dnd/grid.d.ts +44 -0
  49. package/dist/dnd/grid.js +397 -0
  50. package/dist/dnd/grid.js.map +1 -0
  51. package/dist/dnd/gtk-controllers.d.ts +16 -2
  52. package/dist/dnd/gtk-controllers.js +23 -3
  53. package/dist/dnd/gtk-controllers.js.map +1 -1
  54. package/dist/dnd/index.d.ts +4 -2
  55. package/dist/dnd/index.js +9 -2
  56. package/dist/dnd/index.js.map +1 -1
  57. package/dist/dnd/order-state.d.ts +14 -0
  58. package/dist/dnd/order-state.js +55 -0
  59. package/dist/dnd/order-state.js.map +1 -0
  60. package/dist/dnd/order.d.ts +19 -0
  61. package/dist/dnd/order.js +19 -0
  62. package/dist/dnd/order.js.map +1 -1
  63. package/dist/dnd/sortable.d.ts +29 -4
  64. package/dist/dnd/sortable.js +308 -115
  65. package/dist/dnd/sortable.js.map +1 -1
  66. package/dist/dnd/types.d.ts +236 -14
  67. package/dist/dnd/types.js +30 -0
  68. package/dist/dnd/types.js.map +1 -1
  69. package/dist/gesture-handler-compat/attach-context.d.ts +29 -0
  70. package/dist/gesture-handler-compat/attach-context.js +90 -0
  71. package/dist/gesture-handler-compat/attach-context.js.map +1 -0
  72. package/dist/gesture-handler-compat/detector-runtime.d.ts +14 -3
  73. package/dist/gesture-handler-compat/detector-runtime.js +15 -5
  74. package/dist/gesture-handler-compat/detector-runtime.js.map +1 -1
  75. package/dist/gesture-handler-compat/detector.js +57 -2
  76. package/dist/gesture-handler-compat/detector.js.map +1 -1
  77. package/dist/gesture-handler-compat/gesture-state-manager.d.ts +5 -0
  78. package/dist/gesture-handler-compat/gesture-state-manager.js +77 -0
  79. package/dist/gesture-handler-compat/gesture-state-manager.js.map +1 -0
  80. package/dist/gesture-handler-compat/index.d.ts +2 -2
  81. package/dist/gesture-handler-compat/index.js +38 -33
  82. package/dist/gesture-handler-compat/index.js.map +1 -1
  83. package/dist/gesture-handler-compat/recognizer.d.ts +12 -1
  84. package/dist/gesture-handler-compat/recognizer.js +23 -9
  85. package/dist/gesture-handler-compat/recognizer.js.map +1 -1
  86. package/dist/gesture-handler-compat/tag-registry.d.ts +14 -0
  87. package/dist/gesture-handler-compat/tag-registry.js +19 -0
  88. package/dist/gesture-handler-compat/tag-registry.js.map +1 -0
  89. package/dist/globals/index.d.ts +47 -0
  90. package/dist/globals/index.js +181 -0
  91. package/dist/globals/index.js.map +1 -0
  92. package/dist/globals/install.d.ts +1 -0
  93. package/dist/globals/install.js +14 -0
  94. package/dist/globals/install.js.map +1 -0
  95. package/dist/gtkx/bridge/adw-namespace.d.ts +2 -0
  96. package/dist/gtkx/bridge/adw-namespace.js +26 -0
  97. package/dist/gtkx/bridge/adw-namespace.js.map +1 -0
  98. package/dist/gtkx/bridge/adw.d.ts +23 -0
  99. package/dist/gtkx/bridge/adw.js +93 -0
  100. package/dist/gtkx/bridge/adw.js.map +1 -0
  101. package/dist/gtkx/bridge/color-scheme-parse.d.ts +11 -0
  102. package/dist/gtkx/bridge/color-scheme-parse.js +42 -0
  103. package/dist/gtkx/bridge/color-scheme-parse.js.map +1 -0
  104. package/dist/gtkx/bridge/color-scheme-portal.d.ts +24 -0
  105. package/dist/gtkx/bridge/color-scheme-portal.js +172 -0
  106. package/dist/gtkx/bridge/color-scheme-portal.js.map +1 -0
  107. package/dist/gtkx/bridge/core.d.ts +25 -0
  108. package/dist/gtkx/bridge/core.js +69 -0
  109. package/dist/gtkx/bridge/core.js.map +1 -0
  110. package/dist/gtkx/bridge/drag-layer.d.ts +27 -0
  111. package/dist/gtkx/bridge/drag-layer.js +177 -0
  112. package/dist/gtkx/bridge/drag-layer.js.map +1 -0
  113. package/dist/gtkx/bridge/index.d.ts +1 -27
  114. package/dist/gtkx/bridge/index.js +12 -71
  115. package/dist/gtkx/bridge/index.js.map +1 -1
  116. package/dist/gtkx/bridge/widgets.generated.adw.d.ts +1 -0
  117. package/dist/gtkx/bridge/widgets.generated.adw.js +16 -0
  118. package/dist/gtkx/bridge/widgets.generated.adw.js.map +1 -0
  119. package/dist/gtkx/bridge/widgets.generated.d.ts +0 -1
  120. package/dist/gtkx/bridge/widgets.generated.js +3 -3
  121. package/dist/gtkx/bridge/widgets.generated.js.map +1 -1
  122. package/dist/index.js +20 -0
  123. package/dist/index.js.map +1 -1
  124. package/dist/mcp/data/generated.d.ts +41 -20
  125. package/dist/mcp/data/generated.js +46 -20
  126. package/dist/mcp/data/generated.js.map +1 -1
  127. package/dist/metro/index.d.ts +1 -0
  128. package/dist/metro/index.js +12 -0
  129. package/dist/metro/index.js.map +1 -1
  130. package/dist/navigation/sidebar.js +2 -45
  131. package/dist/navigation/sidebar.js.map +1 -1
  132. package/dist/reanimated-compat/animatable-value.d.ts +158 -0
  133. package/dist/reanimated-compat/animatable-value.js +316 -0
  134. package/dist/reanimated-compat/animatable-value.js.map +1 -0
  135. package/dist/reanimated-compat/animation.d.ts +34 -13
  136. package/dist/reanimated-compat/animation.js +97 -25
  137. package/dist/reanimated-compat/animation.js.map +1 -1
  138. package/dist/reanimated-compat/mutable.js +6 -6
  139. package/dist/reanimated-compat/mutable.js.map +1 -1
  140. package/dist/reanimated-compat/updater-animations.js +32 -12
  141. package/dist/reanimated-compat/updater-animations.js.map +1 -1
  142. package/dist/runner/host-dev.js +5 -1
  143. package/dist/runner/host-dev.js.map +1 -1
  144. package/dist/runner/host.js +9 -1
  145. package/dist/runner/host.js.map +1 -1
  146. package/dist/vite/index.js +130 -0
  147. package/dist/vite/index.js.map +1 -1
  148. package/package.json +1 -1
  149. package/dist/gtkx/bridge/theme.d.ts +0 -4
  150. package/dist/gtkx/bridge/theme.js +0 -5
  151. package/dist/gtkx/bridge/theme.js.map +0 -1
@@ -24,9 +24,27 @@
24
24
  // The spring row is not a tuning difference: RN's default has damping ratio
25
25
  // 0.5 and visibly bounces, Reanimated 4's is exactly critically damped and
26
26
  // does not. Every config below is therefore passed explicitly.
27
- import { createValueAnimation, } from "../animated/index";
27
+ import { AnimatedValue, createValueAnimation, } from "../animated/index";
28
+ import { animatableValueSignature, AnimatedShapeValue, assertAnimatableValue, createShapeValueAnimation, isAnimatableValue, springShapeMakeSteps, timingShapeMakeSteps, } from "./animatable-value";
28
29
  import { decayStep, resolveDecayConfig } from "./decay";
29
30
  import { Easing, resolveEasing } from "./easing";
31
+ /**
32
+ * Builds the right driver for `seed`'s type — the ONE place mutable.ts
33
+ * (a shared-value write) and updater-animations.ts (a key newly animating)
34
+ * both make this decision, so a number and a shape are dispatched the same
35
+ * way in both. Throws the same "not animatable" shape of error either module
36
+ * used to throw on its own number-only gate, widened to name what it got.
37
+ */
38
+ export const makeAnimationDriver = (api, seed, context) => {
39
+ if (typeof seed === "number") {
40
+ return new api.Value(seed);
41
+ }
42
+ if (isAnimatableValue(seed)) {
43
+ return new AnimatedShapeValue(seed);
44
+ }
45
+ throw new Error(`react-native-reanimated: ${context} can only be a number, or a plain object/array of numbers ` +
46
+ `(got ${typeof seed}). Colors and layout values cannot be animated on this platform yet — see docs/api.md.`);
47
+ };
30
48
  const MARKER = "__rnGtkxReanimatedAnimation";
31
49
  const mark = (spec) => Object.assign(spec, { [MARKER]: true });
32
50
  export const isAnimationSpec = (value) => typeof value === "object" &&
@@ -72,16 +90,20 @@ const DEFAULT_SPRING_DAMPING = 120;
72
90
  const DEFAULT_SPRING_DURATION = 550;
73
91
  const DEFAULT_SPRING_DAMPING_RATIO = 1;
74
92
  const DEFAULT_ENERGY_THRESHOLD = 6e-9;
75
- const assertAnimatable = (value, api) => {
76
- if (typeof value !== "number" || !Number.isFinite(value)) {
77
- throw new Error(`react-native-reanimated: ${api}() on this platform animates finite numbers only, got ${typeof value === "string" ? `"${value}"` : String(value)}. ` +
78
- "Colors and layout properties cannot be driven imperatively here yet — see docs/api.md.");
79
- }
80
- return value;
81
- };
93
+ /**
94
+ * The number-only gate this whole layer started with, widened to upstream's
95
+ * real `AnimatableValue` see animatable-value.ts's header for the
96
+ * transcription this widening is based on. A thin, generic-preserving
97
+ * wrapper: every `with*` builder below calls this exactly where it always
98
+ * called the number-only version.
99
+ */
100
+ const assertAnimatable = (value, api) => assertAnimatableValue(value, api);
82
101
  /**
83
102
  * Lets you animate a value over a duration with an easing curve. Assign the
84
- * result to a shared value to start it.
103
+ * result to a shared value to start it. `toValue` is upstream's
104
+ * `AnimatableValue`: a finite number, or a plain object/array whose leaves
105
+ * are — a colour string is not (that keeps the separate `interpolateColor`
106
+ * path, docs/api.md).
85
107
  */
86
108
  export const withTiming = (toValue, config, callback) => inInitialRun
87
109
  ? assertAnimatable(toValue, "withTiming")
@@ -91,7 +113,7 @@ export const withTiming = (toValue, config, callback) => inInitialRun
91
113
  config: config ?? {},
92
114
  callback,
93
115
  });
94
- /** Lets you animate a value with spring physics. */
116
+ /** Lets you animate a value with spring physics. See withTiming for `toValue`'s shape. */
95
117
  export const withSpring = (toValue, config, callback) => inInitialRun
96
118
  ? assertAnimatable(toValue, "withSpring")
97
119
  : mark({
@@ -391,9 +413,9 @@ const aimedAt = (spec, toValue) => {
391
413
  export const animationSignature = (spec) => {
392
414
  switch (spec.kind) {
393
415
  case "timing":
394
- return `timing(${spec.toValue},${spec.config.duration ?? ""})`;
416
+ return `timing(${animatableValueSignature(spec.toValue)},${spec.config.duration ?? ""})`;
395
417
  case "spring":
396
- return `spring(${spec.toValue})`;
418
+ return `spring(${animatableValueSignature(spec.toValue)})`;
397
419
  case "delay":
398
420
  return `delay(${spec.delayMs},${animationSignature(spec.animation)})`;
399
421
  case "sequence":
@@ -433,6 +455,42 @@ const reportingTo = (animation, callback, driver) => callback
433
455
  reset: () => animation.reset(),
434
456
  }
435
457
  : animation;
458
+ /**
459
+ * `withDecay`/`withClamp` stay number-only (they are not in the
460
+ * AnimatableValue widening — neither is a real upstream export a shape
461
+ * target would make sense for), so the driver reaching their branch of
462
+ * `buildAnimation` must already be a plain `AnimatedValue`. Asserted rather
463
+ * than assumed: a spec tree can only mix a number-only node with a
464
+ * shape-targeted one by construction that this platform's own generics do
465
+ * not rule out (`withSequence<T>` unifies `T` across a mixed array), so this
466
+ * is the same "fail loudly on a shape this driver was not built for" rule
467
+ * `zipAnimatableLeaves` applies to a mismatched target.
468
+ */
469
+ const asNumberDriver = (driver, api) => {
470
+ if (!(driver instanceof AnimatedValue)) {
471
+ throw new Error(`react-native-reanimated: ${api}() only animates a single number on this platform, but the shared value it is animating holds a shape (an object or array), not a number.`);
472
+ }
473
+ return driver;
474
+ };
475
+ /**
476
+ * The mirror of `asNumberDriver`: an object/array-targeted `withTiming`/
477
+ * `withSpring` needs the shared value it is animating to already hold a
478
+ * shape, not a plain number — the two do not upgrade into one another.
479
+ */
480
+ const asShapeDriver = (driver, api) => {
481
+ if (!(driver instanceof AnimatedShapeValue)) {
482
+ throw new Error(`react-native-reanimated: ${api}() was given an object/array target, but the shared value it is animating holds a plain number.`);
483
+ }
484
+ return driver;
485
+ };
486
+ /** Force-sets `driver` without going through an animation — the two driver kinds each expose their own `setValue`, narrowed by which one `driver` actually is. */
487
+ const setDriverValue = (driver, value) => {
488
+ if (driver instanceof AnimatedValue) {
489
+ driver.setValue(value);
490
+ return;
491
+ }
492
+ driver.setValue(value);
493
+ };
436
494
  const buildRepeat = (engine, driver, spec) => {
437
495
  let child = null;
438
496
  let cancelled = false;
@@ -465,7 +523,7 @@ const buildRepeat = (engine, driver, spec) => {
465
523
  else {
466
524
  // Replay: snap back to where the repeat began and run again,
467
525
  // which is what upstream's onStart(startValue) amounts to.
468
- driver.setValue(from);
526
+ setDriverValue(driver, from);
469
527
  }
470
528
  runIteration();
471
529
  });
@@ -490,16 +548,27 @@ export const buildAnimation = (engine, driver, spec) => {
490
548
  const { api, scheduler } = engine;
491
549
  const build = () => {
492
550
  switch (spec.kind) {
493
- case "timing":
494
- return api.timing(driver, {
495
- toValue: spec.toValue,
496
- duration: spec.config.duration ?? DEFAULT_TIMING_DURATION,
497
- easing: spec.config.easing
498
- ? resolveEasing(spec.config.easing)
499
- : defaultTimingEasing,
500
- });
501
- case "spring":
502
- return api.spring(driver, toPlatformSpringConfig(spec.config, spec.toValue, driver.__getValue()));
551
+ case "timing": {
552
+ const duration = spec.config.duration ?? DEFAULT_TIMING_DURATION;
553
+ const easing = spec.config.easing
554
+ ? resolveEasing(spec.config.easing)
555
+ : defaultTimingEasing;
556
+ if (typeof spec.toValue === "number") {
557
+ return api.timing(asNumberDriver(driver, "withTiming"), {
558
+ toValue: spec.toValue,
559
+ duration,
560
+ easing,
561
+ });
562
+ }
563
+ return createShapeValueAnimation(scheduler, asShapeDriver(driver, "withTiming"), timingShapeMakeSteps(spec.toValue, duration, easing));
564
+ }
565
+ case "spring": {
566
+ if (typeof spec.toValue === "number") {
567
+ const numberDriver = asNumberDriver(driver, "withSpring");
568
+ return api.spring(numberDriver, toPlatformSpringConfig(spec.config, spec.toValue, numberDriver.__getValue()));
569
+ }
570
+ return createShapeValueAnimation(scheduler, asShapeDriver(driver, "withSpring"), springShapeMakeSteps(spec.toValue, toPlatformSpringConfig, spec.config));
571
+ }
503
572
  case "delay":
504
573
  return api.sequence([
505
574
  api.delay(spec.delayMs),
@@ -510,9 +579,9 @@ export const buildAnimation = (engine, driver, spec) => {
510
579
  case "repeat":
511
580
  return buildRepeat(engine, driver, spec);
512
581
  case "decay":
513
- return createValueAnimation(scheduler, driver, decayStep(spec.config));
582
+ return createValueAnimation(scheduler, asNumberDriver(driver, "withDecay"), decayStep(spec.config));
514
583
  case "clamp":
515
- return buildClamp(engine, driver, spec);
584
+ return buildClamp(engine, asNumberDriver(driver, "withClamp"), spec);
516
585
  }
517
586
  };
518
587
  return reportingTo(build(), callbackOf(spec), driver);
@@ -526,6 +595,9 @@ export const buildAnimation = (engine, driver, spec) => {
526
595
  * inner animation is an ordinary one built by the same function.
527
596
  */
528
597
  const buildClamp = (engine, driver, spec) => {
598
+ // withClamp stays number-only (it is not part of this platform's
599
+ // AnimatableValue widening — see asNumberDriver), so `driver` here is
600
+ // always a plain AnimatedValue by construction.
529
601
  const inner = new engine.api.Value(driver.__getValue());
530
602
  inner.addListener(({ value }) => {
531
603
  const clipped = spec.max !== undefined && value > spec.max
@@ -1 +1 @@
1
- {"version":3,"file":"animation.js","sourceRoot":"","sources":["../../src/reanimated-compat/animation.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,6DAA6D;AAC7D,0EAA0E;AAC1E,0EAA0E;AAC1E,6EAA6E;AAC7E,2CAA2C;AAC3C,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,0EAA0E;AAC1E,mCAAmC;AACnC,EAAE;AACF,6EAA6E;AAC7E,oEAAoE;AACpE,wBAAwB;AACxB,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,+DAA+D;AAC/D,OAAO,EACL,oBAAoB,GAKrB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAwB,MAAM,SAAS,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,aAAa,EAAuB,MAAM,UAAU,CAAA;AAmFrE,MAAM,MAAM,GAAG,6BAA6B,CAAA;AAI5C,MAAM,IAAI,GAAG,CAAC,IAAmB,EAAc,EAAE,CAC/C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,IAAa,EAAE,CAAC,CAAA;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAc,EAA0B,EAAE,CACxE,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACb,KAAiC,CAAC,MAAM,CAAC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,IAAI,CAAC,GAAG;gBACV,CAAC,CAAC,KAAK,CAAA;QACb,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IACF,OAAO,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;AACtD,CAAC,CAAA","sourcesContent":["// `withTiming` / `withSpring` / `withDelay` / `withSequence` / `withRepeat`.\n//\n// Upstream types these as returning the animated type itself\n// (`withTiming(100)` is a `number`), because what starts the animation is\n// ASSIGNING the result to a shared value. The cast at each return mirrors\n// that trick rather than inventing a different API — see `mutable.ts`, which\n// recognises the descriptor in its setter.\n//\n// The descriptors are plain data. Turning one into a running animation is\n// `buildAnimation`, and it builds on the platform's own `src/animated/`\n// engine: same frame scheduler, same closed-form solvers, same preemption\n// rules. This layer adds no clock.\n//\n// It does NOT reuse `Animated.timing`/`Animated.spring`'s DEFAULTS, and that\n// distinction is load-bearing. Reanimated's defaults are materially\n// different animations:\n//\n// | config | RN Animated | Reanimated 4 |\n// | --------------- | ------------------------ | -------------------------- |\n// | timing duration | 500 ms | 300 ms |\n// | timing easing | inOut(ease) | inOut(quad) |\n// | spring | damping 10, mass 1, k 100 | damping 120, mass 4, k 900 |\n//\n// The spring row is not a tuning difference: RN's default has damping ratio\n// 0.5 and visibly bounces, Reanimated 4's is exactly critically damped and\n// does not. Every config below is therefore passed explicitly.\nimport {\n createValueAnimation,\n type AnimatedApi,\n type AnimatedValue,\n type CompositeAnimation,\n type FrameScheduler,\n} from \"../animated/index\"\nimport { decayStep, resolveDecayConfig, type WithDecayConfig } from \"./decay\"\nimport { Easing, resolveEasing, type EasingFunction } from \"./easing\"\n\n/** Called when an animation settles or is cancelled, as upstream. */\nexport type AnimationCallback = (finished?: boolean, current?: number) => void\n\nexport type WithTimingConfig = {\n duration?: number\n easing?: EasingFunction | { factory: () => EasingFunction }\n}\n\n/**\n * Upstream's config is a mutually exclusive union: either the physical\n * parameterisation (`stiffness`/`damping`) or the perceptual one\n * (`duration`/`dampingRatio`). Both are accepted here and normalised into the\n * physical one, which is what the platform's spring solver takes.\n */\nexport type WithSpringConfig = {\n mass?: number\n stiffness?: number\n damping?: number\n duration?: number\n dampingRatio?: number\n clamp?: { min?: number; max?: number }\n velocity?: number\n overshootClamping?: boolean\n energyThreshold?: number\n}\n\ntype TimingSpec = {\n kind: \"timing\"\n toValue: number\n config: WithTimingConfig\n callback?: AnimationCallback\n}\n\ntype SpringSpec = {\n kind: \"spring\"\n toValue: number\n config: WithSpringConfig\n callback?: AnimationCallback\n}\n\ntype DelaySpec = {\n kind: \"delay\"\n delayMs: number\n animation: AnimationSpec\n}\n\ntype SequenceSpec = {\n kind: \"sequence\"\n animations: AnimationSpec[]\n}\n\ntype RepeatSpec = {\n kind: \"repeat\"\n animation: AnimationSpec\n numberOfReps: number\n reverse: boolean\n callback?: AnimationCallback\n}\n\ntype DecaySpec = {\n kind: \"decay\"\n config: ReturnType<typeof resolveDecayConfig>\n callback?: AnimationCallback\n}\n\ntype ClampSpec = {\n kind: \"clamp\"\n min?: number\n max?: number\n animation: AnimationSpec\n}\n\nexport type AnimationSpec =\n | TimingSpec\n | SpringSpec\n | DelaySpec\n | SequenceSpec\n | RepeatSpec\n | DecaySpec\n | ClampSpec\n\nconst MARKER = \"__rnGtkxReanimatedAnimation\"\n\ntype MarkedSpec = AnimationSpec & { [MARKER]: true }\n\nconst mark = (spec: AnimationSpec): MarkedSpec =>\n Object.assign(spec, { [MARKER]: true as const })\n\nexport const isAnimationSpec = (value: unknown): value is AnimationSpec =>\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)[MARKER] === true\n\n// --- the initial run ----------------------------------------------------\n//\n// Upstream's `IN_STYLE_UPDATER`, and it is not a detail: the FIRST evaluation\n// of a `useDerivedValue`/`useAnimatedStyle`/`useAnimatedProps` updater has no\n// value to animate FROM, so every `with*` builder returns its target instead\n// of an animation. `defineAnimation` does it in one line —\n// `if (IN_STYLE_UPDATER.current) return starting` — and that line is what\n// makes the documented pattern\n//\n// const v = useDerivedValue(() => withSpring(active.value ? 1 : 0))\n//\n// work at all. Without it the shared value is SEEDED with the animation\n// object itself and every later write finds a value that is not a number.\n// Found by building `react-native-draggable-flatlist`, whose `ScaleDecorator`\n// is exactly that pattern (`hooks/useOnCellActiveAnimation.ts`).\nlet inInitialRun = false\n\n/**\n * Runs an updater in \"seed the value\" mode, where every animation collapses\n * to the value it would have finished at.\n */\nexport const initialUpdaterRun = <T>(updater: () => T): T => {\n inInitialRun = true\n try {\n return updater()\n } finally {\n inInitialRun = false\n }\n}\n\n// Upstream's own defaults, quoted in the table at the top of this file.\nconst DEFAULT_TIMING_DURATION = 300\nconst defaultTimingEasing = Easing.inOut(Easing.quad)\n\n// GentleSpringConfig + energyThreshold, react-native-reanimated 4.5.3\n// (src/animation/spring/springConfigs.ts).\nconst DEFAULT_SPRING_MASS = 4\nconst DEFAULT_SPRING_STIFFNESS = 900\nconst DEFAULT_SPRING_DAMPING = 120\nconst DEFAULT_SPRING_DURATION = 550\nconst DEFAULT_SPRING_DAMPING_RATIO = 1\nconst DEFAULT_ENERGY_THRESHOLD = 6e-9\n\nconst assertAnimatable = (value: unknown, api: string): number => {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new Error(\n `react-native-reanimated: ${api}() on this platform animates finite numbers only, got ${typeof value === \"string\" ? `\"${value}\"` : String(value)}. ` +\n \"Colors and layout properties cannot be driven imperatively here yet — see docs/api.md.\",\n )\n }\n return value\n}\n\n/**\n * Lets you animate a value over a duration with an easing curve. Assign the\n * result to a shared value to start it.\n */\nexport const withTiming = (\n toValue: number,\n config?: WithTimingConfig,\n callback?: AnimationCallback,\n): number =>\n inInitialRun\n ? assertAnimatable(toValue, \"withTiming\")\n : (mark({\n kind: \"timing\",\n toValue: assertAnimatable(toValue, \"withTiming\"),\n config: config ?? {},\n callback,\n }) as unknown as number)\n\n/** Lets you animate a value with spring physics. */\nexport const withSpring = (\n toValue: number,\n config?: WithSpringConfig,\n callback?: AnimationCallback,\n): number =>\n inInitialRun\n ? assertAnimatable(toValue, \"withSpring\")\n : (mark({\n kind: \"spring\",\n toValue: assertAnimatable(toValue, \"withSpring\"),\n config: config ?? {},\n callback,\n }) as unknown as number)\n\n/** Delays another animation by `delayMs`. */\nexport const withDelay = (delayMs: number, animation: number): number => {\n // Upstream's `starting` for every composite is the animation it wraps,\n // which the initial run has already collapsed to a plain value.\n if (inInitialRun) {\n return animation\n }\n if (!isAnimationSpec(animation)) {\n throw new Error(\n \"react-native-reanimated: withDelay() takes an animation, e.g. withDelay(500, withTiming(1))\",\n )\n }\n return mark({\n kind: \"delay\",\n delayMs,\n animation,\n }) as unknown as number\n}\n\n/** Runs animations one after another on the same shared value. */\nexport const withSequence = (...animations: number[]): number => {\n if (inInitialRun) {\n return animations[0] ?? 0\n }\n const specs: AnimationSpec[] = []\n for (const animation of animations) {\n if (!isAnimationSpec(animation)) {\n throw new Error(\n \"react-native-reanimated: withSequence() takes animations, e.g. withSequence(withTiming(1), withTiming(0))\",\n )\n }\n specs.push(animation)\n }\n return mark({ kind: \"sequence\", animations: specs }) as unknown as number\n}\n\n/**\n * Repeats an animation. `numberOfReps <= 0` repeats forever; `reverse` plays\n * every other repetition backwards.\n */\nexport const withRepeat = (\n animation: number,\n numberOfReps = 2,\n reverse = false,\n callback?: AnimationCallback,\n): number => {\n if (inInitialRun) {\n return animation\n }\n if (!isAnimationSpec(animation)) {\n throw new Error(\n \"react-native-reanimated: withRepeat() takes an animation, e.g. withRepeat(withTiming(1), 3)\",\n )\n }\n return mark({\n kind: \"repeat\",\n animation,\n numberOfReps,\n reverse,\n callback,\n }) as unknown as number\n}\n\n/**\n * Coasts to a stop from an initial velocity — the release half of a fling.\n * Unlike every other animation here it has no target: where it lands is the\n * result of the velocity and the friction, which is exactly what makes it the\n * one an inertial gesture needs.\n *\n * ```tsx\n * onPanResponderRelease: (_, g) => {\n * x.value = withDecay({ velocity: g.vx * 1000, clamp: [0, width] })\n * }\n * ```\n *\n * `velocity` is in units per SECOND, as upstream — `PanResponder`'s\n * `gestureState.vx` is per millisecond, so it wants the ×1000 above.\n */\nexport const withDecay = (\n config?: WithDecayConfig,\n callback?: AnimationCallback,\n): number =>\n inInitialRun\n ? // Upstream seeds a decay with 0: it has no target to collapse to.\n 0\n : (mark({\n kind: \"decay\",\n config: resolveDecayConfig(config),\n callback,\n }) as unknown as number)\n\n/**\n * Confines another animation to a range: the inner animation runs its own\n * un-truncated course and what reaches the value is clipped to `[min, max]`.\n * That distinction is upstream's and it is observable — a spring clamped at\n * 100 that would have overshot to 120 sits at 100 and then comes back down,\n * rather than settling at 100 the moment it first arrives.\n */\nexport const withClamp = (\n config: { min?: number; max?: number },\n animation: number,\n): number => {\n if (inInitialRun) {\n return animation\n }\n if (!isAnimationSpec(animation)) {\n throw new Error(\n \"react-native-reanimated: withClamp() takes an animation, e.g. withClamp({ min: 0 }, withSpring(1))\",\n )\n }\n if (\n config.min !== undefined &&\n config.max !== undefined &&\n config.max < config.min\n ) {\n throw new Error(\n `react-native-reanimated: withClamp() was given min ${config.min} above max ${config.max}.`,\n )\n }\n return mark({\n kind: \"clamp\",\n min: config.min,\n max: config.max,\n animation,\n }) as unknown as number\n}\n\nexport type { WithDecayConfig } from \"./decay\"\n\n// --- spring config normalisation ----------------------------------------\n\nconst bisect = (\n min: number,\n max: number,\n fn: (x: number) => number,\n precision: number,\n maxIterations = 100,\n): number => {\n let low = min\n let high = max\n const direction = fn(high) >= fn(low) ? 1 : -1\n let current = (low + high) / 2\n for (let i = 0; i < maxIterations && Math.abs(fn(current)) > precision; i++) {\n if (fn(current) * direction < 0) {\n low = current\n } else {\n high = current\n }\n current = (low + high) / 2\n }\n return current\n}\n\nconst energyOf = (\n displacement: number,\n velocity: number,\n stiffness: number,\n mass: number,\n): number => 0.5 * stiffness * displacement ** 2 + 0.5 * mass * velocity ** 2\n\n/**\n * Solves for the stiffness whose settling time matches a requested perceptual\n * duration, by bisection on the fraction of the initial energy left after\n * 1.5 × that duration. Ported from upstream's\n * `calculateNewStiffnessToMatchDuration` — the perceptual-duration spring is\n * a Reanimated concept with no RN equivalent, so there is nothing on the\n * platform side to reuse.\n */\nconst stiffnessForDuration = (\n x0: number,\n v0: number,\n durationMs: number,\n dampingRatio: number,\n mass: number,\n energyThreshold: number,\n): number => {\n const PERCEPTUAL_COEFFICIENT = 1.5\n const settlingSeconds = (durationMs * PERCEPTUAL_COEFFICIENT) / 1000\n const initialEnergyFor = (stiffness: number): number =>\n energyOf(x0, v0, stiffness, mass)\n\n const energyFractionLeft = (stiffness: number): number => {\n const decay = Math.sqrt(stiffness / mass) * dampingRatio\n const envelope = Math.exp(-decay * settlingSeconds)\n const displacement = (x0 + (v0 + x0 * decay) * settlingSeconds) * envelope\n const velocity = displacement * -decay + (v0 + x0 * decay) * envelope\n const initial = initialEnergyFor(stiffness)\n if (initial === 0) {\n return -energyThreshold\n }\n return (\n energyOf(displacement, velocity, stiffness, mass) / initial -\n energyThreshold\n )\n }\n\n return bisect(\n Number.EPSILON,\n // Upstream's bound: even an 8 ms spring stays under 2e3, with margin.\n 8e3,\n energyFractionLeft,\n energyThreshold * 1e-3,\n )\n}\n\n/**\n * Keeps the overshoot inside `clamp` by raising the damping ratio, using\n * upstream's approximation: the first two extrema of a damped oscillation sit\n * at `exp(-zeta * PI)` and `exp(-zeta * 2 * PI)` of the initial displacement,\n * so the zeta that puts them on the bound is a logarithm away.\n */\nconst zetaForClamp = (\n zeta: number,\n startDisplacement: number,\n toValue: number,\n clamp: { min?: number; max?: number },\n): number => {\n if (startDisplacement === 0) {\n return zeta\n }\n const [firstBound, secondBound] =\n startDisplacement <= 0 ? [clamp.min, clamp.max] : [clamp.max, clamp.min]\n const candidates = [zeta]\n if (secondBound !== undefined) {\n const extremum = Math.abs((secondBound - toValue) / startDisplacement)\n candidates.push(Math.abs(Math.log(extremum) / Math.PI))\n }\n if (firstBound !== undefined) {\n const extremum = Math.abs((firstBound - toValue) / startDisplacement)\n candidates.push(Math.abs(Math.log(extremum) / (2 * Math.PI)))\n }\n // Bigger zeta means smaller bounces, so the strictest candidate wins.\n return Math.max(...candidates)\n}\n\ntype PlatformSpringConfig = {\n toValue: number\n mass: number\n stiffness: number\n damping: number\n initialVelocity: number\n overshootClamping: boolean\n restDisplacementThreshold: number\n restSpeedThreshold: number\n}\n\n/**\n * Turns a Reanimated spring config into the platform solver's config.\n *\n * The rest condition is the one place the two genuinely differ. Upstream\n * stops when the oscillator's remaining energy falls to `energyThreshold` of\n * its initial energy — a RELATIVE criterion; the platform's solver stops on\n * absolute displacement and speed thresholds. Rather than accept RN's\n * absolute defaults (which would end a 400px spring at a different point than\n * a 4px one), the thresholds are derived per animation from the same energy\n * budget, so the stopping point tracks upstream's to well under a pixel.\n */\nexport const toPlatformSpringConfig = (\n config: WithSpringConfig,\n toValue: number,\n from: number,\n): PlatformSpringConfig => {\n const mass = config.mass ?? DEFAULT_SPRING_MASS\n const velocity = config.velocity ?? 0\n const energyThreshold = config.energyThreshold ?? DEFAULT_ENERGY_THRESHOLD\n const useDuration =\n config.duration !== undefined || config.dampingRatio !== undefined\n\n const displacement = from - toValue\n\n let stiffness: number\n let zeta: number\n if (useDuration) {\n const duration = config.duration ?? DEFAULT_SPRING_DURATION\n zeta = config.dampingRatio ?? DEFAULT_SPRING_DAMPING_RATIO\n stiffness =\n duration <= 0\n ? Number.POSITIVE_INFINITY\n : stiffnessForDuration(\n displacement,\n velocity,\n duration,\n zeta,\n mass,\n energyThreshold,\n )\n } else {\n stiffness = config.stiffness ?? DEFAULT_SPRING_STIFFNESS\n const damping = config.damping ?? DEFAULT_SPRING_DAMPING\n zeta = damping / (2 * Math.sqrt(stiffness * mass))\n }\n\n if (config.clamp) {\n zeta = zetaForClamp(zeta, displacement, toValue, config.clamp)\n }\n\n // A zero/degenerate duration means \"be there already\"; the platform solver\n // rejects a non-finite stiffness, so collapse it to a 0 ms timing instead.\n const resolvedStiffness = Number.isFinite(stiffness)\n ? Math.max(stiffness, Number.EPSILON)\n : 1e6\n\n const initialEnergy = energyOf(\n displacement,\n velocity,\n resolvedStiffness,\n mass,\n )\n const restEnergy = energyThreshold * initialEnergy\n\n return {\n toValue,\n mass,\n stiffness: resolvedStiffness,\n damping: Math.max(\n zeta * 2 * Math.sqrt(resolvedStiffness * mass),\n Number.EPSILON,\n ),\n initialVelocity: velocity,\n overshootClamping: config.overshootClamping ?? false,\n // Semi-axes of the energy ellipse: |x| where all the remaining energy is\n // potential, |v| where all of it is kinetic. A spring at rest is inside\n // both.\n restDisplacementThreshold: Math.max(\n Math.sqrt((2 * restEnergy) / resolvedStiffness),\n Number.MIN_VALUE,\n ),\n restSpeedThreshold: Math.max(\n Math.sqrt((2 * restEnergy) / mass),\n Number.MIN_VALUE,\n ),\n }\n}\n\n// --- building a running animation ---------------------------------------\n\n/**\n * The last value an animation aims at, used by `withRepeat`'s reverse and by\n * `updater-animations.ts` to seed a key that is animating for the first time.\n */\nexport const targetOf = (spec: AnimationSpec): number | null => {\n switch (spec.kind) {\n case \"timing\":\n case \"spring\":\n return spec.toValue\n case \"delay\":\n return targetOf(spec.animation)\n case \"sequence\": {\n const last = spec.animations[spec.animations.length - 1]\n return last ? targetOf(last) : null\n }\n case \"repeat\":\n return targetOf(spec.animation)\n case \"clamp\":\n return targetOf(spec.animation)\n // A decay has no target by construction — where it lands is the result\n // rather than the input. `withRepeat(withDecay(...))` therefore replays\n // from the same origin rather than ping-ponging between two.\n case \"decay\":\n return null\n }\n}\n\n/** A copy of `spec` aimed at `toValue`, for a reversed repetition. */\nconst aimedAt = (spec: AnimationSpec, toValue: number): AnimationSpec => {\n switch (spec.kind) {\n case \"timing\":\n case \"spring\":\n return { ...spec, toValue }\n case \"delay\":\n return { ...spec, animation: aimedAt(spec.animation, toValue) }\n case \"sequence\": {\n const animations = [...spec.animations]\n const lastIndex = animations.length - 1\n const last = animations[lastIndex]\n if (last) {\n animations[lastIndex] = aimedAt(last, toValue)\n }\n return { ...spec, animations }\n }\n case \"repeat\":\n return { ...spec, animation: aimedAt(spec.animation, toValue) }\n case \"clamp\":\n return { ...spec, animation: aimedAt(spec.animation, toValue) }\n // Nothing to re-aim: see targetOf.\n case \"decay\":\n return spec\n }\n}\n\n/**\n * What makes two descriptors the SAME animation, for a caller that gets a\n * freshly built one on every evaluation and must decide whether to restart.\n *\n * The target and the shape, not object identity and not the whole config: a\n * mapper re-runs whenever anything it read changed, so `withSpring(open.value\n * ? 320 : 0)` produces a new object many times a second while asking for the\n * same animation every time. Config fields that change WHERE the animation\n * ends are in (a `duration`, a decay's `velocity`); ones that only change how\n * it gets there are not, because re-aiming a running animation at the value it\n * is already aimed at is a no-op that costs a restart.\n */\nexport const animationSignature = (spec: AnimationSpec): string => {\n switch (spec.kind) {\n case \"timing\":\n return `timing(${spec.toValue},${spec.config.duration ?? \"\"})`\n case \"spring\":\n return `spring(${spec.toValue})`\n case \"delay\":\n return `delay(${spec.delayMs},${animationSignature(spec.animation)})`\n case \"sequence\":\n return `sequence(${spec.animations.map(animationSignature).join(\";\")})`\n case \"repeat\":\n return `repeat(${spec.numberOfReps},${spec.reverse},${animationSignature(spec.animation)})`\n case \"clamp\":\n return `clamp(${spec.min},${spec.max},${animationSignature(spec.animation)})`\n // A decay has no target (targetOf), so its identity is the push it was\n // given: a new flick is a new animation, the same flick is not.\n case \"decay\":\n return `decay(${spec.config.velocity},${spec.config.deceleration})`\n }\n}\n\nconst callbackOf = (spec: AnimationSpec): AnimationCallback | undefined =>\n spec.kind === \"timing\" ||\n spec.kind === \"spring\" ||\n spec.kind === \"repeat\" ||\n spec.kind === \"decay\"\n ? spec.callback\n : undefined\n\n/**\n * Fires the descriptor's own callback when its animation settles — including\n * when it is cancelled, which reports `finished: false`, as upstream does.\n * Every node carries one, so the per-child callbacks of a `withSequence` and\n * the per-repetition callbacks of a `withRepeat` fire without the caller\n * having to unpick the tree.\n */\nconst reportingTo = (\n animation: CompositeAnimation,\n callback: AnimationCallback | undefined,\n driver: AnimatedValue,\n): CompositeAnimation =>\n callback\n ? {\n start: (onEnd) => {\n animation.start((result) => {\n callback(result.finished, driver.__getValue())\n onEnd?.(result)\n })\n },\n stop: () => animation.stop(),\n reset: () => animation.reset(),\n }\n : animation\n\n/**\n * What a descriptor needs to become a running animation: the platform's\n * Animated api for the animations it already has, and the frame scheduler\n * behind it for the one it does not (`withDecay` — see decay.ts). Both come\n * from the same place, so there is still exactly one clock under this layer.\n */\nexport type AnimationEngine = {\n api: AnimatedApi\n scheduler: FrameScheduler\n}\n\nconst buildRepeat = (\n engine: AnimationEngine,\n driver: AnimatedValue,\n spec: RepeatSpec,\n): CompositeAnimation => {\n let child: CompositeAnimation | null = null\n let cancelled = false\n\n return {\n start(onEnd) {\n cancelled = false\n const origin = driver.__getValue()\n let from = origin\n let to = targetOf(spec.animation) ?? origin\n let completed = 0\n\n const runIteration = (): void => {\n child = buildAnimation(engine, driver, aimedAt(spec.animation, to))\n child.start((result) => {\n if (cancelled || !result.finished) {\n onEnd?.(result)\n return\n }\n completed += 1\n if (spec.numberOfReps > 0 && completed >= spec.numberOfReps) {\n onEnd?.({ finished: true })\n return\n }\n if (spec.reverse) {\n // Ping-pong: the value is already at `to`, so the next\n // repetition simply aims back at where this one started.\n const previousTarget = to\n to = from\n from = previousTarget\n } else {\n // Replay: snap back to where the repeat began and run again,\n // which is what upstream's onStart(startValue) amounts to.\n driver.setValue(from)\n }\n runIteration()\n })\n }\n\n runIteration()\n },\n stop() {\n cancelled = true\n child?.stop()\n },\n reset() {\n child?.reset()\n },\n }\n}\n\n/**\n * Turns a descriptor into a running animation on `driver`. Every leaf is one\n * of the platform's own animations, so the whole tree runs off the single\n * injected frame scheduler.\n */\nexport const buildAnimation = (\n engine: AnimationEngine,\n driver: AnimatedValue,\n spec: AnimationSpec,\n): CompositeAnimation => {\n const { api, scheduler } = engine\n const build = (): CompositeAnimation => {\n switch (spec.kind) {\n case \"timing\":\n return api.timing(driver, {\n toValue: spec.toValue,\n duration: spec.config.duration ?? DEFAULT_TIMING_DURATION,\n easing: spec.config.easing\n ? resolveEasing(spec.config.easing)\n : defaultTimingEasing,\n })\n case \"spring\":\n return api.spring(\n driver,\n toPlatformSpringConfig(\n spec.config,\n spec.toValue,\n driver.__getValue(),\n ),\n )\n case \"delay\":\n return api.sequence([\n api.delay(spec.delayMs),\n buildAnimation(engine, driver, spec.animation),\n ])\n case \"sequence\":\n return api.sequence(\n spec.animations.map((child) => buildAnimation(engine, driver, child)),\n )\n case \"repeat\":\n return buildRepeat(engine, driver, spec)\n case \"decay\":\n return createValueAnimation(scheduler, driver, decayStep(spec.config))\n case \"clamp\":\n return buildClamp(engine, driver, spec)\n }\n }\n return reportingTo(build(), callbackOf(spec), driver)\n}\n\n/**\n * `withClamp` in full: the inner animation is built on a PRIVATE value and\n * what that value publishes is clipped onto the real driver. Running it\n * un-truncated is the whole behaviour — upstream keeps the clamped animation's\n * own `current` unbounded for exactly this reason — and the private node costs\n * one listener, no extra frame subscription and no second clock, because the\n * inner animation is an ordinary one built by the same function.\n */\nconst buildClamp = (\n engine: AnimationEngine,\n driver: AnimatedValue,\n spec: ClampSpec,\n): CompositeAnimation => {\n const inner = new engine.api.Value(driver.__getValue())\n inner.addListener(({ value }) => {\n const clipped =\n spec.max !== undefined && value > spec.max\n ? spec.max\n : spec.min !== undefined && value < spec.min\n ? spec.min\n : value\n driver.__updateValue(clipped)\n })\n return buildAnimation(engine, inner, spec.animation)\n}\n"]}
1
+ {"version":3,"file":"animation.js","sourceRoot":"","sources":["../../src/reanimated-compat/animation.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,6DAA6D;AAC7D,0EAA0E;AAC1E,0EAA0E;AAC1E,6EAA6E;AAC7E,2CAA2C;AAC3C,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,0EAA0E;AAC1E,mCAAmC;AACnC,EAAE;AACF,6EAA6E;AAC7E,oEAAoE;AACpE,wBAAwB;AACxB,EAAE;AACF,gFAAgF;AA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C,GAAG,KAAK,SAAS,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG;gBAC1C,CAAC,CAAC,IAAI,CAAC,GAAG;gBACV,CAAC,CAAC,KAAK,CAAA;QACb,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IACF,OAAO,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;AACtD,CAAC,CAAA","sourcesContent":["// `withTiming` / `withSpring` / `withDelay` / `withSequence` / `withRepeat`.\n//\n// Upstream types these as returning the animated type itself\n// (`withTiming(100)` is a `number`), because what starts the animation is\n// ASSIGNING the result to a shared value. The cast at each return mirrors\n// that trick rather than inventing a different API — see `mutable.ts`, which\n// recognises the descriptor in its setter.\n//\n// The descriptors are plain data. Turning one into a running animation is\n// `buildAnimation`, and it builds on the platform's own `src/animated/`\n// engine: same frame scheduler, same closed-form solvers, same preemption\n// rules. This layer adds no clock.\n//\n// It does NOT reuse `Animated.timing`/`Animated.spring`'s DEFAULTS, and that\n// distinction is load-bearing. Reanimated's defaults are materially\n// different animations:\n//\n// | config | RN Animated | Reanimated 4 |\n// | --------------- | ------------------------ | -------------------------- |\n// | timing duration | 500 ms | 300 ms |\n// | timing easing | inOut(ease) | inOut(quad) |\n// | spring | damping 10, mass 1, k 100 | damping 120, mass 4, k 900 |\n//\n// The spring row is not a tuning difference: RN's default has damping ratio\n// 0.5 and visibly bounces, Reanimated 4's is exactly critically damped and\n// does not. Every config below is therefore passed explicitly.\nimport {\n AnimatedValue,\n createValueAnimation,\n type AnimatedApi,\n type CompositeAnimation,\n type FrameScheduler,\n} from \"../animated/index\"\nimport {\n animatableValueSignature,\n AnimatedShapeValue,\n assertAnimatableValue,\n createShapeValueAnimation,\n isAnimatableValue,\n springShapeMakeSteps,\n timingShapeMakeSteps,\n type AnimatableValue,\n} from \"./animatable-value\"\nimport { decayStep, resolveDecayConfig, type WithDecayConfig } from \"./decay\"\nimport { Easing, resolveEasing, type EasingFunction } from \"./easing\"\n\nexport type {\n AnimatableArray,\n AnimatableObject,\n AnimatableValue,\n} from \"./animatable-value\"\n\n/** Called when an animation settles or is cancelled, as upstream. */\nexport type AnimationCallback = (\n finished?: boolean,\n current?: AnimatableValue,\n) => void\n\n/**\n * What every animation in this layer runs on: a single-number `AnimatedValue`\n * for a number target, or an `AnimatedShapeValue` (animatable-value.ts) for\n * an object/array one — the SAME driver a spec was built against throughout\n * its whole tree (a `withSequence`'s steps, a `withRepeat`'s iterations),\n * because the driver IS the value being animated, not a detail of one step.\n */\nexport type AnimationDriver = AnimatedValue | AnimatedShapeValue\n\n/**\n * Builds the right driver for `seed`'s type — the ONE place mutable.ts\n * (a shared-value write) and updater-animations.ts (a key newly animating)\n * both make this decision, so a number and a shape are dispatched the same\n * way in both. Throws the same \"not animatable\" shape of error either module\n * used to throw on its own number-only gate, widened to name what it got.\n */\nexport const makeAnimationDriver = (\n api: AnimatedApi,\n seed: unknown,\n context: string,\n): AnimationDriver => {\n if (typeof seed === \"number\") {\n return new api.Value(seed)\n }\n if (isAnimatableValue(seed)) {\n return new AnimatedShapeValue(seed)\n }\n throw new Error(\n `react-native-reanimated: ${context} can only be a number, or a plain object/array of numbers ` +\n `(got ${typeof seed}). Colors and layout values cannot be animated on this platform yet — see docs/api.md.`,\n )\n}\n\nexport type WithTimingConfig = {\n duration?: number\n easing?: EasingFunction | { factory: () => EasingFunction }\n}\n\n/**\n * Upstream's config is a mutually exclusive union: either the physical\n * parameterisation (`stiffness`/`damping`) or the perceptual one\n * (`duration`/`dampingRatio`). Both are accepted here and normalised into the\n * physical one, which is what the platform's spring solver takes.\n */\nexport type WithSpringConfig = {\n mass?: number\n stiffness?: number\n damping?: number\n duration?: number\n dampingRatio?: number\n clamp?: { min?: number; max?: number }\n velocity?: number\n overshootClamping?: boolean\n energyThreshold?: number\n}\n\ntype TimingSpec = {\n kind: \"timing\"\n toValue: AnimatableValue\n config: WithTimingConfig\n callback?: AnimationCallback\n}\n\ntype SpringSpec = {\n kind: \"spring\"\n toValue: AnimatableValue\n config: WithSpringConfig\n callback?: AnimationCallback\n}\n\ntype DelaySpec = {\n kind: \"delay\"\n delayMs: number\n animation: AnimationSpec\n}\n\ntype SequenceSpec = {\n kind: \"sequence\"\n animations: AnimationSpec[]\n}\n\ntype RepeatSpec = {\n kind: \"repeat\"\n animation: AnimationSpec\n numberOfReps: number\n reverse: boolean\n callback?: AnimationCallback\n}\n\ntype DecaySpec = {\n kind: \"decay\"\n config: ReturnType<typeof resolveDecayConfig>\n callback?: AnimationCallback\n}\n\ntype ClampSpec = {\n kind: \"clamp\"\n min?: number\n max?: number\n animation: AnimationSpec\n}\n\nexport type AnimationSpec =\n | TimingSpec\n | SpringSpec\n | DelaySpec\n | SequenceSpec\n | RepeatSpec\n | DecaySpec\n | ClampSpec\n\nconst MARKER = \"__rnGtkxReanimatedAnimation\"\n\ntype MarkedSpec = AnimationSpec & { [MARKER]: true }\n\nconst mark = (spec: AnimationSpec): MarkedSpec =>\n Object.assign(spec, { [MARKER]: true as const })\n\nexport const isAnimationSpec = (value: unknown): value is AnimationSpec =>\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)[MARKER] === true\n\n// --- the initial run ----------------------------------------------------\n//\n// Upstream's `IN_STYLE_UPDATER`, and it is not a detail: the FIRST evaluation\n// of a `useDerivedValue`/`useAnimatedStyle`/`useAnimatedProps` updater has no\n// value to animate FROM, so every `with*` builder returns its target instead\n// of an animation. `defineAnimation` does it in one line —\n// `if (IN_STYLE_UPDATER.current) return starting` — and that line is what\n// makes the documented pattern\n//\n// const v = useDerivedValue(() => withSpring(active.value ? 1 : 0))\n//\n// work at all. Without it the shared value is SEEDED with the animation\n// object itself and every later write finds a value that is not a number.\n// Found by building `react-native-draggable-flatlist`, whose `ScaleDecorator`\n// is exactly that pattern (`hooks/useOnCellActiveAnimation.ts`).\nlet inInitialRun = false\n\n/**\n * Runs an updater in \"seed the value\" mode, where every animation collapses\n * to the value it would have finished at.\n */\nexport const initialUpdaterRun = <T>(updater: () => T): T => {\n inInitialRun = true\n try {\n return updater()\n } finally {\n inInitialRun = false\n }\n}\n\n// Upstream's own defaults, quoted in the table at the top of this file.\nconst DEFAULT_TIMING_DURATION = 300\nconst defaultTimingEasing = Easing.inOut(Easing.quad)\n\n// GentleSpringConfig + energyThreshold, react-native-reanimated 4.5.3\n// (src/animation/spring/springConfigs.ts).\nconst DEFAULT_SPRING_MASS = 4\nconst DEFAULT_SPRING_STIFFNESS = 900\nconst DEFAULT_SPRING_DAMPING = 120\nconst DEFAULT_SPRING_DURATION = 550\nconst DEFAULT_SPRING_DAMPING_RATIO = 1\nconst DEFAULT_ENERGY_THRESHOLD = 6e-9\n\n/**\n * The number-only gate this whole layer started with, widened to upstream's\n * real `AnimatableValue` — see animatable-value.ts's header for the\n * transcription this widening is based on. A thin, generic-preserving\n * wrapper: every `with*` builder below calls this exactly where it always\n * called the number-only version.\n */\nconst assertAnimatable = <T extends AnimatableValue>(\n value: T,\n api: string,\n): T => assertAnimatableValue(value, api)\n\n/**\n * Lets you animate a value over a duration with an easing curve. Assign the\n * result to a shared value to start it. `toValue` is upstream's\n * `AnimatableValue`: a finite number, or a plain object/array whose leaves\n * are — a colour string is not (that keeps the separate `interpolateColor`\n * path, docs/api.md).\n */\nexport const withTiming = <T extends AnimatableValue>(\n toValue: T,\n config?: WithTimingConfig,\n callback?: AnimationCallback,\n): T =>\n inInitialRun\n ? assertAnimatable(toValue, \"withTiming\")\n : (mark({\n kind: \"timing\",\n toValue: assertAnimatable(toValue, \"withTiming\"),\n config: config ?? {},\n callback,\n }) as unknown as T)\n\n/** Lets you animate a value with spring physics. See withTiming for `toValue`'s shape. */\nexport const withSpring = <T extends AnimatableValue>(\n toValue: T,\n config?: WithSpringConfig,\n callback?: AnimationCallback,\n): T =>\n inInitialRun\n ? assertAnimatable(toValue, \"withSpring\")\n : (mark({\n kind: \"spring\",\n toValue: assertAnimatable(toValue, \"withSpring\"),\n config: config ?? {},\n callback,\n }) as unknown as T)\n\n/** Delays another animation by `delayMs`. */\nexport const withDelay = <T extends AnimatableValue>(\n delayMs: number,\n animation: T,\n): T => {\n // Upstream's `starting` for every composite is the animation it wraps,\n // which the initial run has already collapsed to a plain value.\n if (inInitialRun) {\n return animation\n }\n if (!isAnimationSpec(animation)) {\n throw new Error(\n \"react-native-reanimated: withDelay() takes an animation, e.g. withDelay(500, withTiming(1))\",\n )\n }\n return mark({\n kind: \"delay\",\n delayMs,\n animation,\n }) as unknown as T\n}\n\n/** Runs animations one after another on the same shared value. */\nexport const withSequence = <T extends AnimatableValue>(\n ...animations: T[]\n): T => {\n if (inInitialRun) {\n return animations[0] ?? (0 as T)\n }\n const specs: AnimationSpec[] = []\n for (const animation of animations) {\n if (!isAnimationSpec(animation)) {\n throw new Error(\n \"react-native-reanimated: withSequence() takes animations, e.g. withSequence(withTiming(1), withTiming(0))\",\n )\n }\n specs.push(animation)\n }\n return mark({ kind: \"sequence\", animations: specs }) as unknown as T\n}\n\n/**\n * Repeats an animation. `numberOfReps <= 0` repeats forever; `reverse` plays\n * every other repetition backwards.\n */\nexport const withRepeat = <T extends AnimatableValue>(\n animation: T,\n numberOfReps = 2,\n reverse = false,\n callback?: AnimationCallback,\n): T => {\n if (inInitialRun) {\n return animation\n }\n if (!isAnimationSpec(animation)) {\n throw new Error(\n \"react-native-reanimated: withRepeat() takes an animation, e.g. withRepeat(withTiming(1), 3)\",\n )\n }\n return mark({\n kind: \"repeat\",\n animation,\n numberOfReps,\n reverse,\n callback,\n }) as unknown as T\n}\n\n/**\n * Coasts to a stop from an initial velocity — the release half of a fling.\n * Unlike every other animation here it has no target: where it lands is the\n * result of the velocity and the friction, which is exactly what makes it the\n * one an inertial gesture needs.\n *\n * ```tsx\n * onPanResponderRelease: (_, g) => {\n * x.value = withDecay({ velocity: g.vx * 1000, clamp: [0, width] })\n * }\n * ```\n *\n * `velocity` is in units per SECOND, as upstream — `PanResponder`'s\n * `gestureState.vx` is per millisecond, so it wants the ×1000 above.\n */\nexport const withDecay = (\n config?: WithDecayConfig,\n callback?: AnimationCallback,\n): number =>\n inInitialRun\n ? // Upstream seeds a decay with 0: it has no target to collapse to.\n 0\n : (mark({\n kind: \"decay\",\n config: resolveDecayConfig(config),\n callback,\n }) as unknown as number)\n\n/**\n * Confines another animation to a range: the inner animation runs its own\n * un-truncated course and what reaches the value is clipped to `[min, max]`.\n * That distinction is upstream's and it is observable — a spring clamped at\n * 100 that would have overshot to 120 sits at 100 and then comes back down,\n * rather than settling at 100 the moment it first arrives.\n */\nexport const withClamp = (\n config: { min?: number; max?: number },\n animation: number,\n): number => {\n if (inInitialRun) {\n return animation\n }\n if (!isAnimationSpec(animation)) {\n throw new Error(\n \"react-native-reanimated: withClamp() takes an animation, e.g. withClamp({ min: 0 }, withSpring(1))\",\n )\n }\n if (\n config.min !== undefined &&\n config.max !== undefined &&\n config.max < config.min\n ) {\n throw new Error(\n `react-native-reanimated: withClamp() was given min ${config.min} above max ${config.max}.`,\n )\n }\n return mark({\n kind: \"clamp\",\n min: config.min,\n max: config.max,\n animation,\n }) as unknown as number\n}\n\nexport type { WithDecayConfig } from \"./decay\"\n\n// --- spring config normalisation ----------------------------------------\n\nconst bisect = (\n min: number,\n max: number,\n fn: (x: number) => number,\n precision: number,\n maxIterations = 100,\n): number => {\n let low = min\n let high = max\n const direction = fn(high) >= fn(low) ? 1 : -1\n let current = (low + high) / 2\n for (let i = 0; i < maxIterations && Math.abs(fn(current)) > precision; i++) {\n if (fn(current) * direction < 0) {\n low = current\n } else {\n high = current\n }\n current = (low + high) / 2\n }\n return current\n}\n\nconst energyOf = (\n displacement: number,\n velocity: number,\n stiffness: number,\n mass: number,\n): number => 0.5 * stiffness * displacement ** 2 + 0.5 * mass * velocity ** 2\n\n/**\n * Solves for the stiffness whose settling time matches a requested perceptual\n * duration, by bisection on the fraction of the initial energy left after\n * 1.5 × that duration. Ported from upstream's\n * `calculateNewStiffnessToMatchDuration` — the perceptual-duration spring is\n * a Reanimated concept with no RN equivalent, so there is nothing on the\n * platform side to reuse.\n */\nconst stiffnessForDuration = (\n x0: number,\n v0: number,\n durationMs: number,\n dampingRatio: number,\n mass: number,\n energyThreshold: number,\n): number => {\n const PERCEPTUAL_COEFFICIENT = 1.5\n const settlingSeconds = (durationMs * PERCEPTUAL_COEFFICIENT) / 1000\n const initialEnergyFor = (stiffness: number): number =>\n energyOf(x0, v0, stiffness, mass)\n\n const energyFractionLeft = (stiffness: number): number => {\n const decay = Math.sqrt(stiffness / mass) * dampingRatio\n const envelope = Math.exp(-decay * settlingSeconds)\n const displacement = (x0 + (v0 + x0 * decay) * settlingSeconds) * envelope\n const velocity = displacement * -decay + (v0 + x0 * decay) * envelope\n const initial = initialEnergyFor(stiffness)\n if (initial === 0) {\n return -energyThreshold\n }\n return (\n energyOf(displacement, velocity, stiffness, mass) / initial -\n energyThreshold\n )\n }\n\n return bisect(\n Number.EPSILON,\n // Upstream's bound: even an 8 ms spring stays under 2e3, with margin.\n 8e3,\n energyFractionLeft,\n energyThreshold * 1e-3,\n )\n}\n\n/**\n * Keeps the overshoot inside `clamp` by raising the damping ratio, using\n * upstream's approximation: the first two extrema of a damped oscillation sit\n * at `exp(-zeta * PI)` and `exp(-zeta * 2 * PI)` of the initial displacement,\n * so the zeta that puts them on the bound is a logarithm away.\n */\nconst zetaForClamp = (\n zeta: number,\n startDisplacement: number,\n toValue: number,\n clamp: { min?: number; max?: number },\n): number => {\n if (startDisplacement === 0) {\n return zeta\n }\n const [firstBound, secondBound] =\n startDisplacement <= 0 ? [clamp.min, clamp.max] : [clamp.max, clamp.min]\n const candidates = [zeta]\n if (secondBound !== undefined) {\n const extremum = Math.abs((secondBound - toValue) / startDisplacement)\n candidates.push(Math.abs(Math.log(extremum) / Math.PI))\n }\n if (firstBound !== undefined) {\n const extremum = Math.abs((firstBound - toValue) / startDisplacement)\n candidates.push(Math.abs(Math.log(extremum) / (2 * Math.PI)))\n }\n // Bigger zeta means smaller bounces, so the strictest candidate wins.\n return Math.max(...candidates)\n}\n\ntype PlatformSpringConfig = {\n toValue: number\n mass: number\n stiffness: number\n damping: number\n initialVelocity: number\n overshootClamping: boolean\n restDisplacementThreshold: number\n restSpeedThreshold: number\n}\n\n/**\n * Turns a Reanimated spring config into the platform solver's config.\n *\n * The rest condition is the one place the two genuinely differ. Upstream\n * stops when the oscillator's remaining energy falls to `energyThreshold` of\n * its initial energy — a RELATIVE criterion; the platform's solver stops on\n * absolute displacement and speed thresholds. Rather than accept RN's\n * absolute defaults (which would end a 400px spring at a different point than\n * a 4px one), the thresholds are derived per animation from the same energy\n * budget, so the stopping point tracks upstream's to well under a pixel.\n */\nexport const toPlatformSpringConfig = (\n config: WithSpringConfig,\n toValue: number,\n from: number,\n): PlatformSpringConfig => {\n const mass = config.mass ?? DEFAULT_SPRING_MASS\n const velocity = config.velocity ?? 0\n const energyThreshold = config.energyThreshold ?? DEFAULT_ENERGY_THRESHOLD\n const useDuration =\n config.duration !== undefined || config.dampingRatio !== undefined\n\n const displacement = from - toValue\n\n let stiffness: number\n let zeta: number\n if (useDuration) {\n const duration = config.duration ?? DEFAULT_SPRING_DURATION\n zeta = config.dampingRatio ?? DEFAULT_SPRING_DAMPING_RATIO\n stiffness =\n duration <= 0\n ? Number.POSITIVE_INFINITY\n : stiffnessForDuration(\n displacement,\n velocity,\n duration,\n zeta,\n mass,\n energyThreshold,\n )\n } else {\n stiffness = config.stiffness ?? DEFAULT_SPRING_STIFFNESS\n const damping = config.damping ?? DEFAULT_SPRING_DAMPING\n zeta = damping / (2 * Math.sqrt(stiffness * mass))\n }\n\n if (config.clamp) {\n zeta = zetaForClamp(zeta, displacement, toValue, config.clamp)\n }\n\n // A zero/degenerate duration means \"be there already\"; the platform solver\n // rejects a non-finite stiffness, so collapse it to a 0 ms timing instead.\n const resolvedStiffness = Number.isFinite(stiffness)\n ? Math.max(stiffness, Number.EPSILON)\n : 1e6\n\n const initialEnergy = energyOf(\n displacement,\n velocity,\n resolvedStiffness,\n mass,\n )\n const restEnergy = energyThreshold * initialEnergy\n\n return {\n toValue,\n mass,\n stiffness: resolvedStiffness,\n damping: Math.max(\n zeta * 2 * Math.sqrt(resolvedStiffness * mass),\n Number.EPSILON,\n ),\n initialVelocity: velocity,\n overshootClamping: config.overshootClamping ?? false,\n // Semi-axes of the energy ellipse: |x| where all the remaining energy is\n // potential, |v| where all of it is kinetic. A spring at rest is inside\n // both.\n restDisplacementThreshold: Math.max(\n Math.sqrt((2 * restEnergy) / resolvedStiffness),\n Number.MIN_VALUE,\n ),\n restSpeedThreshold: Math.max(\n Math.sqrt((2 * restEnergy) / mass),\n Number.MIN_VALUE,\n ),\n }\n}\n\n// --- building a running animation ---------------------------------------\n\n/**\n * The last value an animation aims at, used by `withRepeat`'s reverse and by\n * `updater-animations.ts` to seed a key that is animating for the first time.\n */\nexport const targetOf = (spec: AnimationSpec): AnimatableValue | null => {\n switch (spec.kind) {\n case \"timing\":\n case \"spring\":\n return spec.toValue\n case \"delay\":\n return targetOf(spec.animation)\n case \"sequence\": {\n const last = spec.animations[spec.animations.length - 1]\n return last ? targetOf(last) : null\n }\n case \"repeat\":\n return targetOf(spec.animation)\n case \"clamp\":\n return targetOf(spec.animation)\n // A decay has no target by construction — where it lands is the result\n // rather than the input. `withRepeat(withDecay(...))` therefore replays\n // from the same origin rather than ping-ponging between two.\n case \"decay\":\n return null\n }\n}\n\n/** A copy of `spec` aimed at `toValue`, for a reversed repetition. */\nconst aimedAt = (\n spec: AnimationSpec,\n toValue: AnimatableValue,\n): AnimationSpec => {\n switch (spec.kind) {\n case \"timing\":\n case \"spring\":\n return { ...spec, toValue }\n case \"delay\":\n return { ...spec, animation: aimedAt(spec.animation, toValue) }\n case \"sequence\": {\n const animations = [...spec.animations]\n const lastIndex = animations.length - 1\n const last = animations[lastIndex]\n if (last) {\n animations[lastIndex] = aimedAt(last, toValue)\n }\n return { ...spec, animations }\n }\n case \"repeat\":\n return { ...spec, animation: aimedAt(spec.animation, toValue) }\n case \"clamp\":\n return { ...spec, animation: aimedAt(spec.animation, toValue) }\n // Nothing to re-aim: see targetOf.\n case \"decay\":\n return spec\n }\n}\n\n/**\n * What makes two descriptors the SAME animation, for a caller that gets a\n * freshly built one on every evaluation and must decide whether to restart.\n *\n * The target and the shape, not object identity and not the whole config: a\n * mapper re-runs whenever anything it read changed, so `withSpring(open.value\n * ? 320 : 0)` produces a new object many times a second while asking for the\n * same animation every time. Config fields that change WHERE the animation\n * ends are in (a `duration`, a decay's `velocity`); ones that only change how\n * it gets there are not, because re-aiming a running animation at the value it\n * is already aimed at is a no-op that costs a restart.\n */\nexport const animationSignature = (spec: AnimationSpec): string => {\n switch (spec.kind) {\n case \"timing\":\n return `timing(${animatableValueSignature(spec.toValue)},${spec.config.duration ?? \"\"})`\n case \"spring\":\n return `spring(${animatableValueSignature(spec.toValue)})`\n case \"delay\":\n return `delay(${spec.delayMs},${animationSignature(spec.animation)})`\n case \"sequence\":\n return `sequence(${spec.animations.map(animationSignature).join(\";\")})`\n case \"repeat\":\n return `repeat(${spec.numberOfReps},${spec.reverse},${animationSignature(spec.animation)})`\n case \"clamp\":\n return `clamp(${spec.min},${spec.max},${animationSignature(spec.animation)})`\n // A decay has no target (targetOf), so its identity is the push it was\n // given: a new flick is a new animation, the same flick is not.\n case \"decay\":\n return `decay(${spec.config.velocity},${spec.config.deceleration})`\n }\n}\n\nconst callbackOf = (spec: AnimationSpec): AnimationCallback | undefined =>\n spec.kind === \"timing\" ||\n spec.kind === \"spring\" ||\n spec.kind === \"repeat\" ||\n spec.kind === \"decay\"\n ? spec.callback\n : undefined\n\n/**\n * Fires the descriptor's own callback when its animation settles — including\n * when it is cancelled, which reports `finished: false`, as upstream does.\n * Every node carries one, so the per-child callbacks of a `withSequence` and\n * the per-repetition callbacks of a `withRepeat` fire without the caller\n * having to unpick the tree.\n */\nconst reportingTo = (\n animation: CompositeAnimation,\n callback: AnimationCallback | undefined,\n driver: AnimationDriver,\n): CompositeAnimation =>\n callback\n ? {\n start: (onEnd) => {\n animation.start((result) => {\n callback(result.finished, driver.__getValue())\n onEnd?.(result)\n })\n },\n stop: () => animation.stop(),\n reset: () => animation.reset(),\n }\n : animation\n\n/**\n * What a descriptor needs to become a running animation: the platform's\n * Animated api for the animations it already has, and the frame scheduler\n * behind it for the one it does not (`withDecay` — see decay.ts). Both come\n * from the same place, so there is still exactly one clock under this layer.\n */\nexport type AnimationEngine = {\n api: AnimatedApi\n scheduler: FrameScheduler\n}\n\n/**\n * `withDecay`/`withClamp` stay number-only (they are not in the\n * AnimatableValue widening — neither is a real upstream export a shape\n * target would make sense for), so the driver reaching their branch of\n * `buildAnimation` must already be a plain `AnimatedValue`. Asserted rather\n * than assumed: a spec tree can only mix a number-only node with a\n * shape-targeted one by construction that this platform's own generics do\n * not rule out (`withSequence<T>` unifies `T` across a mixed array), so this\n * is the same \"fail loudly on a shape this driver was not built for\" rule\n * `zipAnimatableLeaves` applies to a mismatched target.\n */\nconst asNumberDriver = (\n driver: AnimationDriver,\n api: string,\n): AnimatedValue => {\n if (!(driver instanceof AnimatedValue)) {\n throw new Error(\n `react-native-reanimated: ${api}() only animates a single number on this platform, but the shared value it is animating holds a shape (an object or array), not a number.`,\n )\n }\n return driver\n}\n\n/**\n * The mirror of `asNumberDriver`: an object/array-targeted `withTiming`/\n * `withSpring` needs the shared value it is animating to already hold a\n * shape, not a plain number — the two do not upgrade into one another.\n */\nconst asShapeDriver = (\n driver: AnimationDriver,\n api: string,\n): AnimatedShapeValue => {\n if (!(driver instanceof AnimatedShapeValue)) {\n throw new Error(\n `react-native-reanimated: ${api}() was given an object/array target, but the shared value it is animating holds a plain number.`,\n )\n }\n return driver\n}\n\n/** Force-sets `driver` without going through an animation — the two driver kinds each expose their own `setValue`, narrowed by which one `driver` actually is. */\nconst setDriverValue = (\n driver: AnimationDriver,\n value: AnimatableValue,\n): void => {\n if (driver instanceof AnimatedValue) {\n driver.setValue(value as number)\n return\n }\n driver.setValue(value)\n}\n\nconst buildRepeat = (\n engine: AnimationEngine,\n driver: AnimationDriver,\n spec: RepeatSpec,\n): CompositeAnimation => {\n let child: CompositeAnimation | null = null\n let cancelled = false\n\n return {\n start(onEnd) {\n cancelled = false\n const origin = driver.__getValue()\n let from = origin\n let to = targetOf(spec.animation) ?? origin\n let completed = 0\n\n const runIteration = (): void => {\n child = buildAnimation(engine, driver, aimedAt(spec.animation, to))\n child.start((result) => {\n if (cancelled || !result.finished) {\n onEnd?.(result)\n return\n }\n completed += 1\n if (spec.numberOfReps > 0 && completed >= spec.numberOfReps) {\n onEnd?.({ finished: true })\n return\n }\n if (spec.reverse) {\n // Ping-pong: the value is already at `to`, so the next\n // repetition simply aims back at where this one started.\n const previousTarget = to\n to = from\n from = previousTarget\n } else {\n // Replay: snap back to where the repeat began and run again,\n // which is what upstream's onStart(startValue) amounts to.\n setDriverValue(driver, from)\n }\n runIteration()\n })\n }\n\n runIteration()\n },\n stop() {\n cancelled = true\n child?.stop()\n },\n reset() {\n child?.reset()\n },\n }\n}\n\n/**\n * Turns a descriptor into a running animation on `driver`. Every leaf is one\n * of the platform's own animations, so the whole tree runs off the single\n * injected frame scheduler.\n */\nexport const buildAnimation = (\n engine: AnimationEngine,\n driver: AnimationDriver,\n spec: AnimationSpec,\n): CompositeAnimation => {\n const { api, scheduler } = engine\n const build = (): CompositeAnimation => {\n switch (spec.kind) {\n case \"timing\": {\n const duration = spec.config.duration ?? DEFAULT_TIMING_DURATION\n const easing = spec.config.easing\n ? resolveEasing(spec.config.easing)\n : defaultTimingEasing\n if (typeof spec.toValue === \"number\") {\n return api.timing(asNumberDriver(driver, \"withTiming\"), {\n toValue: spec.toValue,\n duration,\n easing,\n })\n }\n return createShapeValueAnimation(\n scheduler,\n asShapeDriver(driver, \"withTiming\"),\n timingShapeMakeSteps(spec.toValue, duration, easing),\n )\n }\n case \"spring\": {\n if (typeof spec.toValue === \"number\") {\n const numberDriver = asNumberDriver(driver, \"withSpring\")\n return api.spring(\n numberDriver,\n toPlatformSpringConfig(\n spec.config,\n spec.toValue,\n numberDriver.__getValue(),\n ),\n )\n }\n return createShapeValueAnimation(\n scheduler,\n asShapeDriver(driver, \"withSpring\"),\n springShapeMakeSteps(\n spec.toValue,\n toPlatformSpringConfig,\n spec.config,\n ),\n )\n }\n case \"delay\":\n return api.sequence([\n api.delay(spec.delayMs),\n buildAnimation(engine, driver, spec.animation),\n ])\n case \"sequence\":\n return api.sequence(\n spec.animations.map((child) => buildAnimation(engine, driver, child)),\n )\n case \"repeat\":\n return buildRepeat(engine, driver, spec)\n case \"decay\":\n return createValueAnimation(\n scheduler,\n asNumberDriver(driver, \"withDecay\"),\n decayStep(spec.config),\n )\n case \"clamp\":\n return buildClamp(engine, asNumberDriver(driver, \"withClamp\"), spec)\n }\n }\n return reportingTo(build(), callbackOf(spec), driver)\n}\n\n/**\n * `withClamp` in full: the inner animation is built on a PRIVATE value and\n * what that value publishes is clipped onto the real driver. Running it\n * un-truncated is the whole behaviour — upstream keeps the clamped animation's\n * own `current` unbounded for exactly this reason — and the private node costs\n * one listener, no extra frame subscription and no second clock, because the\n * inner animation is an ordinary one built by the same function.\n */\nconst buildClamp = (\n engine: AnimationEngine,\n driver: AnimatedValue,\n spec: ClampSpec,\n): CompositeAnimation => {\n // withClamp stays number-only (it is not part of this platform's\n // AnimatableValue widening — see asNumberDriver), so `driver` here is\n // always a plain AnimatedValue by construction.\n const inner = new engine.api.Value(driver.__getValue())\n inner.addListener(({ value }) => {\n const clipped =\n spec.max !== undefined && value > spec.max\n ? spec.max\n : spec.min !== undefined && value < spec.min\n ? spec.min\n : value\n driver.__updateValue(clipped)\n })\n return buildAnimation(engine, inner, spec.animation)\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { buildAnimation, isAnimationSpec, } from "./animation";
1
+ import { buildAnimation, isAnimationSpec, makeAnimationDriver, } from "./animation";
2
2
  import { trackRead } from "./tracking";
3
3
  export const createMakeMutable = (api, scheduler) => {
4
4
  // Both halves of the one clock: the api for the animations the platform
@@ -35,14 +35,14 @@ export const createMakeMutable = (api, scheduler) => {
35
35
  };
36
36
  const startAnimation = (spec) => {
37
37
  stopAnimation();
38
- if (typeof current !== "number") {
39
- throw new Error("react-native-reanimated: an animation can only be assigned to a shared value holding a number " +
40
- `(this one holds ${typeof current}). Colors and layout values cannot be animated on this platform yet — see docs/api.md.`);
41
- }
42
38
  // A fresh driver per run, constructed at the current value: restarting
43
39
  // an animation must pick up from wherever the value is now, and the
44
40
  // platform's engine derives its start value from the node it drives.
45
- const driver = new api.Value(current);
41
+ // A number gets the platform's own AnimatedValue, unchanged; an object
42
+ // or array of numbers — upstream's AnimatableValue, widened from
43
+ // number-only (animatable-value.ts) — gets its shape counterpart.
44
+ // Anything else was never animatable and still is not.
45
+ const driver = makeAnimationDriver(api, current, "a shared value that an animation is assigned to");
46
46
  const driverListener = driver.addListener(({ value }) => {
47
47
  commit(value);
48
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"mutable.js","sourceRoot":"","sources":["../../src/reanimated-compat/mutable.ts"],"names":[],"mappings":"AA+BA,OAAO,EACL,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAA+B,MAAM,YAAY,CAAA;AA6BnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAAgB,EAChB,SAAyB,EACzB,EAAE;IACF,wEAAwE;IACxE,6EAA6E;IAC7E,uDAAuD;IACvD,MAAM,MAAM,GAAoB,EAAE,GAAG,EAAE,SAAS,EAAE,CAAA;IAElD,MAAM,WAAW,GAAG,CAAI,OAAU,EAAkB,EAAE;QACpD,IAAI,OAAO,GAAG,OAAO,CAAA;QACrB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;QACjC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAA;QACrD,IAAI,kBAAkB,GAAG,CAAC,CAAA;QAC1B,IAAI,OAAO,GAA4B,IAAI,CAAA;QAE3C,MAAM,MAAM,GAAG,GA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AoD;IACnD,EAAE,wBAAwB,KAAK,IAAI,CAAA;AAEvC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAAoB,EAAQ,EAAE;IAC5D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,WAAW,CAAC,iBAAiB,EAAE,CAAA;IACjC,CAAC;AACH,CAAC,CAAA","sourcesContent":["// The shared value: an observable box, and the single place where the\n// worklet architecture actually collapses into something.\n//\n// On mobile a SharedValue is a bridge between two runtimes, with guest/host\n// decorators and a serializer behind `.value`. Here it is a closure over a\n// number with two kinds of subscriber — mappers (re-run on write) and\n// listeners (notified on write) — because GTK's main loop IS the JS thread,\n// so a write is a synchronous function call that walks its subscribers.\n//\n// The one deliberate shape decision, and it is load-bearing:\n// `addListener`/`removeListener` accept BOTH calling conventions.\n//\n// - Upstream's is `addListener(listenerID, listener)` with the listener\n// called with the raw value. Library code written against Reanimated\n// uses that one.\n// - This platform's animated nodes use `addListener(callback) => id` with\n// `{ value }`, and `src/components/animated.tsx` recognises an animated\n// node STRUCTURALLY (`addListener` + `__getValue`). Supporting it is what\n// makes a shared value drivable by the existing `Animated.View` with no\n// change to the view layer — the load-bearing discovery behind this whole\n// epic (docs/research/reanimated.md).\n//\n// Implementing only one of the two would not fail loudly; it would fail\n// silently, which this repo treats as the worst outcome. The convention is\n// picked from what actually arrived, and the two id spaces are kept apart so\n// a caller-chosen numeric id cannot collide with a generated one.\nimport type {\n AnimatedApi,\n AnimatedValue,\n FrameScheduler,\n} from \"../animated/index\"\nimport {\n buildAnimation,\n isAnimationSpec,\n type AnimationEngine,\n type AnimationSpec,\n} from \"./animation\"\nimport { trackRead, type Mapper, type Trackable } from \"./tracking\"\n\n/** The platform's animated-node listener shape. */\nexport type NodeListener<T> = (state: { value: T }) => void\n\n/** Upstream's shared-value listener shape. */\nexport type ValueListener<T> = (value: T) => void\n\nexport type SharedValue<T = unknown> = Trackable & {\n value: T\n get(): T\n set(next: T | ((current: T) => T)): void\n modify(modifier?: (current: T) => T, forceUpdate?: boolean): void\n addListener(listener: NodeListener<T>): string\n addListener(listenerID: number | string, listener: ValueListener<T>): string\n removeListener(listenerID: number | string): void\n /** @internal The platform's animated-node read. Never registers a mapper. */\n __getValue(): T\n /** @internal Stops a running animation, leaving the value where it is. */\n __cancelAnimation(): void\n /** Upstream's brand, which `isSharedValue` and consumer libraries check. */\n _isReanimatedSharedValue: true\n}\n\n/** A shared value a `useDerivedValue` owns: readable, not writable. */\nexport type DerivedValue<T = unknown> = Readonly<SharedValue<T>>\n\ntype RunningAnimation = { stop(): void }\n\nexport const createMakeMutable = (\n api: AnimatedApi,\n scheduler: FrameScheduler,\n) => {\n // Both halves of the one clock: the api for the animations the platform\n // already implements, the scheduler for `withDecay`, whose per-frame step is\n // Reanimated's own rather than RN's. See animation.ts.\n const engine: AnimationEngine = { api, scheduler }\n\n const makeMutable = <T>(initial: T): SharedValue<T> => {\n let current = initial\n const mappers = new Set<Mapper>()\n const listeners = new Map<string, ValueListener<T>>()\n let nextNodeListenerId = 1\n let running: RunningAnimation | null = null\n\n const notify = (): void => {\n // Copied before iterating: a listener or a mapper may subscribe or\n // unsubscribe while the write is being published.\n for (const listener of [...listeners.values()]) {\n listener(current)\n }\n for (const mapper of [...mappers]) {\n mapper.run()\n }\n }\n\n const commit = (next: T): void => {\n if (Object.is(next, current)) {\n return\n }\n current = next\n notify()\n }\n\n const stopAnimation = (): void => {\n const animation = running\n running = null\n animation?.stop()\n }\n\n const startAnimation = (spec: AnimationSpec): void => {\n stopAnimation()\n if (typeof current !== \"number\") {\n throw new Error(\n \"react-native-reanimated: an animation can only be assigned to a shared value holding a number \" +\n `(this one holds ${typeof current}). Colors and layout values cannot be animated on this platform yet — see docs/api.md.`,\n )\n }\n // A fresh driver per run, constructed at the current value: restarting\n // an animation must pick up from wherever the value is now, and the\n // platform's engine derives its start value from the node it drives.\n const driver: AnimatedValue = new api.Value(current)\n const driverListener = driver.addListener(({ value }) => {\n commit(value as T)\n })\n const animation = buildAnimation(engine, driver, spec)\n const handle: RunningAnimation = { stop: () => animation.stop() }\n running = handle\n animation.start(() => {\n driver.removeListener(driverListener)\n if (running === handle) {\n running = null\n }\n })\n }\n\n const write = (next: T): void => {\n if (isAnimationSpec(next)) {\n startAnimation(next)\n return\n }\n // A plain write cancels whatever was running, exactly as upstream's\n // valueSetter does — assigning a value is how you stop an animation.\n stopAnimation()\n commit(next)\n }\n\n const shared: SharedValue<T> = {\n _isReanimatedSharedValue: true,\n\n get value() {\n trackRead(shared)\n return current\n },\n set value(next: T) {\n write(next)\n },\n\n get() {\n trackRead(shared)\n return current\n },\n set(next) {\n write(\n typeof next === \"function\"\n ? (next as (currentValue: T) => T)(current)\n : next,\n )\n },\n\n modify(modifier, forceUpdate = true) {\n const next = modifier ? modifier(current) : current\n if (!forceUpdate) {\n commit(next)\n return\n }\n // forceUpdate republishes even when the modifier mutated the value in\n // place and `Object.is` therefore still holds — the case the method\n // exists for.\n current = next\n notify()\n },\n\n addListener(\n first: NodeListener<T> | number | string,\n second?: ValueListener<T>,\n ): string {\n if (typeof first === \"function\") {\n const id = `#${nextNodeListenerId++}`\n listeners.set(id, (value) => first({ value }))\n return id\n }\n const id = String(first)\n if (second) {\n listeners.set(id, second)\n }\n return id\n },\n\n removeListener(listenerID) {\n listeners.delete(String(listenerID))\n },\n\n __getValue() {\n return current\n },\n\n __addMapper(mapper) {\n mappers.add(mapper)\n },\n\n __removeMapper(mapper) {\n mappers.delete(mapper)\n },\n\n __cancelAnimation() {\n stopAnimation()\n },\n }\n\n return shared\n }\n\n return makeMutable\n}\n\nexport const isSharedValue = <T = unknown>(\n value: unknown,\n): value is SharedValue<T> =>\n (value as Record<string, unknown> | null | undefined)\n ?._isReanimatedSharedValue === true\n\n/** Stops the animation running on a shared value, leaving it where it is. */\nexport const cancelAnimation = (sharedValue: unknown): void => {\n if (isSharedValue(sharedValue)) {\n sharedValue.__cancelAnimation()\n }\n}\n"]}
1
+ {"version":3,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gBAC3B,CAAC;gBACD,OAAO,EAAE,CAAA;YACX,CAAC;YAED,cAAc,CAAC,UAAU;gBACvB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;YACtC,CAAC;YAED,UAAU;gBACR,OAAO,OAAO,CAAA;YAChB,CAAC;YAED,WAAW,CAAC,MAAM;gBAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACrB,CAAC;YAED,cAAc,CAAC,MAAM;gBACnB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACxB,CAAC;YAED,iBAAiB;gBACf,aAAa,EAAE,CAAA;YACjB,CAAC;SACF,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAED,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAc,EACW,EAAE,CAC1B,KAAoD;IACnD,EAAE,wBAAwB,KAAK,IAAI,CAAA;AAEvC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAAoB,EAAQ,EAAE;IAC5D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,WAAW,CAAC,iBAAiB,EAAE,CAAA;IACjC,CAAC;AACH,CAAC,CAAA","sourcesContent":["// The shared value: an observable box, and the single place where the\n// worklet architecture actually collapses into something.\n//\n// On mobile a SharedValue is a bridge between two runtimes, with guest/host\n// decorators and a serializer behind `.value`. Here it is a closure over a\n// number with two kinds of subscriber — mappers (re-run on write) and\n// listeners (notified on write) — because GTK's main loop IS the JS thread,\n// so a write is a synchronous function call that walks its subscribers.\n//\n// The one deliberate shape decision, and it is load-bearing:\n// `addListener`/`removeListener` accept BOTH calling conventions.\n//\n// - Upstream's is `addListener(listenerID, listener)` with the listener\n// called with the raw value. Library code written against Reanimated\n// uses that one.\n// - This platform's animated nodes use `addListener(callback) => id` with\n// `{ value }`, and `src/components/animated.tsx` recognises an animated\n// node STRUCTURALLY (`addListener` + `__getValue`). Supporting it is what\n// makes a shared value drivable by the existing `Animated.View` with no\n// change to the view layer — the load-bearing discovery behind this whole\n// epic (docs/research/reanimated.md).\n//\n// Implementing only one of the two would not fail loudly; it would fail\n// silently, which this repo treats as the worst outcome. The convention is\n// picked from what actually arrived, and the two id spaces are kept apart so\n// a caller-chosen numeric id cannot collide with a generated one.\nimport type { AnimatedApi, FrameScheduler } from \"../animated/index\"\nimport {\n buildAnimation,\n isAnimationSpec,\n makeAnimationDriver,\n type AnimationEngine,\n type AnimationSpec,\n} from \"./animation\"\nimport { trackRead, type Mapper, type Trackable } from \"./tracking\"\n\n/** The platform's animated-node listener shape. */\nexport type NodeListener<T> = (state: { value: T }) => void\n\n/** Upstream's shared-value listener shape. */\nexport type ValueListener<T> = (value: T) => void\n\nexport type SharedValue<T = unknown> = Trackable & {\n value: T\n get(): T\n set(next: T | ((current: T) => T)): void\n modify(modifier?: (current: T) => T, forceUpdate?: boolean): void\n addListener(listener: NodeListener<T>): string\n addListener(listenerID: number | string, listener: ValueListener<T>): string\n removeListener(listenerID: number | string): void\n /** @internal The platform's animated-node read. Never registers a mapper. */\n __getValue(): T\n /** @internal Stops a running animation, leaving the value where it is. */\n __cancelAnimation(): void\n /** Upstream's brand, which `isSharedValue` and consumer libraries check. */\n _isReanimatedSharedValue: true\n}\n\n/** A shared value a `useDerivedValue` owns: readable, not writable. */\nexport type DerivedValue<T = unknown> = Readonly<SharedValue<T>>\n\ntype RunningAnimation = { stop(): void }\n\nexport const createMakeMutable = (\n api: AnimatedApi,\n scheduler: FrameScheduler,\n) => {\n // Both halves of the one clock: the api for the animations the platform\n // already implements, the scheduler for `withDecay`, whose per-frame step is\n // Reanimated's own rather than RN's. See animation.ts.\n const engine: AnimationEngine = { api, scheduler }\n\n const makeMutable = <T>(initial: T): SharedValue<T> => {\n let current = initial\n const mappers = new Set<Mapper>()\n const listeners = new Map<string, ValueListener<T>>()\n let nextNodeListenerId = 1\n let running: RunningAnimation | null = null\n\n const notify = (): void => {\n // Copied before iterating: a listener or a mapper may subscribe or\n // unsubscribe while the write is being published.\n for (const listener of [...listeners.values()]) {\n listener(current)\n }\n for (const mapper of [...mappers]) {\n mapper.run()\n }\n }\n\n const commit = (next: T): void => {\n if (Object.is(next, current)) {\n return\n }\n current = next\n notify()\n }\n\n const stopAnimation = (): void => {\n const animation = running\n running = null\n animation?.stop()\n }\n\n const startAnimation = (spec: AnimationSpec): void => {\n stopAnimation()\n // A fresh driver per run, constructed at the current value: restarting\n // an animation must pick up from wherever the value is now, and the\n // platform's engine derives its start value from the node it drives.\n // A number gets the platform's own AnimatedValue, unchanged; an object\n // or array of numbers — upstream's AnimatableValue, widened from\n // number-only (animatable-value.ts) — gets its shape counterpart.\n // Anything else was never animatable and still is not.\n const driver = makeAnimationDriver(\n api,\n current,\n \"a shared value that an animation is assigned to\",\n )\n const driverListener = driver.addListener(({ value }) => {\n commit(value as T)\n })\n const animation = buildAnimation(engine, driver, spec)\n const handle: RunningAnimation = { stop: () => animation.stop() }\n running = handle\n animation.start(() => {\n driver.removeListener(driverListener)\n if (running === handle) {\n running = null\n }\n })\n }\n\n const write = (next: T): void => {\n if (isAnimationSpec(next)) {\n startAnimation(next)\n return\n }\n // A plain write cancels whatever was running, exactly as upstream's\n // valueSetter does — assigning a value is how you stop an animation.\n stopAnimation()\n commit(next)\n }\n\n const shared: SharedValue<T> = {\n _isReanimatedSharedValue: true,\n\n get value() {\n trackRead(shared)\n return current\n },\n set value(next: T) {\n write(next)\n },\n\n get() {\n trackRead(shared)\n return current\n },\n set(next) {\n write(\n typeof next === \"function\"\n ? (next as (currentValue: T) => T)(current)\n : next,\n )\n },\n\n modify(modifier, forceUpdate = true) {\n const next = modifier ? modifier(current) : current\n if (!forceUpdate) {\n commit(next)\n return\n }\n // forceUpdate republishes even when the modifier mutated the value in\n // place and `Object.is` therefore still holds — the case the method\n // exists for.\n current = next\n notify()\n },\n\n addListener(\n first: NodeListener<T> | number | string,\n second?: ValueListener<T>,\n ): string {\n if (typeof first === \"function\") {\n const id = `#${nextNodeListenerId++}`\n listeners.set(id, (value) => first({ value }))\n return id\n }\n const id = String(first)\n if (second) {\n listeners.set(id, second)\n }\n return id\n },\n\n removeListener(listenerID) {\n listeners.delete(String(listenerID))\n },\n\n __getValue() {\n return current\n },\n\n __addMapper(mapper) {\n mappers.add(mapper)\n },\n\n __removeMapper(mapper) {\n mappers.delete(mapper)\n },\n\n __cancelAnimation() {\n stopAnimation()\n },\n }\n\n return shared\n }\n\n return makeMutable\n}\n\nexport const isSharedValue = <T = unknown>(\n value: unknown,\n): value is SharedValue<T> =>\n (value as Record<string, unknown> | null | undefined)\n ?._isReanimatedSharedValue === true\n\n/** Stops the animation running on a shared value, leaving it where it is. */\nexport const cancelAnimation = (sharedValue: unknown): void => {\n if (isSharedValue(sharedValue)) {\n sharedValue.__cancelAnimation()\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { animationSignature, buildAnimation, isAnimationSpec, targetOf, } from "./animation";
1
+ import { isAnimatableValue, maxAnimatableLeafDelta, sameAnimatableValue, } from "./animatable-value";
2
+ import { animationSignature, buildAnimation, isAnimationSpec, makeAnimationDriver, targetOf, } from "./animation";
2
3
  // How far behind its own animation a property this platform will not drive at
3
4
  // frame rate is allowed to fall.
4
5
  //
@@ -103,8 +104,14 @@ export const createUpdaterAnimations = (engine, publish, onSettled, onLanding) =
103
104
  entries.delete(key);
104
105
  entry.running?.stop();
105
106
  entry.driver.removeListener(entry.listenerId);
106
- if (typeof replacement === "number" &&
107
- !Object.is(replacement, entry.landedValue)) {
107
+ // A number originally; now also an object/array of numbers — either way
108
+ // a resting AnimatableValue owes the caller a render if it differs from
109
+ // what React was last given. `sameAnimatableValue` replaces the original
110
+ // `Object.is`: a merged object is rebuilt fresh every frame
111
+ // (rebuildAnimatableValue), so it is never the SAME reference as the
112
+ // landed value even when every leaf agrees.
113
+ if (isAnimatableValue(replacement) &&
114
+ !sameAnimatableValue(replacement, entry.landedValue)) {
108
115
  onLanding?.(key);
109
116
  }
110
117
  };
@@ -126,7 +133,12 @@ export const createUpdaterAnimations = (engine, publish, onSettled, onLanding) =
126
133
  entry.landedValue = entry.driver.__getValue();
127
134
  entry.landedAt = now();
128
135
  };
129
- /** The cadence: see LANDING_INTERVAL_MS. */
136
+ /**
137
+ * The cadence: see LANDING_INTERVAL_MS. For a shape key (`{x, y}`, …) "far
138
+ * enough to change a committed layout" is ANY leaf crossing the epsilon —
139
+ * `maxAnimatableLeafDelta` is the largest single-leaf change, not a sum, so
140
+ * a diagonal move is not double-counted into landing twice as often.
141
+ */
130
142
  const considerLanding = (key, value) => {
131
143
  if (onLanding === undefined || !hasClock) {
132
144
  return;
@@ -138,7 +150,7 @@ export const createUpdaterAnimations = (engine, publish, onSettled, onLanding) =
138
150
  if (now() - entry.landedAt < LANDING_INTERVAL_MS) {
139
151
  return;
140
152
  }
141
- if (Math.abs(value - entry.landedValue) < LANDING_EPSILON) {
153
+ if (maxAnimatableLeafDelta(value, entry.landedValue) < LANDING_EPSILON) {
142
154
  return;
143
155
  }
144
156
  markLanded(entry);
@@ -178,11 +190,17 @@ export const createUpdaterAnimations = (engine, publish, onSettled, onLanding) =
178
190
  * `republish`; reading one key out of it is the entire mechanism, and the
179
191
  * entry does not have to carry a value across runs or outlive its animation.
180
192
  *
181
- * Numbers only, and `undefined` for everything else, which lines up with
182
- * upstream at both ends: a key that was absent has no starting point (its
183
- * `oldValues[key]` is `undefined`, and the animation's own `current` the
184
- * target stands), and a percentage string or a colour is not something the
185
- * numeric drivers here can start at.
193
+ * Numbers only, and `undefined` for everything else which, now that a key
194
+ * can hold an OBJECT too, is worth stating precisely: a plain object
195
+ * (`{x: 5, y: 10}`) does NOT carry over here, on purpose, and it is
196
+ * upstream's own rule, not a gap in this one. `prepareAnimation`'s branches
197
+ * are `typeof lastValue === "object"` → was it a shared value (`.value`) or
198
+ * an animation node (`.onFrame`)? Neither matches a plain data object, so
199
+ * `value` is left at its default — the animation's own target. A key whose
200
+ * previous value was a plain OBJECT is therefore seeded at the target
201
+ * exactly like a key that was absent, and only a plain NUMBER ever carries
202
+ * over as a starting point. This function already implemented that rule by
203
+ * accident, before objects were legal at all; nothing here changed.
186
204
  */
187
205
  const startingPoint = (previous, key) => {
188
206
  const value = previous?.[key];
@@ -201,8 +219,10 @@ export const createUpdaterAnimations = (engine, publish, onSettled, onLanding) =
201
219
  const from = startingPoint(previous, key);
202
220
  // The driver is seeded before anything is built on purpose: a spring reads
203
221
  // its origin off the value it is given (animation.ts), so this IS where
204
- // "animate from the old number" happens.
205
- const driver = new engine.api.Value(from ?? targetOf(spec) ?? 0);
222
+ // "animate from the old number" happens. makeAnimationDriver picks the
223
+ // right driver kind for the seed a number for a scalar key, a shape
224
+ // (animatable-value.ts) for an object/array one.
225
+ const driver = makeAnimationDriver(engine.api, from ?? targetOf(spec) ?? 0, `the "${key}" key of an updater's result`);
206
226
  const entry = {
207
227
  driver,
208
228
  listenerId: driver.addListener(({ value }) => {