import { z } from "zod"; import { BezierHandle, PropertyKeyframe, PropertyAnimatorSchema, PropertyLink, PropertyRegistration, PropertyTrack, PropertyValue, TrackDefaults } from "./PropertyAnimator.types"; /** * Stores keyframed animation tracks for clip properties and evaluates them over local clip time. */ export declare class PropertyAnimator { private clipId?; private tracks; private properties; private initialValues; /** compound key → PropertyLink */ private links; /** component key → compound key (reverse lookup) */ private componentToCompound; /** * Associates the animator with a clip ID used for undo records and emitted events. * * @param clipId Owning clip ID. * @returns Nothing. */ setClipId(clipId: string): void; /** * Returns the owning clip ID associated with the animator. * * @returns The owning clip ID, or `undefined` if none has been assigned. */ getClipId(): string | undefined; private recordUndo; /** Tolerance for matching keyframes: half a frame minus epsilon */ private get tolerance(); /** Round a time value to the nearest frame boundary */ private alignTime; /** * Registers a property that may be read, written, and keyframed by the animator. * * @param registration Property registration describing how to get and set the property. * @returns Nothing. */ registerProperty(registration: PropertyRegistration): void; /** * Unregisters a property and removes any track and initial value stored for it. * * @param key Registered property key to remove. * @returns Nothing. */ unregisterProperty(key: string): void; /** * Returns the registered animatable properties. * * @returns A read-only map of property registrations by key. */ getRegisteredProperties(): ReadonlyMap; /** * Stores the base value used to restore a property when its last keyframe is removed. * * @param property Registered property key. * @param value Base property value. * @returns Nothing. */ setInitialPropertyValue(property: string, value: PropertyValue): void; /** * Returns the stored base value for a property. * * @param property Registered property key. * @returns A cloned base value, or `undefined` if none is stored. */ getInitialPropertyValue(property: string): PropertyValue | undefined; /** * Indicates whether a property has a stored base value. * * @param property Registered property key. * @returns `true` if a base value exists; otherwise `false`. */ hasInitialPropertyValue(property: string): boolean; /** * Removes the stored base value for a property. * * @param property Registered property key. * @returns Nothing. */ deleteInitialPropertyValue(property: string): void; /** * Returns all stored base property values. * * @returns A read-only map of base property values. */ getInitialPropertyValues(): ReadonlyMap; /** * Register a link between a compound vector property and its scalar components. * E.g. linkProperties({ compound: "scale", components: ["scaleX", "scaleY"] }) */ /** * Registers a relationship between a compound property and its scalar component properties. * * @param link Compound-to-component link definition. * @returns Nothing. */ linkProperties(link: PropertyLink): void; /** * Splits a compound property track into independent component tracks. * * @param compound Compound property key to split. * @returns Nothing. */ splitTrack(compound: string): void; /** * Merges component tracks back into a compound property track. * * @param compound Compound property key to rebuild. * @param force When `true`, fills missing component keyframes by evaluating track values at merge times. * @returns Nothing. */ mergeTrack(compound: string, force?: boolean): void; /** * Indicates whether a compound property can be merged losslessly from its component tracks. * * @param compound Compound property key to inspect. * @returns `true` if all populated component tracks share the same keyframe times; otherwise `false`. */ canMergeTrack(compound: string): boolean; /** * Indicates whether a compound property is currently represented by populated component tracks. * * @param compound Compound property key to inspect. * @returns `true` if any component track exists with keyframes; otherwise `false`. */ isSplit(compound: string): boolean; /** * Returns the compound/component link definition associated with a property key. * * @param property Compound or component property key. * @returns The matching property link, or `undefined` if the property is not linked. */ getLink(property: string): PropertyLink | undefined; /** * Check if adding a keyframe to this property would conflict with an active linked track. * Throws if there's a conflict (user must explicitly split/merge first). */ private validateLinkConflict; /** * Creates a keyframe track for a registered property if it does not already exist. * * @param property Registered property key. * @param defaults Optional default keyframe settings for newly inserted keyframes. * @returns The existing or created property track. */ addTrack(property: string, defaults?: TrackDefaults): PropertyTrack; /** * Removes a property track and restores the initial property value when appropriate. * * @param property Registered property key. * @returns Nothing. */ removeTrack(property: string): void; /** * Indicates whether a property currently has a track. * * @param property Registered property key. * @returns `true` if a track exists; otherwise `false`. */ hasTrack(property: string): boolean; /** * Returns a property track by key. * * @param property Registered property key. * @returns The matching track, or `undefined` if no track exists. */ getTrack(property: string): PropertyTrack | undefined; /** * Returns all property tracks. * * @returns A read-only map of tracks by property key. */ getTracks(): ReadonlyMap; /** * Adds or replaces a keyframe on a property track. * * @param property Registered property key. * @param time Local clip time, in seconds, where the keyframe should be placed. * @param value Keyframe value to store. * @param handleIn Optional incoming Bezier handle. * @param handleOut Optional outgoing Bezier handle. * @param hold Whether this keyframe should hold its value until the next keyframe. * @returns The created or replaced keyframe. */ addKeyframe(property: string, time: number, value: PropertyValue, handleIn?: BezierHandle, handleOut?: BezierHandle, hold?: boolean): PropertyKeyframe; /** * Removes a specific keyframe object from a property track. * * @param property Registered property key. * @param keyframe Keyframe instance to remove. * @returns Nothing. */ removeKeyframe(property: string, keyframe: PropertyKeyframe): void; /** * Removes all keyframes on a property track that match the provided time within keyframe tolerance. * * @param property Registered property key. * @param time Local clip time, in seconds. * @returns Nothing. */ removeKeyframeAtTime(property: string, time: number): void; /** * Updates the value or handles of the keyframe closest to the provided time. * * @param property Registered property key. * @param time Local clip time, in seconds, used to locate the keyframe. * @param patch Partial keyframe data to apply. * @returns Nothing. */ updateKeyframe(property: string, time: number, patch: Partial>): void; /** * Moves a keyframe to a new time. * * @param property Registered property key. * @param oldTime Current keyframe time, in seconds. * @param newTime Target keyframe time, in seconds. * @param clamped When `true`, keeps the keyframe between its neighbors instead of allowing reordering. * @returns Nothing. */ moveKeyframe(property: string, oldTime: number, newTime: number, clamped?: boolean): void; /** * Returns all keyframes that exist at the provided time across every track. * * @param time Local clip time, in seconds. * @returns A map of property keys to matching keyframes. */ getKeyframesAtTime(time: number): Map; /** * Returns the keyframe on a property track that matches the provided time. * * @param property Registered property key. * @param time Local clip time, in seconds. * @returns The matching keyframe, or `undefined` if none exists at that time. */ getKeyframeAtTime(property: string, time: number): PropertyKeyframe | undefined; /** * Removes all keyframes at the provided time across every track. * * @param time Local clip time, in seconds. * @returns Nothing. */ removeKeyframesAtTime(time: number): void; /** * Removes keyframe data from one property track or from all tracks. * * @param property Optional property key to clear. When omitted, every track is cleared. * @returns Nothing. */ clear(property?: string): void; /** * Copies a keyframe from one time to another on the same property track. * * @param property Registered property key. * @param sourceTime Existing keyframe time, in seconds. * @param targetTime Destination keyframe time, in seconds. * @returns The duplicated keyframe, or `undefined` if no source keyframe exists. */ duplicateKeyframe(property: string, sourceTime: number, targetTime: number): PropertyKeyframe | undefined; /** * Indicates whether a property track has a keyframe at the provided time. * * @param property Registered property key. * @param time Local clip time, in seconds. * @returns `true` if a keyframe exists at that time; otherwise `false`. */ hasKeyframeAtTime(property: string, time: number): boolean; /** * Returns the first keyframe after the provided time on a property track. * * @param property Registered property key. * @param time Local clip time, in seconds. * @returns The next keyframe, or `undefined` if none exists after that time. */ getNextKeyframe(property: string, time: number): PropertyKeyframe | undefined; /** * Returns the last keyframe before the provided time on a property track. * * @param property Registered property key. * @param time Local clip time, in seconds. * @returns The previous keyframe, or `undefined` if none exists before that time. */ getPrevKeyframe(property: string, time: number): PropertyKeyframe | undefined; /** * Returns the set of all unique keyframe times across every property track. * * @returns The unique keyframe times. */ getAllKeyframeTimes(): Set; /** * Returns keyframes on a property track that fall within an inclusive time range. * * @param property Registered property key. * @param startTime Range start, in seconds. * @param endTime Range end, in seconds. * @returns The matching keyframes. */ getKeyframesBetween(property: string, startTime: number, endTime: number): PropertyKeyframe[]; /** * Returns the property keys that currently have at least one keyframe. * * @returns The animated property keys. */ getAnimatedProperties(): Set; /** * Evaluates every populated property track at the provided time. * * @param time Local clip time, in seconds. * @returns A map of evaluated property values by key. */ evaluate(time: number): Map; /** * Evaluates a single property track at the provided time. * * @param property Registered property key. * @param time Local clip time, in seconds. * @returns The evaluated property value, or `undefined` if the track has no keyframes. */ evaluateProperty(property: string, time: number): PropertyValue | undefined; /** * Applies evaluated values to all registered properties at the provided local clip time. * * @param time Local clip time, in seconds. * @returns Nothing. */ apply(time: number): void; private evaluateTrack; private comparePropertyValues; private compareNumericValue; private compareArrayLikeValue; /** * Record the current value of a registered property as a keyframe. * Reads the value from the property's registered getter. * If a keyframe already exists at that time, only the value is updated (handles are preserved). * If no keyframe exists, a new one is inserted with default handles. * If no track exists, one is created automatically. */ /** * Records the current live value of a registered property as a keyframe. * * @param property Registered property key. * @param currentTime Local clip time, in seconds, where the keyframe should be stored. * @returns Nothing. */ recordProperty(property: string, currentTime: number): void; /** * Serializes the animator tracks and stored initial values. * * @returns The serialized property animator payload. */ serialize(): z.infer; /** * Restores animator tracks and stored initial values from serialized data. * * @param data Serialized property animator payload. * @returns Nothing. */ deserialize(data: z.infer): void; private emitKeyframeChanged; private readCurrentPropertyValue; private removeTrackInternal; private restoreInitialValue; /** Find the single closest keyframe within tolerance using binary search. Returns index or -1. */ private findClosestKeyframeIndex; private findInsertIndex; }