motion-dom 12.7.4 → 12.7.5-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/cjs/index.js +2946 -475
  2. package/dist/es/animation/AsyncMotionValueAnimation.mjs +178 -0
  3. package/dist/es/animation/GroupAnimation.mjs +6 -15
  4. package/dist/es/animation/JSAnimation.mjs +346 -0
  5. package/dist/es/animation/NativeAnimation.mjs +64 -67
  6. package/dist/es/animation/NativeAnimationExtended.mjs +65 -0
  7. package/dist/es/animation/NativeAnimationWrapper.mjs +14 -0
  8. package/dist/es/animation/drivers/driver-frameloop.mjs +17 -0
  9. package/dist/es/animation/generators/inertia.mjs +87 -0
  10. package/dist/es/animation/generators/keyframes.mjs +49 -0
  11. package/dist/es/animation/generators/spring/defaults.mjs +27 -0
  12. package/dist/es/animation/generators/spring/find.mjs +84 -0
  13. package/dist/es/animation/generators/spring/index.mjs +175 -0
  14. package/dist/es/animation/generators/utils/velocity.mjs +9 -0
  15. package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +131 -0
  16. package/dist/es/animation/keyframes/KeyframesResolver.mjs +156 -0
  17. package/dist/es/animation/keyframes/get-final.mjs +3 -4
  18. package/dist/es/animation/keyframes/offsets/default.mjs +9 -0
  19. package/dist/es/animation/keyframes/offsets/fill.mjs +12 -0
  20. package/dist/es/animation/keyframes/offsets/time.mjs +5 -0
  21. package/dist/es/animation/keyframes/utils/apply-px-defaults.mjs +11 -0
  22. package/dist/es/animation/keyframes/utils/fill-wildcards.mjs +7 -0
  23. package/dist/es/animation/keyframes/utils/is-none.mjs +15 -0
  24. package/dist/es/animation/keyframes/utils/make-none-animatable.mjs +30 -0
  25. package/dist/es/animation/keyframes/utils/unit-conversion.mjs +36 -0
  26. package/dist/es/animation/utils/WithPromise.mjs +28 -0
  27. package/dist/es/animation/utils/active-animations.mjs +9 -0
  28. package/dist/es/animation/utils/can-animate.mjs +42 -0
  29. package/dist/es/animation/utils/css-variables-conversion.mjs +41 -0
  30. package/dist/es/animation/utils/is-animatable.mjs +30 -0
  31. package/dist/es/animation/utils/is-css-variable.mjs +15 -0
  32. package/dist/es/animation/utils/replace-transition-type.mjs +18 -0
  33. package/dist/es/animation/waapi/easing/is-supported.mjs +1 -1
  34. package/dist/es/animation/waapi/easing/map-easing.mjs +5 -3
  35. package/dist/es/animation/waapi/start-waapi-animation.mjs +6 -4
  36. package/dist/es/animation/waapi/supports/waapi.mjs +39 -0
  37. package/dist/es/animation/waapi/utils/accelerated-values.mjs +14 -0
  38. package/dist/es/animation/waapi/utils/apply-generator.mjs +2 -1
  39. package/dist/es/animation/waapi/utils/unsupported-easing.mjs +18 -0
  40. package/dist/es/frameloop/batcher.mjs +2 -1
  41. package/dist/es/frameloop/order.mjs +1 -0
  42. package/dist/es/index.mjs +49 -2
  43. package/dist/es/render/dom/is-css-var.mjs +3 -0
  44. package/dist/es/render/dom/parse-transform.mjs +83 -0
  45. package/dist/es/render/dom/style-computed.mjs +10 -0
  46. package/dist/es/render/dom/style-set.mjs +9 -0
  47. package/dist/es/render/utils/keys-position.mjs +13 -0
  48. package/dist/es/render/utils/keys-transform.mjs +28 -0
  49. package/dist/es/scroll/observe.mjs +18 -0
  50. package/dist/es/stats/index.mjs +2 -0
  51. package/dist/es/utils/interpolate.mjs +74 -0
  52. package/dist/es/utils/mix/color.mjs +47 -0
  53. package/dist/es/utils/mix/complex.mjs +92 -0
  54. package/dist/es/utils/mix/immediate.mjs +5 -0
  55. package/dist/es/utils/mix/index.mjs +14 -0
  56. package/dist/es/utils/mix/number.mjs +26 -0
  57. package/dist/es/utils/mix/visibility.mjs +16 -0
  58. package/dist/es/value/index.mjs +3 -1
  59. package/dist/es/value/types/auto.mjs +9 -0
  60. package/dist/es/value/types/color/hex.mjs +40 -0
  61. package/dist/es/value/types/color/hsla-to-rgba.mjs +42 -0
  62. package/dist/es/value/types/color/hsla.mjs +22 -0
  63. package/dist/es/value/types/color/index.mjs +27 -0
  64. package/dist/es/value/types/color/rgba.mjs +25 -0
  65. package/dist/es/value/types/color/utils.mjs +29 -0
  66. package/dist/es/value/types/complex/filter.mjs +30 -0
  67. package/dist/es/value/types/complex/index.mjs +91 -0
  68. package/dist/es/value/types/dimensions.mjs +15 -0
  69. package/dist/es/value/types/int.mjs +8 -0
  70. package/dist/es/value/types/maps/defaults.mjs +30 -0
  71. package/dist/es/value/types/maps/number.mjs +51 -0
  72. package/dist/es/value/types/maps/transform.mjs +31 -0
  73. package/dist/es/value/types/numbers/index.mjs +17 -0
  74. package/dist/es/value/types/numbers/units.mjs +18 -0
  75. package/dist/es/value/types/test.mjs +6 -0
  76. package/dist/es/value/types/utils/animatable-none.mjs +15 -0
  77. package/dist/es/value/types/utils/color-regex.mjs +3 -0
  78. package/dist/es/value/types/utils/find.mjs +15 -0
  79. package/dist/es/value/types/utils/float-regex.mjs +3 -0
  80. package/dist/es/value/types/utils/get-as-type.mjs +10 -0
  81. package/dist/es/value/types/utils/is-nullish.mjs +5 -0
  82. package/dist/es/value/types/utils/sanitize.mjs +5 -0
  83. package/dist/es/value/types/utils/single-color-regex.mjs +3 -0
  84. package/dist/es/view/start.mjs +4 -3
  85. package/dist/index.d.ts +945 -444
  86. package/dist/motion-dom.dev.js +2945 -475
  87. package/dist/motion-dom.js +1 -1
  88. package/package.json +3 -3
  89. package/dist/es/animation/keyframes/hydrate.mjs +0 -26
  90. package/dist/es/animation/waapi/utils/attach-timeline.mjs +0 -6
  91. package/dist/es/render/dom/style.mjs +0 -15
  92. package/dist/es/utils/is-bezier-definition.mjs +0 -3
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Box, Easing, EasingFunction, BezierDefinition } from 'motion-utils';
2
+
1
3
  interface SVGAttributes {
2
4
  accentHeight?: number | string | undefined;
3
5
  accumulate?: "none" | "sum" | undefined;
@@ -243,12 +245,33 @@ interface SVGAttributes {
243
245
  zoomAndPan?: string | undefined;
244
246
  }
245
247
 
248
+ /**
249
+ * Temporary subset of VisualElement until VisualElement is
250
+ * moved to motion-dom
251
+ */
252
+ interface WithRender {
253
+ render: () => void;
254
+ readValue: (name: string, keyframe: any) => any;
255
+ getValue: (name: string, defaultValue?: any) => any;
256
+ current?: HTMLElement | SVGElement;
257
+ measureViewportBox: () => Box;
258
+ }
259
+
246
260
  interface ProgressTimeline {
247
261
  currentTime: null | {
248
262
  value: number;
249
263
  };
250
264
  cancel?: VoidFunction;
251
265
  }
266
+ interface ValueAnimationOptionsWithRenderContext<V extends string | number = number> extends ValueAnimationOptions<V> {
267
+ KeyframeResolver?: typeof KeyframeResolver;
268
+ motionValue?: MotionValue<V>;
269
+ element?: WithRender;
270
+ }
271
+ interface TimelineWithFallback {
272
+ timeline: ProgressTimeline;
273
+ observe: (animation: AnimationPlaybackControls) => VoidFunction;
274
+ }
252
275
  /**
253
276
  * Methods to control an animation.
254
277
  */
@@ -271,7 +294,7 @@ interface AnimationPlaybackControls {
271
294
  *
272
295
  * This is currently for internal use only.
273
296
  */
274
- state?: AnimationPlayState;
297
+ state: AnimationPlayState;
275
298
  duration: number;
276
299
  /**
277
300
  * Stops the animation at its current state, and prevents it from
@@ -299,14 +322,7 @@ interface AnimationPlaybackControls {
299
322
  *
300
323
  * This is currently for internal use only.
301
324
  */
302
- attachTimeline?: (timeline: ProgressTimeline, fallback?: (animation: AnimationPlaybackControls) => VoidFunction) => VoidFunction;
303
- /**
304
- * Flattens the animation's easing curve to linear.
305
- *
306
- * This is currently for internal use only, and is used by scroll() to
307
- * ensure an animation is being scrubbed by progress rather than eased time.
308
- */
309
- flatten: () => void;
325
+ attachTimeline: (timeline: TimelineWithFallback) => VoidFunction;
310
326
  finished: Promise<any>;
311
327
  }
312
328
  type AnimationPlaybackControlsWithThen = AnimationPlaybackControls & {
@@ -321,24 +337,26 @@ interface KeyframeGenerator<V> {
321
337
  next: (t: number) => AnimationState<V>;
322
338
  toString: () => string;
323
339
  }
324
- interface DOMValueAnimationOptions<V extends string | number = number> {
340
+ interface DOMValueAnimationOptions<V extends string | number = number> extends ValueAnimationTransition<V> {
325
341
  element: HTMLElement | SVGElement;
326
342
  keyframes: ValueKeyframesDefinition;
327
343
  name: string;
328
344
  pseudoElement?: string;
329
345
  allowFlatten?: boolean;
330
- transition: ValueAnimationTransition<V>;
331
346
  }
332
347
  interface ValueAnimationOptions<V extends string | number = number> extends ValueAnimationTransition {
333
348
  keyframes: V[];
349
+ element?: any;
334
350
  name?: string;
351
+ motionValue?: MotionValue<V>;
335
352
  from?: V;
336
- isGenerator?: boolean;
353
+ isHandoff?: boolean;
337
354
  allowFlatten?: boolean;
355
+ finalKeyframe?: V;
338
356
  }
339
357
  type GeneratorFactoryFunction = (options: ValueAnimationOptions<any>) => KeyframeGenerator<any>;
340
358
  interface GeneratorFactory extends GeneratorFactoryFunction {
341
- applyToOptions: (options: Transition) => Transition;
359
+ applyToOptions?: (options: Transition) => Transition;
342
360
  }
343
361
  type AnimationGeneratorType = GeneratorFactory | "decay" | "spring" | "keyframes" | "tween" | "inertia";
344
362
  interface AnimationPlaybackLifecycles<V> {
@@ -377,20 +395,6 @@ interface DecayOptions extends VelocityOptions {
377
395
  timeConstant?: number;
378
396
  modifyTarget?: (v: number) => number;
379
397
  }
380
- type EasingFunction = (v: number) => number;
381
- type EasingModifier = (easing: EasingFunction) => EasingFunction;
382
- type BezierDefinition = readonly [number, number, number, number];
383
- type EasingDefinition = BezierDefinition | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
384
- /**
385
- * The easing function to use. Set as one of:
386
- *
387
- * - The name of an in-built easing function.
388
- * - An array of four numbers to define a cubic bezier curve.
389
- * - An easing function, that accepts and returns a progress value between `0` and `1`.
390
- *
391
- * @public
392
- */
393
- type Easing = EasingDefinition | EasingFunction;
394
398
  interface DriverControls {
395
399
  start: () => void;
396
400
  stop: () => void;
@@ -493,441 +497,72 @@ interface SVGPathProperties {
493
497
  pathSpacing?: number;
494
498
  }
495
499
 
496
- type AcceptedAnimations = AnimationPlaybackControls;
497
- type GroupedAnimations = AcceptedAnimations[];
498
- declare class GroupAnimation implements AnimationPlaybackControls {
499
- animations: GroupedAnimations;
500
- constructor(animations: Array<AcceptedAnimations | undefined>);
501
- get finished(): Promise<any[]>;
502
- /**
503
- * TODO: Filter out cancelled or stopped animations before returning
504
- */
505
- private getAll;
506
- private setAll;
507
- attachTimeline(timeline: any, fallback?: (animation: AnimationPlaybackControls) => VoidFunction): () => void;
508
- get time(): number;
509
- set time(time: number);
510
- get speed(): number;
511
- set speed(speed: number);
512
- get startTime(): any;
513
- get duration(): number;
514
- private runAll;
515
- flatten(): void;
516
- play(): void;
517
- pause(): void;
518
- stop: () => void;
519
- cancel(): void;
520
- complete(): void;
500
+ /**
501
+ * @public
502
+ */
503
+ type Subscriber<T> = (v: T) => void;
504
+ /**
505
+ * @public
506
+ */
507
+ type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
508
+ type StartAnimation = (complete: () => void) => AnimationPlaybackControlsWithThen | undefined;
509
+ interface MotionValueEventCallbacks<V> {
510
+ animationStart: () => void;
511
+ animationComplete: () => void;
512
+ animationCancel: () => void;
513
+ change: (latestValue: V) => void;
514
+ renderRequest: () => void;
521
515
  }
522
-
523
- declare class GroupAnimationWithThen extends GroupAnimation implements AnimationPlaybackControlsWithThen {
524
- then(onResolve: VoidFunction, _onReject?: VoidFunction): Promise<void>;
516
+ interface ResolvedValues {
517
+ [key: string]: string | number;
525
518
  }
526
-
527
- interface NativeAnimationOptions<V extends string | number = number> extends DOMValueAnimationOptions<V> {
528
- pseudoElement?: string;
519
+ interface Owner {
520
+ current: HTMLElement | unknown;
521
+ getProps: () => {
522
+ onUpdate?: (latest: ResolvedValues) => void;
523
+ transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
524
+ };
529
525
  }
530
- interface NativeControlsOptions {
531
- animation: Animation;
526
+ interface MotionValueOptions {
527
+ owner?: Owner;
532
528
  }
529
+ declare const collectMotionValues: {
530
+ current: MotionValue[] | undefined;
531
+ };
533
532
  /**
534
- * NativeAnimation implements AnimationPlaybackControls for the browser's Web Animations API.
533
+ * `MotionValue` is used to track the state and velocity of motion values.
534
+ *
535
+ * @public
535
536
  */
536
- declare class NativeAnimation implements AnimationPlaybackControls {
537
+ declare class MotionValue<V = any> {
537
538
  /**
538
- * The interfaced Web Animation API animation
539
+ * This will be replaced by the build step with the latest version number.
540
+ * When MotionValues are provided to motion components, warn if versions are mixed.
539
541
  */
540
- private animation;
541
- private allowFlatten;
542
- private removeAnimation;
543
- private isPseudoElement;
544
- constructor(options: NativeAnimationOptions | NativeControlsOptions);
545
- play(): void;
546
- pause(): void;
547
- complete(): void;
548
- cancel(): void;
549
- stop(): void;
542
+ version: string;
550
543
  /**
551
- * WAAPI doesn't natively have any interruption capabilities.
552
- *
553
- * In this method, we commit styles back to the DOM before cancelling
554
- * the animation.
555
- *
556
- * This is designed to be overridden by NativeAnimationExtended, which
557
- * will create a renderless JS animation and sample it twice to calculate
558
- * its current value, "previous" value, and therefore allow
559
- * Motion to also correctly calculate velocity for any subsequent animation
560
- * while deferring the commit until the next animation frame.
544
+ * If a MotionValue has an owner, it was created internally within Motion
545
+ * and therefore has no external listeners. It is therefore safe to animate via WAAPI.
561
546
  */
562
- private commitStyles;
563
- get duration(): number;
564
- get time(): number;
565
- set time(newTime: number);
547
+ owner?: Owner;
566
548
  /**
567
- * The playback speed of the animation.
568
- * 1 = normal speed, 2 = double speed, 0.5 = half speed.
549
+ * The current state of the `MotionValue`.
569
550
  */
570
- get speed(): number;
571
- set speed(newSpeed: number);
572
- get state(): AnimationPlayState;
573
- get startTime(): number;
574
- get finished(): Promise<Animation>;
575
- flatten(): void;
551
+ private current;
576
552
  /**
577
- * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
553
+ * The previous state of the `MotionValue`.
578
554
  */
579
- attachTimeline(timeline: ProgressTimeline): VoidFunction;
555
+ private prev;
580
556
  /**
581
- * Allows the animation to be awaited.
582
- *
583
- * @deprecated Use `finished` instead.
557
+ * The previous state of the `MotionValue` at the end of the previous frame.
584
558
  */
585
- then(onResolve: VoidFunction, onReject?: VoidFunction): Promise<void>;
586
- }
587
-
588
- declare function getValueTransition(transition: any, key: string): any;
589
-
590
- /**
591
- * Implement a practical max duration for keyframe generation
592
- * to prevent infinite loops
593
- */
594
- declare const maxGeneratorDuration = 20000;
595
- declare function calcGeneratorDuration(generator: KeyframeGenerator<unknown>): number;
596
-
597
- /**
598
- * Create a progress => progress easing function from a generator.
599
- */
600
- declare function createGeneratorEasing(options: Transition, scale: number | undefined, createGenerator: GeneratorFactory): {
601
- type: string;
602
- ease: (progress: number) => number;
603
- duration: number;
604
- };
605
-
606
- declare function isGenerator(type?: AnimationGeneratorType): type is GeneratorFactory;
607
-
608
- declare const cubicBezierAsString: ([a, b, c, d]: BezierDefinition) => string;
609
-
610
- declare function isWaapiSupportedEasing(easing?: Easing | Easing[]): boolean;
611
-
612
- declare function mapEasingToNativeEasing(easing: Easing | Easing[] | undefined, duration: number): undefined | string | string[];
613
-
614
- declare const supportedWaapiEasing: {
615
- linear: string;
616
- ease: string;
617
- easeIn: string;
618
- easeOut: string;
619
- easeInOut: string;
620
- circIn: string;
621
- circOut: string;
622
- backIn: string;
623
- backOut: string;
624
- };
625
-
626
- declare function startWaapiAnimation(element: Element, valueName: string, keyframes: ValueKeyframesDefinition, { delay, duration, repeat, repeatType, ease, times, }?: Transition, pseudoElement?: string | undefined): Animation;
627
-
628
- declare function attachTimeline(animation: Animation, timeline: any): void;
629
-
630
- declare const generateLinearEasing: (easing: EasingFunction, duration: number, resolution?: number) => string;
631
-
632
- declare const frame: Batcher;
633
- declare const cancelFrame: (process: Process) => void;
634
- declare const frameData: FrameData;
635
- declare const frameSteps: Steps;
636
-
637
- type Process = (data: FrameData) => void;
638
- type Schedule = (process: Process, keepAlive?: boolean, immediate?: boolean) => Process;
639
- interface Step {
640
- schedule: Schedule;
641
- cancel: (process: Process) => void;
642
- process: (data: FrameData) => void;
643
- }
644
- type StepId = "read" | "resolveKeyframes" | "update" | "preRender" | "render" | "postRender";
645
- type CancelProcess = (process: Process) => void;
646
- type Batcher = {
647
- [key in StepId]: Schedule;
648
- };
649
- type Steps = {
650
- [key in StepId]: Step;
651
- };
652
- interface FrameData {
653
- delta: number;
654
- timestamp: number;
655
- isProcessing: boolean;
656
- }
657
-
658
- declare function createRenderBatcher(scheduleNextBatch: (callback: Function) => void, allowKeepAlive: boolean): {
659
- schedule: Batcher;
660
- cancel: (process: Process) => void;
661
- state: FrameData;
662
- steps: Steps;
663
- };
664
-
665
- declare const microtask: Batcher;
666
- declare const cancelMicrotask: (process: Process) => void;
667
-
668
- /**
669
- * An eventloop-synchronous alternative to performance.now().
670
- *
671
- * Ensures that time measurements remain consistent within a synchronous context.
672
- * Usually calling performance.now() twice within the same synchronous context
673
- * will return different values which isn't useful for animations when we're usually
674
- * trying to sync animations to the same frame.
675
- */
676
- declare const time: {
677
- now: () => number;
678
- set: (newTime: number) => void;
679
- };
680
-
681
- declare const isDragging: {
682
- x: boolean;
683
- y: boolean;
684
- };
685
- declare function isDragActive(): boolean;
686
-
687
- declare function setDragLock(axis: boolean | "x" | "y" | "lockDirection"): (() => void) | null;
688
-
689
- type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
690
- interface WithQuerySelectorAll {
691
- querySelectorAll: Element["querySelectorAll"];
692
- }
693
- interface AnimationScope<T = any> {
694
- readonly current: T;
695
- animations: any[];
696
- }
697
- interface SelectorCache {
698
- [key: string]: NodeListOf<Element>;
699
- }
700
- declare function resolveElements(elementOrSelector: ElementOrSelector, scope?: AnimationScope, selectorCache?: SelectorCache): Element[];
701
-
702
- /**
703
- * Options for the hover gesture.
704
- *
705
- * @public
706
- */
707
- interface EventOptions {
559
+ private prevFrameValue;
708
560
  /**
709
- * Use passive event listeners. Doing so allows the browser to optimize
710
- * scrolling performance by not allowing the use of `preventDefault()`.
711
- *
712
- * @default true
561
+ * The last time the `MotionValue` was updated.
713
562
  */
714
- passive?: boolean;
563
+ updatedAt: number;
715
564
  /**
716
- * Remove the event listener after the first event.
717
- *
718
- * @default false
719
- */
720
- once?: boolean;
721
- }
722
-
723
- /**
724
- * A function to be called when a hover gesture starts.
725
- *
726
- * This function can optionally return a function that will be called
727
- * when the hover gesture ends.
728
- *
729
- * @public
730
- */
731
- type OnHoverStartEvent = (element: Element, event: PointerEvent) => void | OnHoverEndEvent;
732
- /**
733
- * A function to be called when a hover gesture ends.
734
- *
735
- * @public
736
- */
737
- type OnHoverEndEvent = (event: PointerEvent) => void;
738
- /**
739
- * Create a hover gesture. hover() is different to .addEventListener("pointerenter")
740
- * in that it has an easier syntax, filters out polyfilled touch events, interoperates
741
- * with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
742
- *
743
- * @public
744
- */
745
- declare function hover(elementOrSelector: ElementOrSelector, onHoverStart: OnHoverStartEvent, options?: EventOptions): VoidFunction;
746
-
747
- interface PressGestureInfo {
748
- success: boolean;
749
- }
750
- type OnPressEndEvent = (event: PointerEvent, info: PressGestureInfo) => void;
751
- type OnPressStartEvent = (element: Element, event: PointerEvent) => OnPressEndEvent | void;
752
-
753
- interface PointerEventOptions extends EventOptions {
754
- useGlobalTarget?: boolean;
755
- }
756
- /**
757
- * Create a press gesture.
758
- *
759
- * Press is different to `"pointerdown"`, `"pointerup"` in that it
760
- * automatically filters out secondary pointer events like right
761
- * click and multitouch.
762
- *
763
- * It also adds accessibility support for keyboards, where
764
- * an element with a press gesture will receive focus and
765
- * trigger on Enter `"keydown"` and `"keyup"` events.
766
- *
767
- * This is different to a browser's `"click"` event, which does
768
- * respond to keyboards but only for the `"click"` itself, rather
769
- * than the press start and end/cancel. The element also needs
770
- * to be focusable for this to work, whereas a press gesture will
771
- * make an element focusable by default.
772
- *
773
- * @public
774
- */
775
- declare function press(targetOrSelector: ElementOrSelector, onPressStart: OnPressStartEvent, options?: PointerEventOptions): VoidFunction;
776
-
777
- /**
778
- * Recursively traverse up the tree to check whether the provided child node
779
- * is the parent or a descendant of it.
780
- *
781
- * @param parent - Element to find
782
- * @param child - Element to test against parent
783
- */
784
- declare const isNodeOrChild: (parent: Element | null, child?: Element | null) => boolean;
785
-
786
- declare const isPrimaryPointer: (event: PointerEvent) => boolean;
787
-
788
- declare const stepsOrder: StepId[];
789
- type StepNames = (typeof stepsOrder)[number];
790
-
791
- interface Summary {
792
- min: number;
793
- max: number;
794
- avg: number;
795
- }
796
- type FrameloopStatNames = "rate" | StepNames;
797
- interface Stats<T> {
798
- frameloop: {
799
- [key in FrameloopStatNames]: T;
800
- };
801
- animations: {
802
- mainThread: T;
803
- waapi: T;
804
- layout: T;
805
- };
806
- layoutProjection: {
807
- nodes: T;
808
- calculatedTargetDeltas: T;
809
- calculatedProjections: T;
810
- };
811
- }
812
- type StatsBuffer = number[];
813
- type FrameStats = Stats<number>;
814
- type StatsRecording = Stats<StatsBuffer>;
815
- type StatsSummary = Stats<Summary>;
816
-
817
- declare function reportStats(): StatsSummary;
818
- declare function recordStats(): typeof reportStats;
819
-
820
- declare const activeAnimations: {
821
- layout: number;
822
- mainThread: number;
823
- waapi: number;
824
- };
825
-
826
- type InactiveStatsBuffer = {
827
- value: null;
828
- addProjectionMetrics: null;
829
- };
830
- type ActiveStatsBuffer = {
831
- value: StatsRecording;
832
- addProjectionMetrics: (metrics: {
833
- nodes: number;
834
- calculatedTargetDeltas: number;
835
- calculatedProjections: number;
836
- }) => void;
837
- };
838
- declare const statsBuffer: InactiveStatsBuffer | ActiveStatsBuffer;
839
-
840
- declare const isBezierDefinition: (easing: Easing | Easing[]) => easing is BezierDefinition;
841
-
842
- /**
843
- * Add the ability for test suites to manually set support flags
844
- * to better test more environments.
845
- */
846
- declare const supportsFlags: Record<string, boolean | undefined>;
847
-
848
- declare const supportsLinearEasing: () => boolean;
849
-
850
- declare global {
851
- interface Window {
852
- ScrollTimeline: ScrollTimeline;
853
- }
854
- }
855
- declare class ScrollTimeline implements ProgressTimeline {
856
- constructor(options: ScrollOptions);
857
- currentTime: null | {
858
- value: number;
859
- };
860
- cancel?: VoidFunction;
861
- }
862
- declare const supportsScrollTimeline: () => boolean;
863
-
864
- type Transformer<T> = (v: T) => T;
865
- /**
866
- * @public
867
- */
868
- type Subscriber<T> = (v: T) => void;
869
- /**
870
- * @public
871
- */
872
- type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void;
873
- type StartAnimation = (complete: () => void) => AnimationPlaybackControlsWithThen | undefined;
874
- interface MotionValueEventCallbacks<V> {
875
- animationStart: () => void;
876
- animationComplete: () => void;
877
- animationCancel: () => void;
878
- change: (latestValue: V) => void;
879
- renderRequest: () => void;
880
- }
881
- interface ResolvedValues {
882
- [key: string]: string | number;
883
- }
884
- interface Owner {
885
- current: HTMLElement | unknown;
886
- getProps: () => {
887
- onUpdate?: (latest: ResolvedValues) => void;
888
- transformTemplate?: (transform: TransformProperties, generatedTransform: string) => string;
889
- };
890
- }
891
- interface MotionValueOptions {
892
- owner?: Owner;
893
- }
894
- declare const collectMotionValues: {
895
- current: MotionValue[] | undefined;
896
- };
897
- /**
898
- * `MotionValue` is used to track the state and velocity of motion values.
899
- *
900
- * @public
901
- */
902
- declare class MotionValue<V = any> {
903
- /**
904
- * This will be replaced by the build step with the latest version number.
905
- * When MotionValues are provided to motion components, warn if versions are mixed.
906
- */
907
- version: string;
908
- /**
909
- * If a MotionValue has an owner, it was created internally within Motion
910
- * and therefore has no external listeners. It is therefore safe to animate via WAAPI.
911
- */
912
- owner?: Owner;
913
- /**
914
- * The current state of the `MotionValue`.
915
- */
916
- private current;
917
- /**
918
- * The previous state of the `MotionValue`.
919
- */
920
- private prev;
921
- /**
922
- * The previous state of the `MotionValue` at the end of the previous frame.
923
- */
924
- private prevFrameValue;
925
- /**
926
- * The last time the `MotionValue` was updated.
927
- */
928
- updatedAt: number;
929
- /**
930
- * The time `prevFrameValue` was updated.
565
+ * The time `prevFrameValue` was updated.
931
566
  */
932
567
  prevUpdatedAt: number | undefined;
933
568
  private stopPassiveEffect?;
@@ -1080,6 +715,872 @@ declare class MotionValue<V = any> {
1080
715
  }
1081
716
  declare function motionValue<V>(init: V, options?: MotionValueOptions): MotionValue<V>;
1082
717
 
718
+ type UnresolvedKeyframes<T extends string | number> = Array<T | null>;
719
+ type ResolvedKeyframes<T extends string | number> = Array<T>;
720
+ declare function flushKeyframeResolvers(): void;
721
+ type OnKeyframesResolved<T extends string | number> = (resolvedKeyframes: ResolvedKeyframes<T>, finalKeyframe: T, forced: boolean) => void;
722
+ declare class KeyframeResolver<T extends string | number = any> {
723
+ name?: string;
724
+ element?: WithRender;
725
+ finalKeyframe?: T;
726
+ suspendedScrollY?: number;
727
+ protected unresolvedKeyframes: UnresolvedKeyframes<string | number>;
728
+ private motionValue?;
729
+ private onComplete;
730
+ /**
731
+ * Track whether this resolver has completed. Once complete, it never
732
+ * needs to attempt keyframe resolution again.
733
+ */
734
+ private isComplete;
735
+ /**
736
+ * Track whether this resolver is async. If it is, it'll be added to the
737
+ * resolver queue and flushed in the next frame. Resolvers that aren't going
738
+ * to trigger read/write thrashing don't need to be async.
739
+ */
740
+ private isAsync;
741
+ /**
742
+ * Track whether this resolver needs to perform a measurement
743
+ * to resolve its keyframes.
744
+ */
745
+ needsMeasurement: boolean;
746
+ /**
747
+ * Track whether this resolver is currently scheduled to resolve
748
+ * to allow it to be cancelled and resumed externally.
749
+ */
750
+ isScheduled: boolean;
751
+ constructor(unresolvedKeyframes: UnresolvedKeyframes<string | number>, onComplete: OnKeyframesResolved<T>, name?: string, motionValue?: MotionValue<T>, element?: WithRender, isAsync?: boolean);
752
+ scheduleResolve(): void;
753
+ readKeyframes(): void;
754
+ setFinalKeyframe(): void;
755
+ measureInitialState(): void;
756
+ renderEndStyles(): void;
757
+ measureEndState(): void;
758
+ complete(isForced?: boolean): void;
759
+ cancel(): void;
760
+ resume(): void;
761
+ }
762
+
763
+ declare class WithPromise {
764
+ protected _finished: Promise<void>;
765
+ resolve: VoidFunction;
766
+ count: number;
767
+ constructor();
768
+ get finished(): Promise<void>;
769
+ protected updateFinished(): void;
770
+ protected notifyFinished(): void;
771
+ /**
772
+ * Allows the animation to be awaited.
773
+ *
774
+ * @deprecated Use `finished` instead.
775
+ */
776
+ then(onResolve: VoidFunction, onReject?: VoidFunction): Promise<void>;
777
+ }
778
+
779
+ type OptionsWithoutKeyframes<T extends string | number> = Omit<ValueAnimationOptions<T>, "keyframes">;
780
+ declare class AsyncMotionValueAnimation<T extends string | number> extends WithPromise implements AnimationPlaybackControls {
781
+ private createdAt;
782
+ private resolvedAt;
783
+ private _animation;
784
+ private pendingTimeline;
785
+ private keyframeResolver;
786
+ private stopTimeline;
787
+ constructor({ autoplay, delay, type, repeat, repeatDelay, repeatType, keyframes, name, motionValue, element, ...options }: ValueAnimationOptions<T>);
788
+ onKeyframesResolved(keyframes: ResolvedKeyframes<T>, finalKeyframe: T, options: OptionsWithoutKeyframes<T>, sync: boolean): void;
789
+ get finished(): Promise<any>;
790
+ then(onResolve: VoidFunction, _onReject?: VoidFunction): Promise<void>;
791
+ get animation(): AnimationPlaybackControls;
792
+ get duration(): number;
793
+ get time(): number;
794
+ set time(newTime: number);
795
+ get speed(): number;
796
+ get state(): AnimationPlayState;
797
+ set speed(newSpeed: number);
798
+ get startTime(): number | null;
799
+ attachTimeline(timeline: TimelineWithFallback): () => void;
800
+ play(): void;
801
+ pause(): void;
802
+ complete(): void;
803
+ cancel(): void;
804
+ /**
805
+ * Bound to support return animation.stop pattern
806
+ */
807
+ stop: () => void;
808
+ }
809
+
810
+ type AcceptedAnimations = AnimationPlaybackControls;
811
+ type GroupedAnimations = AcceptedAnimations[];
812
+ declare class GroupAnimation implements AnimationPlaybackControls {
813
+ animations: GroupedAnimations;
814
+ constructor(animations: Array<AcceptedAnimations | undefined>);
815
+ get finished(): Promise<any[]>;
816
+ /**
817
+ * TODO: Filter out cancelled or stopped animations before returning
818
+ */
819
+ private getAll;
820
+ private setAll;
821
+ attachTimeline(timeline: TimelineWithFallback): () => void;
822
+ get time(): number;
823
+ set time(time: number);
824
+ get speed(): number;
825
+ set speed(speed: number);
826
+ get state(): any;
827
+ get startTime(): any;
828
+ get duration(): number;
829
+ private runAll;
830
+ play(): void;
831
+ pause(): void;
832
+ stop: () => void;
833
+ cancel(): void;
834
+ complete(): void;
835
+ }
836
+
837
+ declare class GroupAnimationWithThen extends GroupAnimation implements AnimationPlaybackControlsWithThen {
838
+ then(onResolve: VoidFunction, _onReject?: VoidFunction): Promise<void>;
839
+ }
840
+
841
+ declare class JSAnimation<T extends number | string> extends WithPromise implements AnimationPlaybackControlsWithThen {
842
+ state: AnimationPlayState;
843
+ startTime: number | null;
844
+ /**
845
+ * The driver that's controlling the animation loop. Normally this is a requestAnimationFrame loop
846
+ * but in tests we can pass in a synchronous loop.
847
+ */
848
+ private driver?;
849
+ private isStopped;
850
+ private generator;
851
+ private calculatedDuration;
852
+ private resolvedDuration;
853
+ private totalDuration;
854
+ private options;
855
+ /**
856
+ * The current time of the animation.
857
+ */
858
+ private currentTime;
859
+ /**
860
+ * The time at which the animation was paused.
861
+ */
862
+ private holdTime;
863
+ /**
864
+ * Playback speed as a factor. 0 would be stopped, -1 reverse and 2 double speed.
865
+ */
866
+ private playbackSpeed;
867
+ private mixKeyframes;
868
+ private mirroredGenerator;
869
+ constructor(options: ValueAnimationOptions<T>);
870
+ initAnimation(): void;
871
+ updateTime(timestamp: number): void;
872
+ tick(timestamp: number, sample?: boolean): AnimationState<T>;
873
+ /**
874
+ * Allows the returned animation to be awaited or promise-chained. Currently
875
+ * resolves when the animation finishes at all but in a future update could/should
876
+ * reject if its cancels.
877
+ */
878
+ then(resolve: VoidFunction, reject?: VoidFunction): Promise<void>;
879
+ get duration(): number;
880
+ get time(): number;
881
+ set time(newTime: number);
882
+ get speed(): number;
883
+ set speed(newSpeed: number);
884
+ play(): void;
885
+ pause(): void;
886
+ /**
887
+ * This method is bound to the instance to fix a pattern where
888
+ * animation.stop is returned as a reference from a useEffect.
889
+ */
890
+ stop: () => void;
891
+ complete(): void;
892
+ finish(): void;
893
+ cancel(): void;
894
+ private teardown;
895
+ private stopDriver;
896
+ sample(sampleTime: number): AnimationState<T>;
897
+ attachTimeline(timeline: TimelineWithFallback): VoidFunction;
898
+ }
899
+ declare function animateValue<T extends number | string>(options: ValueAnimationOptions<T>): JSAnimation<T>;
900
+
901
+ interface NativeAnimationOptions<V extends string | number = number> extends DOMValueAnimationOptions<V> {
902
+ pseudoElement?: string;
903
+ startTime?: number;
904
+ }
905
+ /**
906
+ * NativeAnimation implements AnimationPlaybackControls for the browser's Web Animations API.
907
+ */
908
+ declare class NativeAnimation<T extends string | number> extends WithPromise implements AnimationPlaybackControlsWithThen {
909
+ /**
910
+ * The interfaced Web Animation API animation
911
+ */
912
+ protected animation: Animation;
913
+ protected finishedTime: number | null;
914
+ protected options: NativeAnimationOptions;
915
+ private allowFlatten;
916
+ private isStopped;
917
+ private isPseudoElement;
918
+ constructor(options?: NativeAnimationOptions);
919
+ updateMotionValue?(value?: T): void;
920
+ play(): void;
921
+ pause(): void;
922
+ complete(): void;
923
+ cancel(): void;
924
+ stop(): void;
925
+ /**
926
+ * WAAPI doesn't natively have any interruption capabilities.
927
+ *
928
+ * In this method, we commit styles back to the DOM before cancelling
929
+ * the animation.
930
+ *
931
+ * This is designed to be overridden by NativeAnimationExtended, which
932
+ * will create a renderless JS animation and sample it twice to calculate
933
+ * its current value, "previous" value, and therefore allow
934
+ * Motion to also correctly calculate velocity for any subsequent animation
935
+ * while deferring the commit until the next animation frame.
936
+ */
937
+ protected commitStyles(): void;
938
+ get duration(): number;
939
+ get time(): number;
940
+ set time(newTime: number);
941
+ /**
942
+ * The playback speed of the animation.
943
+ * 1 = normal speed, 2 = double speed, 0.5 = half speed.
944
+ */
945
+ get speed(): number;
946
+ set speed(newSpeed: number);
947
+ get state(): AnimationPlayState;
948
+ get startTime(): number;
949
+ set startTime(newStartTime: number);
950
+ /**
951
+ * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
952
+ */
953
+ attachTimeline({ timeline, observe }: TimelineWithFallback): VoidFunction;
954
+ }
955
+
956
+ type NativeAnimationOptionsExtended<T extends string | number> = NativeAnimationOptions & ValueAnimationOptions<T> & NativeAnimationOptions;
957
+ declare class NativeAnimationExtended<T extends string | number> extends NativeAnimation<T> {
958
+ options: NativeAnimationOptionsExtended<T>;
959
+ constructor(options: NativeAnimationOptionsExtended<T>);
960
+ /**
961
+ * WAAPI doesn't natively have any interruption capabilities.
962
+ *
963
+ * Rather than read commited styles back out of the DOM, we can
964
+ * create a renderless JS animation and sample it twice to calculate
965
+ * its current value, "previous" value, and therefore allow
966
+ * Motion to calculate velocity for any subsequent animation.
967
+ */
968
+ updateMotionValue(value?: T): void;
969
+ }
970
+
971
+ declare class NativeAnimationWrapper<T extends string | number> extends NativeAnimation<T> {
972
+ constructor(animation: Animation);
973
+ }
974
+
975
+ declare const animationMapKey: (name: string, pseudoElement?: string) => string;
976
+ declare function getAnimationMap(element: Element): Map<any, any>;
977
+
978
+ type CSSVariableName = `--${string}`;
979
+ type CSSVariableToken = `var(${CSSVariableName})`;
980
+ declare const isCSSVariableName: (key?: string | number | null) => key is `--${string}`;
981
+ declare const isCSSVariableToken: (value?: string) => value is `var(--${string})`;
982
+
983
+ declare function parseCSSVariable(current: string): string[] | undefined[];
984
+ declare function getVariableValue(current: CSSVariableToken, element: Element, depth?: number): string | number | undefined;
985
+
986
+ declare function getValueTransition(transition: any, key: string): any;
987
+
988
+ declare function inertia({ keyframes, velocity, power, timeConstant, bounceDamping, bounceStiffness, modifyTarget, min, max, restDelta, restSpeed, }: ValueAnimationOptions<number>): KeyframeGenerator<number>;
989
+
990
+ declare function defaultEasing(values: any[], easing?: EasingFunction): EasingFunction[];
991
+ declare function keyframes<T extends string | number>({ duration, keyframes: keyframeValues, times, ease, }: ValueAnimationOptions<T>): KeyframeGenerator<T>;
992
+
993
+ declare function spring(optionsOrVisualDuration?: ValueAnimationOptions<number> | number, bounce?: number): KeyframeGenerator<number>;
994
+ declare namespace spring {
995
+ var applyToOptions: (options: Transition) => Transition;
996
+ }
997
+
998
+ /**
999
+ * Implement a practical max duration for keyframe generation
1000
+ * to prevent infinite loops
1001
+ */
1002
+ declare const maxGeneratorDuration = 20000;
1003
+ declare function calcGeneratorDuration(generator: KeyframeGenerator<unknown>): number;
1004
+
1005
+ /**
1006
+ * Create a progress => progress easing function from a generator.
1007
+ */
1008
+ declare function createGeneratorEasing(options: Transition, scale: number | undefined, createGenerator: GeneratorFactory): {
1009
+ type: string;
1010
+ ease: (progress: number) => number;
1011
+ duration: number;
1012
+ };
1013
+
1014
+ declare function isGenerator(type?: AnimationGeneratorType): type is GeneratorFactory;
1015
+
1016
+ declare class DOMKeyframesResolver<T extends string | number> extends KeyframeResolver<T> {
1017
+ name: string;
1018
+ element?: WithRender;
1019
+ private removedTransforms?;
1020
+ private measuredOrigin?;
1021
+ constructor(unresolvedKeyframes: UnresolvedKeyframes<string | number>, onComplete: OnKeyframesResolved<T>, name?: string, motionValue?: MotionValue<T>, element?: WithRender);
1022
+ readKeyframes(): void;
1023
+ resolveNoneKeyframes(): void;
1024
+ measureInitialState(): void;
1025
+ measureEndState(): void;
1026
+ }
1027
+
1028
+ declare function defaultOffset(arr: any[]): number[];
1029
+
1030
+ declare function fillOffset(offset: number[], remaining: number): void;
1031
+
1032
+ declare function convertOffsetToTimes(offset: number[], duration: number): number[];
1033
+
1034
+ declare function applyPxDefaults(keyframes: ValueKeyframe[] | UnresolvedValueKeyframe[], name: string): void;
1035
+
1036
+ declare function fillWildcards(keyframes: ValueKeyframe[] | UnresolvedValueKeyframe[]): void;
1037
+
1038
+ declare const cubicBezierAsString: ([a, b, c, d]: BezierDefinition) => string;
1039
+
1040
+ declare function isWaapiSupportedEasing(easing?: Easing | Easing[]): boolean;
1041
+
1042
+ declare function mapEasingToNativeEasing(easing: Easing | Easing[] | undefined, duration: number): undefined | string | string[];
1043
+
1044
+ declare const supportedWaapiEasing: {
1045
+ linear: string;
1046
+ ease: string;
1047
+ easeIn: string;
1048
+ easeOut: string;
1049
+ easeInOut: string;
1050
+ circIn: string;
1051
+ circOut: string;
1052
+ backIn: string;
1053
+ backOut: string;
1054
+ };
1055
+
1056
+ declare function startWaapiAnimation(element: Element, valueName: string, keyframes: ValueKeyframesDefinition, { delay, duration, repeat, repeatType, ease, times, }?: Transition, pseudoElement?: string | undefined): Animation;
1057
+
1058
+ declare const supportsPartialKeyframes: () => boolean;
1059
+
1060
+ declare function supportsBrowserAnimation<T extends string | number>(options: ValueAnimationOptionsWithRenderContext<T>): any;
1061
+
1062
+ /**
1063
+ * A list of values that can be hardware-accelerated.
1064
+ */
1065
+ declare const acceleratedValues: Set<string>;
1066
+
1067
+ declare const generateLinearEasing: (easing: EasingFunction, duration: number, resolution?: number) => string;
1068
+
1069
+ declare const frame: Batcher;
1070
+ declare const cancelFrame: (process: Process) => void;
1071
+ declare const frameData: FrameData;
1072
+ declare const frameSteps: Steps;
1073
+
1074
+ type Process = (data: FrameData) => void;
1075
+ type Schedule = (process: Process, keepAlive?: boolean, immediate?: boolean) => Process;
1076
+ interface Step {
1077
+ schedule: Schedule;
1078
+ cancel: (process: Process) => void;
1079
+ process: (data: FrameData) => void;
1080
+ }
1081
+ type StepId = "setup" | "read" | "resolveKeyframes" | "update" | "preRender" | "render" | "postRender";
1082
+ type CancelProcess = (process: Process) => void;
1083
+ type Batcher = {
1084
+ [key in StepId]: Schedule;
1085
+ };
1086
+ type Steps = {
1087
+ [key in StepId]: Step;
1088
+ };
1089
+ interface FrameData {
1090
+ delta: number;
1091
+ timestamp: number;
1092
+ isProcessing: boolean;
1093
+ }
1094
+
1095
+ declare function createRenderBatcher(scheduleNextBatch: (callback: Function) => void, allowKeepAlive: boolean): {
1096
+ schedule: Batcher;
1097
+ cancel: (process: Process) => void;
1098
+ state: FrameData;
1099
+ steps: Steps;
1100
+ };
1101
+
1102
+ declare const microtask: Batcher;
1103
+ declare const cancelMicrotask: (process: Process) => void;
1104
+
1105
+ /**
1106
+ * An eventloop-synchronous alternative to performance.now().
1107
+ *
1108
+ * Ensures that time measurements remain consistent within a synchronous context.
1109
+ * Usually calling performance.now() twice within the same synchronous context
1110
+ * will return different values which isn't useful for animations when we're usually
1111
+ * trying to sync animations to the same frame.
1112
+ */
1113
+ declare const time: {
1114
+ now: () => number;
1115
+ set: (newTime: number) => void;
1116
+ };
1117
+
1118
+ declare const isDragging: {
1119
+ x: boolean;
1120
+ y: boolean;
1121
+ };
1122
+ declare function isDragActive(): boolean;
1123
+
1124
+ declare function setDragLock(axis: boolean | "x" | "y" | "lockDirection"): (() => void) | null;
1125
+
1126
+ type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
1127
+ interface WithQuerySelectorAll {
1128
+ querySelectorAll: Element["querySelectorAll"];
1129
+ }
1130
+ interface AnimationScope<T = any> {
1131
+ readonly current: T;
1132
+ animations: any[];
1133
+ }
1134
+ interface SelectorCache {
1135
+ [key: string]: NodeListOf<Element>;
1136
+ }
1137
+ declare function resolveElements(elementOrSelector: ElementOrSelector, scope?: AnimationScope, selectorCache?: SelectorCache): Element[];
1138
+
1139
+ /**
1140
+ * Options for the hover gesture.
1141
+ *
1142
+ * @public
1143
+ */
1144
+ interface EventOptions {
1145
+ /**
1146
+ * Use passive event listeners. Doing so allows the browser to optimize
1147
+ * scrolling performance by not allowing the use of `preventDefault()`.
1148
+ *
1149
+ * @default true
1150
+ */
1151
+ passive?: boolean;
1152
+ /**
1153
+ * Remove the event listener after the first event.
1154
+ *
1155
+ * @default false
1156
+ */
1157
+ once?: boolean;
1158
+ }
1159
+
1160
+ /**
1161
+ * A function to be called when a hover gesture starts.
1162
+ *
1163
+ * This function can optionally return a function that will be called
1164
+ * when the hover gesture ends.
1165
+ *
1166
+ * @public
1167
+ */
1168
+ type OnHoverStartEvent = (element: Element, event: PointerEvent) => void | OnHoverEndEvent;
1169
+ /**
1170
+ * A function to be called when a hover gesture ends.
1171
+ *
1172
+ * @public
1173
+ */
1174
+ type OnHoverEndEvent = (event: PointerEvent) => void;
1175
+ /**
1176
+ * Create a hover gesture. hover() is different to .addEventListener("pointerenter")
1177
+ * in that it has an easier syntax, filters out polyfilled touch events, interoperates
1178
+ * with drag gestures, and automatically removes the "pointerennd" event listener when the hover ends.
1179
+ *
1180
+ * @public
1181
+ */
1182
+ declare function hover(elementOrSelector: ElementOrSelector, onHoverStart: OnHoverStartEvent, options?: EventOptions): VoidFunction;
1183
+
1184
+ interface PressGestureInfo {
1185
+ success: boolean;
1186
+ }
1187
+ type OnPressEndEvent = (event: PointerEvent, info: PressGestureInfo) => void;
1188
+ type OnPressStartEvent = (element: Element, event: PointerEvent) => OnPressEndEvent | void;
1189
+
1190
+ interface PointerEventOptions extends EventOptions {
1191
+ useGlobalTarget?: boolean;
1192
+ }
1193
+ /**
1194
+ * Create a press gesture.
1195
+ *
1196
+ * Press is different to `"pointerdown"`, `"pointerup"` in that it
1197
+ * automatically filters out secondary pointer events like right
1198
+ * click and multitouch.
1199
+ *
1200
+ * It also adds accessibility support for keyboards, where
1201
+ * an element with a press gesture will receive focus and
1202
+ * trigger on Enter `"keydown"` and `"keyup"` events.
1203
+ *
1204
+ * This is different to a browser's `"click"` event, which does
1205
+ * respond to keyboards but only for the `"click"` itself, rather
1206
+ * than the press start and end/cancel. The element also needs
1207
+ * to be focusable for this to work, whereas a press gesture will
1208
+ * make an element focusable by default.
1209
+ *
1210
+ * @public
1211
+ */
1212
+ declare function press(targetOrSelector: ElementOrSelector, onPressStart: OnPressStartEvent, options?: PointerEventOptions): VoidFunction;
1213
+
1214
+ /**
1215
+ * Recursively traverse up the tree to check whether the provided child node
1216
+ * is the parent or a descendant of it.
1217
+ *
1218
+ * @param parent - Element to find
1219
+ * @param child - Element to test against parent
1220
+ */
1221
+ declare const isNodeOrChild: (parent: Element | null, child?: Element | null) => boolean;
1222
+
1223
+ declare const isPrimaryPointer: (event: PointerEvent) => boolean;
1224
+
1225
+ declare function parseValueFromTransform(transform: string | undefined, name: string): number;
1226
+ declare const readTransformValue: (instance: HTMLElement, name: string) => number;
1227
+
1228
+ declare function getComputedStyle(element: HTMLElement | SVGElement, name: string): string;
1229
+
1230
+ declare function setStyle(element: HTMLElement | SVGElement, name: string, value: string | number): void;
1231
+
1232
+ declare const positionalKeys: Set<string>;
1233
+
1234
+ /**
1235
+ * Generate a list of every possible transform key.
1236
+ */
1237
+ declare const transformPropOrder: string[];
1238
+ /**
1239
+ * A quick lookup for transform props.
1240
+ */
1241
+ declare const transformProps: Set<string>;
1242
+
1243
+ type Update = (progress: number) => void;
1244
+ declare function observeTimeline(update: Update, timeline: ProgressTimeline): () => void;
1245
+
1246
+ declare const stepsOrder: StepId[];
1247
+ type StepNames = (typeof stepsOrder)[number];
1248
+
1249
+ interface Summary {
1250
+ min: number;
1251
+ max: number;
1252
+ avg: number;
1253
+ }
1254
+ type FrameloopStatNames = "rate" | StepNames;
1255
+ interface Stats<T> {
1256
+ frameloop: {
1257
+ [key in FrameloopStatNames]: T;
1258
+ };
1259
+ animations: {
1260
+ mainThread: T;
1261
+ waapi: T;
1262
+ layout: T;
1263
+ };
1264
+ layoutProjection: {
1265
+ nodes: T;
1266
+ calculatedTargetDeltas: T;
1267
+ calculatedProjections: T;
1268
+ };
1269
+ }
1270
+ type StatsBuffer = number[];
1271
+ type FrameStats = Stats<number>;
1272
+ type StatsRecording = Stats<StatsBuffer>;
1273
+ type StatsSummary = Stats<Summary>;
1274
+
1275
+ declare function reportStats(): StatsSummary;
1276
+ declare function recordStats(): typeof reportStats;
1277
+
1278
+ declare const activeAnimations: {
1279
+ layout: number;
1280
+ mainThread: number;
1281
+ waapi: number;
1282
+ };
1283
+
1284
+ type InactiveStatsBuffer = {
1285
+ value: null;
1286
+ addProjectionMetrics: null;
1287
+ };
1288
+ type ActiveStatsBuffer = {
1289
+ value: StatsRecording;
1290
+ addProjectionMetrics: (metrics: {
1291
+ nodes: number;
1292
+ calculatedTargetDeltas: number;
1293
+ calculatedProjections: number;
1294
+ }) => void;
1295
+ };
1296
+ declare const statsBuffer: InactiveStatsBuffer | ActiveStatsBuffer;
1297
+
1298
+ type Mixer<T> = (p: number) => T;
1299
+ type MixerFactory<T> = (a: T, b: T) => Mixer<T>;
1300
+
1301
+ interface InterpolateOptions<T> {
1302
+ clamp?: boolean;
1303
+ ease?: EasingFunction | EasingFunction[];
1304
+ mixer?: MixerFactory<T>;
1305
+ }
1306
+ /**
1307
+ * Create a function that maps from a numerical input array to a generic output array.
1308
+ *
1309
+ * Accepts:
1310
+ * - Numbers
1311
+ * - Colors (hex, hsl, hsla, rgb, rgba)
1312
+ * - Complex (combinations of one or more numbers or strings)
1313
+ *
1314
+ * ```jsx
1315
+ * const mixColor = interpolate([0, 1], ['#fff', '#000'])
1316
+ *
1317
+ * mixColor(0.5) // 'rgba(128, 128, 128, 1)'
1318
+ * ```
1319
+ *
1320
+ * TODO Revist this approach once we've moved to data models for values,
1321
+ * probably not needed to pregenerate mixer functions.
1322
+ *
1323
+ * @public
1324
+ */
1325
+ declare function interpolate<T>(input: number[], output: T[], { clamp: isClamp, ease, mixer }?: InterpolateOptions<T>): (v: number) => T;
1326
+
1327
+ declare function mix<T>(from: T, to: T): Mixer<T>;
1328
+ declare function mix(from: number, to: number, p: number): number;
1329
+
1330
+ type Transformer = (v: any) => any;
1331
+ type ValueType = {
1332
+ test: (v: any) => boolean;
1333
+ parse: (v: any) => any;
1334
+ transform?: Transformer;
1335
+ createTransformer?: (template: string) => Transformer;
1336
+ default?: any;
1337
+ getAnimatableNone?: (v: any) => any;
1338
+ };
1339
+ type NumberMap = {
1340
+ [key: string]: number;
1341
+ };
1342
+ type RGBA = {
1343
+ red: number;
1344
+ green: number;
1345
+ blue: number;
1346
+ alpha: number;
1347
+ };
1348
+ type HSLA = {
1349
+ hue: number;
1350
+ saturation: number;
1351
+ lightness: number;
1352
+ alpha: number;
1353
+ };
1354
+ type Color = HSLA | RGBA;
1355
+
1356
+ declare const mixLinearColor: (from: number, to: number, v: number) => number;
1357
+ declare const mixColor: (from: Color | string, to: Color | string) => (p: number) => string | Color;
1358
+
1359
+ type MixableArray = Array<number | RGBA | HSLA | string>;
1360
+ type MixableObject = {
1361
+ [key: string]: string | number | RGBA | HSLA;
1362
+ };
1363
+ declare function getMixer<T>(a: T): ((from: string | Color, to: string | Color) => (p: number) => string | Color) | ((origin: string | number, target: string | number) => Function) | typeof mixArray | typeof mixObject;
1364
+ declare function mixArray(a: MixableArray, b: MixableArray): (p: number) => (string | number | RGBA | HSLA)[];
1365
+ declare function mixObject(a: MixableObject, b: MixableObject): (v: number) => {
1366
+ [x: string]: string | number | RGBA | HSLA;
1367
+ };
1368
+ declare const mixComplex: (origin: string | number, target: string | number) => Function;
1369
+
1370
+ declare function mixImmediate<T>(a: T, b: T): (p: number) => T;
1371
+
1372
+ declare const mixNumber: (from: number, to: number, progress: number) => number;
1373
+
1374
+ declare const invisibleValues: Set<string>;
1375
+ /**
1376
+ * Returns a function that, when provided a progress value between 0 and 1,
1377
+ * will return the "none" or "hidden" string only when the progress is that of
1378
+ * the origin or target.
1379
+ */
1380
+ declare function mixVisibility(origin: string, target: string): (p: number) => string;
1381
+
1382
+ /**
1383
+ * Add the ability for test suites to manually set support flags
1384
+ * to better test more environments.
1385
+ */
1386
+ declare const supportsFlags: Record<string, boolean | undefined>;
1387
+
1388
+ declare const supportsLinearEasing: () => boolean;
1389
+
1390
+ declare global {
1391
+ interface Window {
1392
+ ScrollTimeline: ScrollTimeline;
1393
+ }
1394
+ }
1395
+ declare class ScrollTimeline implements ProgressTimeline {
1396
+ constructor(options: ScrollOptions);
1397
+ currentTime: null | {
1398
+ value: number;
1399
+ };
1400
+ cancel?: VoidFunction;
1401
+ }
1402
+ declare const supportsScrollTimeline: () => boolean;
1403
+
1404
+ declare const color: {
1405
+ test: (v: any) => boolean;
1406
+ parse: (v: any) => RGBA | HSLA;
1407
+ transform: (v: HSLA | RGBA | string) => string;
1408
+ };
1409
+
1410
+ declare function parseHex(v: string): RGBA;
1411
+ declare const hex: {
1412
+ test: (v: any) => boolean;
1413
+ parse: typeof parseHex;
1414
+ transform: ({ red, green, blue, alpha }: RGBA) => string;
1415
+ };
1416
+
1417
+ declare const hsla: {
1418
+ test: (v: any) => boolean;
1419
+ parse: (v: string | Color) => HSLA;
1420
+ transform: ({ hue, saturation, lightness, alpha }: HSLA) => string;
1421
+ };
1422
+
1423
+ declare function hslaToRgba({ hue, saturation, lightness, alpha }: HSLA): RGBA;
1424
+
1425
+ declare const rgbUnit: {
1426
+ transform: (v: number) => number;
1427
+ test: (v: number) => boolean;
1428
+ parse: typeof parseFloat;
1429
+ };
1430
+ declare const rgba: {
1431
+ test: (v: any) => boolean;
1432
+ parse: (v: string | Color) => RGBA;
1433
+ transform: ({ red, green, blue, alpha }: RGBA) => string;
1434
+ };
1435
+
1436
+ declare function test(v: any): boolean;
1437
+ type ComplexValues = Array<CSSVariableToken | string | number | Color>;
1438
+ type ValueIndexes = {
1439
+ color: number[];
1440
+ number: number[];
1441
+ var: number[];
1442
+ };
1443
+ interface ComplexValueInfo {
1444
+ values: ComplexValues;
1445
+ split: string[];
1446
+ indexes: ValueIndexes;
1447
+ types: Array<keyof ValueIndexes>;
1448
+ }
1449
+ declare function analyseComplexValue(value: string | number): ComplexValueInfo;
1450
+ declare function parseComplexValue(v: string | number): ComplexValues;
1451
+ declare function createTransformer(source: string | number): (v: Array<CSSVariableToken | Color | number | string>) => string;
1452
+ declare function getAnimatableNone$1(v: string | number): string;
1453
+ declare const complex: {
1454
+ test: typeof test;
1455
+ parse: typeof parseComplexValue;
1456
+ createTransformer: typeof createTransformer;
1457
+ getAnimatableNone: typeof getAnimatableNone$1;
1458
+ };
1459
+
1460
+ /**
1461
+ * A list of value types commonly used for dimensions
1462
+ */
1463
+ declare const dimensionValueTypes: (ValueType | {
1464
+ test: (v: number) => boolean;
1465
+ parse: typeof parseFloat;
1466
+ transform: (v: number) => number;
1467
+ } | {
1468
+ test: (v: string | number) => boolean;
1469
+ parse: typeof parseFloat;
1470
+ transform: (v: string | number) => string;
1471
+ })[];
1472
+ /**
1473
+ * Tests a dimensional value against the list of dimension ValueTypes
1474
+ */
1475
+ declare const findDimensionValueType: (v: any) => ValueType | {
1476
+ test: (v: number) => boolean;
1477
+ parse: typeof parseFloat;
1478
+ transform: (v: number) => number;
1479
+ } | {
1480
+ test: (v: string | number) => boolean;
1481
+ parse: typeof parseFloat;
1482
+ transform: (v: string | number) => string;
1483
+ } | undefined;
1484
+
1485
+ interface ValueTypeMap {
1486
+ [key: string]: ValueType;
1487
+ }
1488
+
1489
+ /**
1490
+ * A map of default value types for common values
1491
+ */
1492
+ declare const defaultValueTypes: ValueTypeMap;
1493
+ /**
1494
+ * Gets the default ValueType for the provided value key
1495
+ */
1496
+ declare const getDefaultValueType: (key: string) => ValueType;
1497
+
1498
+ declare const numberValueTypes: ValueTypeMap;
1499
+
1500
+ declare const transformValueTypes: ValueTypeMap;
1501
+
1502
+ declare const number: {
1503
+ test: (v: number) => boolean;
1504
+ parse: typeof parseFloat;
1505
+ transform: (v: number) => number;
1506
+ };
1507
+ declare const alpha: {
1508
+ transform: (v: number) => number;
1509
+ test: (v: number) => boolean;
1510
+ parse: typeof parseFloat;
1511
+ };
1512
+ declare const scale: {
1513
+ default: number;
1514
+ test: (v: number) => boolean;
1515
+ parse: typeof parseFloat;
1516
+ transform: (v: number) => number;
1517
+ };
1518
+
1519
+ declare const degrees: {
1520
+ test: (v: string | number) => boolean;
1521
+ parse: typeof parseFloat;
1522
+ transform: (v: number | string) => string;
1523
+ };
1524
+ declare const percent: {
1525
+ test: (v: string | number) => boolean;
1526
+ parse: typeof parseFloat;
1527
+ transform: (v: number | string) => string;
1528
+ };
1529
+ declare const px: {
1530
+ test: (v: string | number) => boolean;
1531
+ parse: typeof parseFloat;
1532
+ transform: (v: number | string) => string;
1533
+ };
1534
+ declare const vh: {
1535
+ test: (v: string | number) => boolean;
1536
+ parse: typeof parseFloat;
1537
+ transform: (v: number | string) => string;
1538
+ };
1539
+ declare const vw: {
1540
+ test: (v: string | number) => boolean;
1541
+ parse: typeof parseFloat;
1542
+ transform: (v: number | string) => string;
1543
+ };
1544
+ declare const progressPercentage: {
1545
+ parse: (v: string) => number;
1546
+ transform: (v: number) => string;
1547
+ test: (v: string | number) => boolean;
1548
+ };
1549
+
1550
+ /**
1551
+ * Tests a provided value against a ValueType
1552
+ */
1553
+ declare const testValueType: (v: any) => (type: ValueType) => boolean;
1554
+
1555
+ declare function getAnimatableNone(key: string, value: string): any;
1556
+
1557
+ /**
1558
+ * Tests a value against the list of ValueTypes
1559
+ */
1560
+ declare const findValueType: (v: any) => ValueType | {
1561
+ test: (v: number) => boolean;
1562
+ parse: typeof parseFloat;
1563
+ transform: (v: number) => number;
1564
+ } | {
1565
+ test: (v: string | number) => boolean;
1566
+ parse: typeof parseFloat;
1567
+ transform: (v: string | number) => string;
1568
+ } | {
1569
+ test: (v: any) => boolean;
1570
+ parse: (v: any) => RGBA | HSLA;
1571
+ transform: (v: string | RGBA | HSLA) => string;
1572
+ } | {
1573
+ test: (v: any) => boolean;
1574
+ parse: (v: string | number) => ComplexValues;
1575
+ createTransformer: (source: string | number) => (v: (string | number | Color)[]) => string;
1576
+ getAnimatableNone: (v: string | number) => string;
1577
+ } | undefined;
1578
+
1579
+ /**
1580
+ * Provided a value and a ValueType, returns the value as that value type.
1581
+ */
1582
+ declare const getValueAsType: (value: any, type?: ValueType) => any;
1583
+
1083
1584
  type ViewTransitionAnimationDefinition = {
1084
1585
  keyframes: DOMKeyframesDefinition;
1085
1586
  options: AnimationOptions;
@@ -1129,4 +1630,4 @@ declare const sync: Batcher;
1129
1630
  */
1130
1631
  declare const cancelSync: Record<string, (process: Process) => void>;
1131
1632
 
1132
- export { type AcceptedAnimations, type ActiveStatsBuffer, type AnimationGeneratorType, type AnimationOptions, type AnimationOptionsWithValueOverrides, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, type Batcher, type BezierDefinition, type CSSStyleDeclarationWithTransform, type CancelProcess, type DOMKeyframesDefinition, type DOMValueAnimationOptions, type DecayOptions, type Driver, type DriverControls, type DurationSpringOptions, type DynamicOption, type Easing, type EasingDefinition, type EasingFunction, type EasingModifier, type ElementOrSelector, type EventOptions, type FrameData, type FrameStats, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type InactiveStatsBuffer, type InertiaOptions, type KeyframeGenerator, type KeyframeOptions, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, NativeAnimation, type NativeAnimationOptions, type NativeControlsOptions, type OnHoverEndEvent, type OnHoverStartEvent, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PassiveEffect, type PointerEventOptions, type PressGestureInfo, type Process, type ProgressTimeline, type RepeatType, type ResolvedValueKeyframe, type SVGAttributes, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGTransitions, type Schedule, type SelectorCache, type SpringOptions, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type Target, type TransformProperties, type Transformer, type Transition, type UnresolvedValueKeyframe, type ValueAnimationOptions, type ValueAnimationTransition, type ValueKeyframe, type ValueKeyframesDefinition, type VariableKeyframesDefinition, type VariableTransitions, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type WithQuerySelectorAll, activeAnimations, animateView, attachTimeline, calcGeneratorDuration, cancelFrame, cancelMicrotask, cancelSync, collectMotionValues, createGeneratorEasing, createRenderBatcher, cubicBezierAsString, frame, frameData, frameSteps, generateLinearEasing, getValueTransition, hover, isBezierDefinition, isDragActive, isDragging, isGenerator, isNodeOrChild, isPrimaryPointer, isWaapiSupportedEasing, mapEasingToNativeEasing, maxGeneratorDuration, microtask, motionValue, press, recordStats, resolveElements, setDragLock, startWaapiAnimation, statsBuffer, supportedWaapiEasing, supportsFlags, supportsLinearEasing, supportsScrollTimeline, sync, time };
1633
+ export { type AcceptedAnimations, type ActiveStatsBuffer, type AnimationGeneratorType, type AnimationOptions, type AnimationOptionsWithValueOverrides, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, type DecayOptions, type Driver, type DriverControls, type DurationSpringOptions, type DynamicOption, type ElementOrSelector, type EventOptions, type FrameData, type FrameStats, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, type InactiveStatsBuffer, type InertiaOptions, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, type Mixer, type MixerFactory, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NumberMap, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PassiveEffect, type PointerEventOptions, type PressGestureInfo, type Process, type ProgressTimeline, type RGBA, type RepeatType, type ResolvedKeyframes, type ResolvedValueKeyframe, type SVGAttributes, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGTransitions, type Schedule, type SelectorCache, type SpringOptions, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type Target, type TimelineWithFallback, type TransformProperties, type Transformer, type Transition, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type WithQuerySelectorAll, acceleratedValues, activeAnimations, alpha, analyseComplexValue, animateValue, animateView, animationMapKey, applyPxDefaults, calcGeneratorDuration, cancelFrame, cancelMicrotask, cancelSync, collectMotionValues, color, complex, convertOffsetToTimes, createGeneratorEasing, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultValueTypes, degrees, dimensionValueTypes, fillOffset, fillWildcards, findDimensionValueType, findValueType, flushKeyframeResolvers, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultValueType, getMixer, getValueAsType, getValueTransition, getVariableValue, hex, hover, hsla, hslaToRgba, inertia, interpolate, invisibleValues, isCSSVariableName, isCSSVariableToken, isDragActive, isDragging, isGenerator, isNodeOrChild, isPrimaryPointer, isWaapiSupportedEasing, keyframes, mapEasingToNativeEasing, maxGeneratorDuration, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixVisibility, motionValue, number, numberValueTypes, observeTimeline, parseCSSVariable, parseValueFromTransform, percent, positionalKeys, press, progressPercentage, px, readTransformValue, recordStats, resolveElements, rgbUnit, rgba, scale, setDragLock, setStyle, spring, startWaapiAnimation, statsBuffer, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, sync, testValueType, time, transformPropOrder, transformProps, transformValueTypes, vh, vw };