@motion.page/sdk 0.1.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 (52) hide show
  1. package/README.md +817 -0
  2. package/dist/core/Animation.d.ts +230 -0
  3. package/dist/core/AnimationBuilder.d.ts +125 -0
  4. package/dist/core/Engine.d.ts +140 -0
  5. package/dist/core/Motion.d.ts +56 -0
  6. package/dist/core/PropTween.d.ts +81 -0
  7. package/dist/core/Ticker.d.ts +107 -0
  8. package/dist/core/Timeline.d.ts +294 -0
  9. package/dist/easing/index.d.ts +65 -0
  10. package/dist/fit/FitResolver.d.ts +12 -0
  11. package/dist/index.cjs +34 -0
  12. package/dist/index.cjs.map +52 -0
  13. package/dist/index.d.ts +25 -0
  14. package/dist/index.js +34 -0
  15. package/dist/index.js.map +52 -0
  16. package/dist/memory/AnimationPool.d.ts +14 -0
  17. package/dist/memory/ObjectPool.d.ts +37 -0
  18. package/dist/memory/PropTweenPool.d.ts +14 -0
  19. package/dist/registries/SDKRegistry.d.ts +69 -0
  20. package/dist/render/CSSRenderer.d.ts +33 -0
  21. package/dist/render/PathRenderer.d.ts +24 -0
  22. package/dist/render/RenderBatch.d.ts +27 -0
  23. package/dist/render/TransformCache.d.ts +54 -0
  24. package/dist/stagger/StaggerResolver.d.ts +28 -0
  25. package/dist/triggers/BaseTrigger.d.ts +61 -0
  26. package/dist/triggers/CursorTrigger.d.ts +86 -0
  27. package/dist/triggers/EventTrigger.d.ts +48 -0
  28. package/dist/triggers/GestureTrigger.d.ts +137 -0
  29. package/dist/triggers/MarkerManager.d.ts +42 -0
  30. package/dist/triggers/MouseMoveTrigger.d.ts +49 -0
  31. package/dist/triggers/PageExitTrigger.d.ts +74 -0
  32. package/dist/triggers/PageLoadTrigger.d.ts +37 -0
  33. package/dist/triggers/PinManager.d.ts +131 -0
  34. package/dist/triggers/ScrollTrigger.d.ts +103 -0
  35. package/dist/triggers/TriggerManager.d.ts +133 -0
  36. package/dist/types/index.d.ts +355 -0
  37. package/dist/types/public.d.ts +7 -0
  38. package/dist/utils/ColorParser.d.ts +23 -0
  39. package/dist/utils/DrawSVGParser.d.ts +62 -0
  40. package/dist/utils/FilterParser.d.ts +49 -0
  41. package/dist/utils/MotionUtils.d.ts +136 -0
  42. package/dist/utils/PathParser.d.ts +89 -0
  43. package/dist/utils/PositionParser.d.ts +24 -0
  44. package/dist/utils/PropertyParser.d.ts +159 -0
  45. package/dist/utils/QuickSetter.d.ts +16 -0
  46. package/dist/utils/ScrollPositionParser.d.ts +19 -0
  47. package/dist/utils/StyleReset.d.ts +73 -0
  48. package/dist/utils/TargetResolver.d.ts +23 -0
  49. package/dist/utils/TextSplitter.d.ts +90 -0
  50. package/dist/utils/executeTimelineAction.d.ts +18 -0
  51. package/dist/utils/getLayoutRect.d.ts +10 -0
  52. package/package.json +56 -0
