leptos_motion_core/
lib.rs

1//! Leptos Motion Core
2//! 
3//! Core animation engine providing hybrid RAF/WAAPI animation system,
4//! spring physics, easing functions, and motion value management.
5
6#![warn(missing_docs)]
7#![forbid(unsafe_code)]
8
9pub mod animation;
10pub mod easing;
11pub mod engine;
12pub mod interpolation;
13pub mod math;
14pub mod spring;
15pub mod time;
16pub mod types;
17pub mod values;
18
19// Re-export core types
20pub use animation::{AnimationBuilder, AnimationConfig, Variants};
21pub use easing::EasingFn;
22pub use engine::{AnimationEngine, HybridEngine, WaapiEngine, RafEngine, PlaybackState};
23pub use interpolation::Interpolate;
24pub use math::{clamp, map_range, distance_2d, smooth_step, smoother_step};
25pub use spring::{SpringSimulator, SpringState};
26pub use time::Timer;
27pub use types::{
28    AnimationHandle, AnimationValue, AnimationTarget, Transition,
29    Transform, ComplexValue, SpringConfig, RepeatConfig, StaggerConfig, StaggerFrom, Easing
30};
31pub use values::{MotionValue, MotionNumber, MotionTransform, MotionValues};
32
33/// Result type for animation operations
34pub type Result<T> = std::result::Result<T, AnimationError>;
35
36/// Core animation error types
37#[derive(Debug, thiserror::Error)]
38pub enum AnimationError {
39    /// Animation engine not available
40    #[error("Animation engine not available: {0}")]
41    EngineUnavailable(String),
42    
43    /// Invalid animation property
44    #[error("Invalid animation property: {property}")]
45    InvalidProperty { property: String },
46    
47    /// Animation already running
48    #[error("Animation already running with handle: {handle:?}")]
49    AlreadyRunning { handle: AnimationHandle },
50    
51    /// Animation not found
52    #[error("Animation not found: {handle:?}")]
53    NotFound { handle: AnimationHandle },
54    
55    /// DOM operation failed
56    #[error("DOM operation failed: {0}")]
57    DomError(String),
58    
59    /// Mathematical error (division by zero, invalid range, etc.)
60    #[error("Math error: {0}")]
61    MathError(String),
62}