@@ -0,0 +1,355 @@
1
+ /**
2
+ * Motion.page SDK - Type Definitions
3
+ */
4
+ export type { TimelineAction } from '../utils/executeTimelineAction';
5
+ /**
6
+ * Easing function type
7
+ */
8
+ export type EasingFunction = (t: number) => number;
9
+ /**
10
+ * Text split types for character/word/line animations
11
+ */
12
+ export type SplitType = 'chars' | 'words' | 'lines' | 'chars,words' | 'words,lines' | 'chars,words,lines';
13
+ /**
14
+ * Configuration for repeat behavior
15
+ */
16
+ export interface RepeatConfig {
17
+ times: number;
18
+ delay?: number;
19
+ yoyo?: boolean;
20
+ }
21
+ /**
22
+ * Stagger configuration for multiple elements
23
+ */
24
+ export interface StaggerVars {
25
+ each?: number;
26
+ amount?: number;
27
+ from?: 'start' | 'center' | 'edges' | 'random' | 'end' | number;
28
+ grid?: 'auto' | [number, number];
29
+ axis?: 'x' | 'y';
30
+ ease?: string;
31
+ }
32
+ /**
33
+ * Animatable properties
34
+ */
35
+ export interface AnimationVars {
36
+ x?: number | string;
37
+ y?: number | string;
38
+ z?: number | string;
39
+ rotate?: number | string;
40
+ rotateX?: number | string;
41
+ rotateY?: number | string;
42
+ rotateZ?: number | string;
43
+ scale?: number | string;
44
+ scaleX?: number | string;
45
+ scaleY?: number | string;
46
+ scaleZ?: number;
47
+ skewX?: number | string;
48
+ skewY?: number | string;
49
+ perspective?: number | string;
50
+ opacity?: number;
51
+ backgroundColor?: string;
52
+ color?: string;
53
+ width?: number | string;
54
+ height?: number | string;
55
+ top?: number | string;
56
+ left?: number | string;
57
+ right?: number | string;
58
+ bottom?: number | string;
59
+ margin?: number | string;
60
+ marginTop?: number | string;
61
+ marginRight?: number | string;
62
+ marginBottom?: number | string;
63
+ marginLeft?: number | string;
64
+ padding?: number | string;
65
+ paddingTop?: number | string;
66
+ paddingRight?: number | string;
67
+ paddingBottom?: number | string;
68
+ paddingLeft?: number | string;
69
+ borderRadius?: number | string;
70
+ fontSize?: number | string;
71
+ lineHeight?: number | string;
72
+ letterSpacing?: number | string;
73
+ zIndex?: number;
74
+ filter?: string;
75
+ transformOrigin?: string;
76
+ backgroundPosition?: string;
77
+ borderColor?: string;
78
+ borderTopColor?: string;
79
+ borderRightColor?: string;
80
+ borderBottomColor?: string;
81
+ borderLeftColor?: string;
82
+ outlineColor?: string;
83
+ textDecorationColor?: string;
84
+ caretColor?: string;
85
+ drawSVG?: string | {
86
+ start?: number;
87
+ end?: number;
88
+ };
89
+ fill?: string;
90
+ stroke?: string;
91
+ path?: PathConfig;
92
+ [key: string]: string | number | boolean | undefined | null | object;
93
+ }
94
+ /**
95
+ * Path configuration for motion along SVG path
96
+ */
97
+ export interface PathConfig {
98
+ /** SVG path - CSS selector, Element, or raw path data (starting with M/m) */
99
+ target: string | Element;
100
+ /** Element to align to (CSS selector or Element) */
101
+ align?: string | Element;
102
+ /** Origin point on element [x%, y%], default [50, 50] */
103
+ alignAt?: [number, number];
104
+ /** Start position on path 0-1 (default: 0) */
105
+ start?: number;
106
+ /** End position on path 0-1 (default: 1) */
107
+ end?: number;
108
+ /** Auto-rotate element along path tangent */
109
+ rotate?: boolean;
110
+ }
111
+ /**
112
+ * Configuration for Fit animations.
113
+ * Morphs one element's geometry to match another's — captures source and target
114
+ * element bounding rects at play time and animates the visual delta.
115
+ */
116
+ export interface FitConfig {
117
+ /** CSS selector for the target element to morph toward. Measured at animation play time via getBoundingClientRect() */
118
+ target: string;
119
+ /** Convert elements to absolute positioning during animation to prevent layout flow disruption. Default: false. Animates CSS left/top/width/height instead of transforms */
120
+ absolute?: boolean;
121
+ /** Include scale (scaleX/scaleY transform) changes in the animation. Default: true. Distorts content (text, borders). Use `resize` for undistorted dimension changes. */
122
+ scale?: boolean;
123
+ /** Animate actual width/height CSS properties instead of scaleX/scaleY transforms. Default: false. No content distortion but triggers layout reflow. Mutually exclusive with `scale`. */
124
+ resize?: boolean;
125
+ }
126
+ /**
127
+ * Animation configuration for Motion(name, target, config)
128
+ */
129
+ export interface AnimationConfig {
130
+ from?: AnimationVars;
131
+ to?: AnimationVars;
132
+ duration?: number;
133
+ delay?: number;
134
+ ease?: string;
135
+ stagger?: number | StaggerVars;
136
+ /**
137
+ * Number of times to repeat the animation.
138
+ * Use a number for simple repeats, or RepeatConfig for advanced options.
139
+ * Use -1 for infinite repeat.
140
+ * @example
141
+ * repeat: 3
142
+ * repeat: { times: -1, delay: 0.2, yoyo: true }
143
+ */
144
+ repeat?: number | RepeatConfig;
145
+ split?: SplitType;
146
+ /**
147
+ * When true (used with `split`), each split element is wrapped in a parent
148
+ * with `overflow: hidden` so animated content is clipped to its natural bounds.
149
+ * Creates a "reveal" effect when animating `y: '100%'` — text slides up from
150
+ * behind an invisible edge.
151
+ * @example
152
+ * Motion('reveal', 'h1', { split: 'lines', mask: true, from: { y: '100%' }, to: { y: 0 }, stagger: 0.1 })
153
+ */
154
+ mask?: boolean;
155
+ /**
156
+ * Fit animation configuration.
157
+ * Morphs the source element's geometry toward the target element's geometry.
158
+ * When set, `from` and `to` are ignored.
159
+ * @example
160
+ * Motion('reorder', '.container', { fit: { target: '.item' }, duration: 0.5 })
161
+ */
162
+ fit?: FitConfig;
163
+ /** Axis binding for onMouseMove trigger (x or y) */
164
+ axis?: 'x' | 'y';
165
+ /**
166
+ * Called when the animation starts (first frame with progress > 0).
167
+ * @example
168
+ * Motion('fade', '#box', { to: { opacity: 0 }, onStart: () => console.log('started') })
169
+ */
170
+ onStart?: () => void;
171
+ /**
172
+ * Called every frame with the current progress value (0–1).
173
+ * @param progress - Current playback progress from 0 (start) to 1 (end)
174
+ * @example
175
+ * Motion('fade', '#box', { to: { opacity: 0 }, onUpdate: (p) => console.log(p) })
176
+ */
177
+ onUpdate?: (progress: number) => void;
178
+ /**
179
+ * Called when the animation completes (after the final repeat, forward direction).
180
+ * @example
181
+ * Motion('fade', '#box', { to: { opacity: 0 }, onComplete: () => console.log('done') })
182
+ */
183
+ onComplete?: () => void;
184
+ /**
185
+ * Called at the end of each repeat cycle.
186
+ * @param repeatCount - Number of repeats completed so far
187
+ * @example
188
+ * Motion('pulse', '#box', { to: { scale: 1.2 }, repeat: { times: 3 }, onRepeat: (n) => console.log('repeat', n) })
189
+ */
190
+ onRepeat?: (repeatCount: number) => void;
191
+ /**
192
+ * Called when the animation completes in the reverse direction (after the final yoyo repeat).
193
+ * @example
194
+ * Motion('pulse', '#box', { to: { scale: 1.2 }, repeat: { times: 1, yoyo: true }, onReverseComplete: () => console.log('reversed') })
195
+ */
196
+ onReverseComplete?: () => void;
197
+ }
198
+ /**
199
+ * Animation entry for Motion(name, [entries])
200
+ */
201
+ export interface AnimationEntry extends AnimationConfig {
202
+ target: TargetInput;
203
+ position?: number | string;
204
+ }
205
+ /**
206
+ * Plain object target for non-DOM animation
207
+ */
208
+ export type ObjectTarget = Record<string, number>;
209
+ /**
210
+ * Valid animation targets
211
+ */
212
+ export type AnimationTarget = Element | ObjectTarget;
213
+ /**
214
+ * Input types accepted by Motion()
215
+ */
216
+ export type TargetInput = string | string[] | Element | NodeList | Element[] | ObjectTarget | ObjectTarget[];
217
+ export interface MarkerConfig {
218
+ startColor?: string;
219
+ endColor?: string;
220
+ fontSize?: string;
221
+ fontWeight?: string;
222
+ indent?: number;
223
+ }
224
+ export interface HoverConfig {
225
+ target?: string | Element;
226
+ each?: boolean;
227
+ onLeave?: 'reverse' | 'pause' | 'stop' | 'restart' | 'none';
228
+ leaveDelay?: number;
229
+ }
230
+ export interface ClickConfig {
231
+ target?: string | Element;
232
+ each?: boolean;
233
+ secondTarget?: string | Element;
234
+ toggle?: 'reverse' | 'restart' | 'play';
235
+ preventDefault?: boolean;
236
+ }
237
+ export interface ScrollConfig {
238
+ target?: string | Element;
239
+ start?: string;
240
+ end?: string;
241
+ scrub?: boolean | number;
242
+ markers?: boolean | MarkerConfig;
243
+ scroller?: string | Element;
244
+ pin?: boolean | string;
245
+ pinSpacing?: boolean | 'margin' | 'padding';
246
+ each?: boolean;
247
+ /** Toggle actions for non-scrub mode: "onEnter onLeave onEnterBack onLeaveBack" */
248
+ toggleActions?: string;
249
+ /**
250
+ * Snap scroll progress to fixed points.
251
+ * - `number`: snap to evenly-spaced increments (e.g., 0.25 → 0, 0.25, 0.5, 0.75, 1)
252
+ * - `number[]`: snap to specific progress values (e.g., [0, 0.33, 0.66, 1])
253
+ * - `function`: custom snap function receiving raw progress, returning snapped progress
254
+ *
255
+ * @example Horizontal scroll with 4 sections
256
+ * snap: 1 / (document.querySelectorAll('.section').length - 1)
257
+ */
258
+ snap?: number | number[] | ((progress: number) => number);
259
+ }
260
+ export interface MouseMoveConfig {
261
+ type?: 'distance' | 'axis';
262
+ target?: string | Element;
263
+ each?: boolean;
264
+ smooth?: number;
265
+ startProgress?: number;
266
+ leaveProgress?: number;
267
+ }
268
+ export interface PageExitConfig {
269
+ /** Link selection mode: 'all' (default), 'include', or 'exclude' */
270
+ mode?: 'all' | 'include' | 'exclude';
271
+ /** CSS selector(s) for links — required for 'include'/'exclude' modes */
272
+ selectors?: string;
273
+ /** Href patterns to skip (never intercept) */
274
+ skipHref?: ('anchor' | 'javascript' | 'mailto')[];
275
+ }
276
+ export type GestureInputType = 'pointer' | 'touch' | 'wheel' | 'scroll';
277
+ export type GestureEvent = 'Up' | 'Down' | 'Left' | 'Right' | 'UpComplete' | 'DownComplete' | 'LeftComplete' | 'RightComplete' | 'Change' | 'ChangeX' | 'ChangeY' | 'ToggleX' | 'ToggleY' | 'Press' | 'Release' | 'PressInit' | 'Drag' | 'DragEnd' | 'Stop' | 'Hover' | 'HoverEnd';
278
+ export type GestureAction = 'play' | 'pause' | 'reverse' | 'restart' | 'toggle' | 'reset' | 'complete' | 'kill' | 'playReverse' | 'progressUp' | 'progressDown' | 'playNext' | 'playPrevious';
279
+ export interface GestureConfig {
280
+ target?: string | Element;
281
+ types: GestureInputType[];
282
+ events: Partial<Record<GestureEvent, GestureAction>>;
283
+ tolerance?: number;
284
+ dragMinimum?: number;
285
+ wheelSpeed?: number;
286
+ scrollSpeed?: number;
287
+ preventDefault?: boolean;
288
+ lockAxis?: boolean;
289
+ each?: boolean;
290
+ stopDelay?: number;
291
+ animationStep?: number | Partial<Record<GestureEvent, number>>;
292
+ smooth?: number;
293
+ }
294
+ /**
295
+ * Extended GestureConfig with internal fields used by GestureTrigger.
296
+ * @internal - Not part of the public API. Used by the builder when setting up each-mode animations.
297
+ */
298
+ export interface GestureConfigInternal extends GestureConfig {
299
+ /** @internal */
300
+ _siblings?: unknown[];
301
+ /** @internal */
302
+ _index?: number;
303
+ }
304
+ /**
305
+ * CSS properties as object (like GSAP/React style)
306
+ * duration and ease are extracted for transitions
307
+ */
308
+ export interface CursorStateVars {
309
+ /** CSS selectors that trigger this state (hover only) */
310
+ targets?: string[];
311
+ /** Transition duration in seconds. Default: 0.15 */
312
+ duration?: number;
313
+ /** Easing function. Default: 'power3.inOut' */
314
+ ease?: string;
315
+ /** Whether state is enabled. Default: true */
316
+ enabled?: boolean;
317
+ /** Additional CSS properties to apply (e.g., width, height, backgroundColor) */
318
+ [key: string]: string | number | string[] | boolean | undefined;
319
+ }
320
+ /**
321
+ * Squeeze effect configuration
322
+ */
323
+ export interface CursorSqueezeConfig {
324
+ /** Minimum scale when moving fast. Default: 0.55 */
325
+ min?: number;
326
+ /** Maximum scale when stationary. Default: 1.2 */
327
+ max?: number;
328
+ /** Velocity sensitivity multiplier. Default: 150 */
329
+ multiplier?: number;
330
+ }
331
+ /**
332
+ * Main cursor configuration
333
+ */
334
+ export interface CursorConfig {
335
+ /** Target element selector or element for the cursor container */
336
+ target?: string | Element;
337
+ /** Cursor type. Default: 'basic' */
338
+ type?: 'basic' | 'text' | 'media';
339
+ /** Smoothing factor (0 = most delay/smoothing, 1 = instant). Default: 0.25 */
340
+ smooth?: number;
341
+ /** Enable velocity-based squeeze effect */
342
+ squeeze?: boolean | CursorSqueezeConfig;
343
+ /** Hide native browser cursor. Default: false */
344
+ hideNative?: boolean;
345
+ /** Default state configuration (required) */
346
+ default: CursorStateVars;
347
+ /** Hover state configuration */
348
+ hover?: CursorStateVars;
349
+ /** Click/pressed state configuration */
350
+ click?: CursorStateVars;
351
+ /** Text element styles (for type: 'text') */
352
+ text?: Record<string, string | number>;
353
+ /** Media element styles (for type: 'media') */
354
+ media?: Record<string, string | number>;
355
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Public types for SDK consumers
3
+ *
4
+ * This file re-exports only the public types intended for SDK users.
5
+ * Internal types are co-located with their implementations.
6
+ */
7
+ export type { EasingFunction, SplitType, RepeatConfig, StaggerVars, AnimationVars, PathConfig, FitConfig, AnimationConfig, AnimationEntry, ObjectTarget, AnimationTarget, TargetInput, MarkerConfig, HoverConfig, ClickConfig, ScrollConfig, MouseMoveConfig, PageExitConfig, GestureInputType, GestureEvent, GestureAction, GestureConfig, CursorStateVars, CursorSqueezeConfig, CursorConfig, } from './index';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * ColorParser - Parse any color format to RGBA
3
+ *
4
+ * Supports:
5
+ * - Hex: #ff0000, #f00, #ff0000ff, #f00f
6
+ * - RGB/RGBA: rgb(255, 0, 0), rgba(255, 0, 0, 0.5)
7
+ * - HSL/HSLA: hsl(0, 100%, 50%), hsla(0, 100%, 50%, 0.5)
8
+ * - Named colors: red, coral, transparent
9
+ * - CSS variables: var(--color)
10
+ */
11
+ /**
12
+ * Parse any color format to RGBA Float32Array
13
+ * Returns [R, G, B, A] where RGB is 0-255 and A is 0-1
14
+ */
15
+ export declare function parseColor(color: string, element?: Element): Float32Array | null;
16
+ /**
17
+ * Convert RGBA Float32Array to CSS rgba() string
18
+ */
19
+ export declare function rgbaToString(rgba: Float32Array): string;
20
+ /**
21
+ * Get current color value from element's computed style
22
+ */
23
+ export declare function getCurrentColor(element: Element, property: string): Float32Array;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * DrawSVGParser - Parse and animate SVG stroke drawing
3
+ *
4
+ * Handles:
5
+ * - Percentage values: "0% 100%", "20% 80%"
6
+ * - Pixel values: "100px 500px"
7
+ * - Object format: { start: 0, end: 100 }
8
+ * - Single values: "50%" (draws from 0 to 50%)
9
+ *
10
+ * Uses stroke-dasharray and stroke-dashoffset for performant rendering.
11
+ */
12
+ /**
13
+ * Parsed DrawSVG values (normalized to 0-1 range)
14
+ */
15
+ export interface ParsedDrawSVG {
16
+ start: number;
17
+ end: number;
18
+ }
19
+ /**
20
+ * DrawSVG input value types
21
+ */
22
+ type DrawSVGValue = string | {
23
+ start?: number;
24
+ end?: number;
25
+ };
26
+ /**
27
+ * Get the total length of an SVG element's stroke path.
28
+ * Cached per element for performance.
29
+ */
30
+ export declare function getPathLength(element: Element): number;
31
+ /**
32
+ * Clear cached path length for an element.
33
+ * Call when SVG path data changes.
34
+ */
35
+ export declare function clearPathLengthCache(element: Element): void;
36
+ /**
37
+ * Parse a DrawSVG value string or object into normalized 0-1 values.
38
+ *
39
+ * Supported formats:
40
+ * - "0% 100%" - percentage range
41
+ * - "100px 500px" - pixel range (requires element for length)
42
+ * - "50%" - single percentage (0 to value)
43
+ * - "50" - single number treated as percentage
44
+ * - { start: 0, end: 100 } - object with percentages
45
+ */
46
+ export declare function parseDrawSVG(value: DrawSVGValue, element?: Element): ParsedDrawSVG | null;
47
+ /**
48
+ * Get the current DrawSVG state from an element's computed style.
49
+ * Parses existing stroke-dasharray and stroke-dashoffset.
50
+ */
51
+ export declare function getCurrentDrawSVG(element: Element): ParsedDrawSVG;
52
+ /**
53
+ * Apply DrawSVG values to an element's style.
54
+ * Sets stroke-dasharray and stroke-dashoffset for the draw effect.
55
+ *
56
+ * @param element - Target SVG element
57
+ * @param start - Start position (0-1)
58
+ * @param end - End position (0-1)
59
+ * @param length - Pre-calculated path length
60
+ */
61
+ export declare function applyDrawSVG(element: Element, start: number, end: number, length: number): void;
62
+ export {};
@@ -0,0 +1,49 @@
1
+ /**
2
+ * FilterParser - Parse CSS filter strings for animation
3
+ *
4
+ * Supports:
5
+ * - blur(px)
6
+ * - brightness(ratio)
7
+ * - contrast(ratio)
8
+ * - saturate(ratio)
9
+ * - grayscale(ratio or %)
10
+ * - sepia(ratio or %)
11
+ * - hue-rotate(deg)
12
+ * - invert(ratio or %)
13
+ * - opacity(ratio or %)
14
+ */
15
+ /**
16
+ * Parsed filter function with name, value, and unit
17
+ */
18
+ export interface ParsedFilterFunction {
19
+ name: string;
20
+ value: number;
21
+ unit: string;
22
+ }
23
+ /**
24
+ * Parse a complete filter string into an array of filter functions
25
+ * Example: "blur(10px) brightness(1.5)" -> [{name: 'blur', value: 10, unit: 'px'}, ...]
26
+ */
27
+ export declare function parseFilter(filter: string): ParsedFilterFunction[] | null;
28
+ /**
29
+ * Convert parsed filter functions back to CSS filter string
30
+ */
31
+ export declare function filterToString(filters: ParsedFilterFunction[]): string;
32
+ /**
33
+ * Get current filter value from element's computed style
34
+ */
35
+ export declare function getCurrentFilter(element: Element): ParsedFilterFunction[];
36
+ /**
37
+ * Merge two filter arrays, ensuring all functions from both are present
38
+ * Missing functions get their default values
39
+ */
40
+ export declare function mergeFilterArrays(start: ParsedFilterFunction[], end: ParsedFilterFunction[]): {
41
+ start: ParsedFilterFunction[];
42
+ end: ParsedFilterFunction[];
43
+ };
44
+ /**
45
+ * Interpolate between two filter arrays at given progress.
46
+ * Reuses a module-level buffer to avoid allocating a new array every frame.
47
+ * NOTE: The returned array is reused on the next call — consume it immediately.
48
+ */
49
+ export declare function interpolateFilters(start: ParsedFilterFunction[], end: ParsedFilterFunction[], progress: number): ParsedFilterFunction[];
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Motion.utils — GSAP-compatible utility functions
3
+ *
4
+ * Drop-in replacements for common gsap.utils.* helpers.
5
+ * Enables migration from GSAP custom code to the Motion SDK.
6
+ *
7
+ * @example Migration from GSAP
8
+ * // Before: gsap.utils.toArray(".section").length
9
+ * // After: Motion.utils.toArray(".section").length
10
+ */
11
+ /**
12
+ * Convert a selector, NodeList, or value into a flat Array of Elements.
13
+ * Drop-in replacement for gsap.utils.toArray().
14
+ *
15
+ * @param target - CSS selector string, NodeList, HTMLCollection, Element, or array
16
+ * @param scope - Optional parent element to scope selector queries
17
+ * @returns Flat array of matched elements
18
+ *
19
+ * @example
20
+ * Motion.utils.toArray(".h-scroll-section") // all matching elements
21
+ * Motion.utils.toArray(".item", containerEl) // scoped to container
22
+ * Motion.utils.toArray(document.querySelectorAll("p")) // NodeList → Array
23
+ */
24
+ export declare function toArray<T extends Element = Element>(target: string | NodeList | HTMLCollection | Element | T[] | ArrayLike<T>, scope?: Element | Document): T[];
25
+ /**
26
+ * Clamp a value between min and max.
27
+ * Drop-in replacement for gsap.utils.clamp().
28
+ *
29
+ * Can be called with 3 args or curried with 2:
30
+ * - `clamp(0, 100, 150)` → `100`
31
+ * - `const c = clamp(0, 1); c(1.5)` → `1`
32
+ *
33
+ * @param min - Minimum allowed value
34
+ * @param max - Maximum allowed value
35
+ * @param value - Value to clamp (optional — returns curried function if omitted)
36
+ */
37
+ export declare function clamp(min: number, max: number, value: number): number;
38
+ export declare function clamp(min: number, max: number): (value: number) => number;
39
+ /**
40
+ * Generate a random number between min and max (inclusive).
41
+ * Drop-in replacement for gsap.utils.random().
42
+ *
43
+ * @param min - Minimum value
44
+ * @param max - Maximum value
45
+ * @param snapIncrement - Optional increment to snap to (e.g., 5 → multiples of 5)
46
+ * @returns Random number in the given range
47
+ *
48
+ * @example
49
+ * Motion.utils.random(0, 100) // 0–100 (float)
50
+ * Motion.utils.random(0, 100, 10) // 0, 10, 20, ... 100
51
+ * Motion.utils.random(-1, 1) // -1 to 1
52
+ */
53
+ export declare function random(min: number, max: number, snapIncrement?: number): number;
54
+ /**
55
+ * Snap a number to the nearest increment.
56
+ * Drop-in replacement for gsap.utils.snap().
57
+ *
58
+ * @param snapTo - Increment value or array of values to snap to
59
+ * @param value - Value to snap (optional — returns curried function if omitted)
60
+ *
61
+ * @example
62
+ * Motion.utils.snap(5, 13) // 15
63
+ * Motion.utils.snap([0, 25, 50, 100], 30) // 25
64
+ * const s = Motion.utils.snap(10); s(27) // 30
65
+ */
66
+ export declare function snap(snapTo: number | number[], value: number): number;
67
+ export declare function snap(snapTo: number | number[]): (value: number) => number;
68
+ /**
69
+ * Linear interpolation between two values.
70
+ * Drop-in replacement for gsap.utils.interpolate() (simple 2-value case).
71
+ *
72
+ * @param start - Start value
73
+ * @param end - End value
74
+ * @param progress - Interpolation factor (0–1)
75
+ * @returns Interpolated value
76
+ *
77
+ * @example
78
+ * Motion.utils.interpolate(0, 100, 0.5) // 50
79
+ */
80
+ export declare function interpolate(start: number, end: number, progress: number): number;
81
+ /**
82
+ * Map a value from one range to another.
83
+ * Drop-in replacement for gsap.utils.mapRange().
84
+ *
85
+ * @param inMin - Input range minimum
86
+ * @param inMax - Input range maximum
87
+ * @param outMin - Output range minimum
88
+ * @param outMax - Output range maximum
89
+ * @param value - Value to map (optional — returns curried function if omitted)
90
+ *
91
+ * @example
92
+ * Motion.utils.mapRange(0, 100, 0, 1, 50) // 0.5
93
+ * const map = Motion.utils.mapRange(0, 1, -100, 100); map(0.75) // 50
94
+ */
95
+ export declare function mapRange(inMin: number, inMax: number, outMin: number, outMax: number, value: number): number;
96
+ export declare function mapRange(inMin: number, inMax: number, outMin: number, outMax: number): (value: number) => number;
97
+ /**
98
+ * Normalize a value from a range to 0–1.
99
+ * Drop-in replacement for gsap.utils.normalize().
100
+ *
101
+ * @param min - Range minimum
102
+ * @param max - Range maximum
103
+ * @param value - Value to normalize (optional — returns curried function if omitted)
104
+ *
105
+ * @example
106
+ * Motion.utils.normalize(0, 100, 25) // 0.25
107
+ */
108
+ export declare function normalize(min: number, max: number, value: number): number;
109
+ export declare function normalize(min: number, max: number): (value: number) => number;
110
+ /**
111
+ * Wrap a value within a range (modular arithmetic).
112
+ * Drop-in replacement for gsap.utils.wrap().
113
+ *
114
+ * @param min - Range minimum
115
+ * @param max - Range maximum
116
+ * @param value - Value to wrap (optional — returns curried function if omitted)
117
+ *
118
+ * @example
119
+ * Motion.utils.wrap(0, 100, 150) // 50
120
+ * Motion.utils.wrap(0, 360, -90) // 270
121
+ */
122
+ export declare function wrap(min: number, max: number, value: number): number;
123
+ export declare function wrap(min: number, max: number): (value: number) => number;
124
+ /**
125
+ * The complete utils namespace, attached to Motion.utils
126
+ */
127
+ export declare const MotionUtils: {
128
+ readonly toArray: typeof toArray;
129
+ readonly clamp: typeof clamp;
130
+ readonly random: typeof random;
131
+ readonly snap: typeof snap;
132
+ readonly interpolate: typeof interpolate;
133
+ readonly mapRange: typeof mapRange;
134
+ readonly normalize: typeof normalize;
135
+ readonly wrap: typeof wrap;
136
+ };