@lottiefiles/dotlottie-web 0.63.0 → 0.64.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.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
+ //#region src/core/dotlottie-player.types.d.ts
1
2
  interface Marker {
2
- duration: number;
3
- name: string;
4
- time: number;
3
+ duration: number;
4
+ name: string;
5
+ time: number;
5
6
  }
6
-
7
+ //#endregion
8
+ //#region src/event-manager.d.ts
7
9
  /**
8
10
  * Represents the different types of events that can be dispatched.
9
11
  */
@@ -12,162 +14,161 @@ type EventType = 'complete' | 'frame' | 'load' | 'loadError' | 'renderError' | '
12
14
  * Maps an event type string to its respective event interface.
13
15
  */
14
16
  type EventByType<T extends EventType> = Extract<Event, {
15
- type: T;
17
+ type: T;
16
18
  }>;
17
19
  /**
18
20
  * Base interface for all events.
19
21
  */
20
22
  interface BaseEvent {
21
- type: EventType;
23
+ type: EventType;
22
24
  }
23
25
  interface RenderEvent extends BaseEvent {
24
- currentFrame: number;
25
- type: 'render';
26
+ currentFrame: number;
27
+ type: 'render';
26
28
  }
27
29
  interface FreezeEvent extends BaseEvent {
28
- type: 'freeze';
30
+ type: 'freeze';
29
31
  }
30
32
  interface UnfreezeEvent extends BaseEvent {
31
- type: 'unfreeze';
33
+ type: 'unfreeze';
32
34
  }
33
35
  interface DestroyEvent extends BaseEvent {
34
- type: 'destroy';
36
+ type: 'destroy';
35
37
  }
36
38
  /**
37
39
  * Event fired when a loop action occurs.
38
40
  */
39
41
  interface LoopEvent extends BaseEvent {
40
- loopCount: number;
41
- type: 'loop';
42
+ loopCount: number;
43
+ type: 'loop';
42
44
  }
43
45
  /**
44
46
  * Event fired during frame changes.
45
47
  */
46
48
  interface FrameEvent extends BaseEvent {
47
- currentFrame: number;
48
- type: 'frame';
49
+ currentFrame: number;
50
+ type: 'frame';
49
51
  }
50
52
  /**
51
53
  * Event fired when a load action occurs.
52
54
  */
53
55
  interface LoadEvent extends BaseEvent {
54
- type: 'load';
56
+ type: 'load';
55
57
  }
56
58
  /**
57
59
  * Event fired when a loading error occurs.
58
60
  */
59
61
  interface LoadErrorEvent extends BaseEvent {
60
- error: Error;
61
- type: 'loadError';
62
+ error: Error;
63
+ type: 'loadError';
62
64
  }
63
65
  /**
64
66
  * Event fired when a loading error occurs.
65
67
  */
66
68
  interface RenderErrorEvent extends BaseEvent {
67
- error: Error;
68
- type: 'renderError';
69
+ error: Error;
70
+ type: 'renderError';
69
71
  }
70
72
  /**
71
73
  * Event fired when a completion action occurs.
72
74
  */
73
75
  interface CompleteEvent extends BaseEvent {
74
- type: 'complete';
76
+ type: 'complete';
75
77
  }
76
78
  /**
77
79
  * Event fired when a pause action occurs.
78
80
  */
79
81
  interface PauseEvent extends BaseEvent {
80
- type: 'pause';
82
+ type: 'pause';
81
83
  }
82
84
  /**
83
85
  * Event fired when a play action occurs.
84
86
  */
85
87
  interface PlayEvent extends BaseEvent {
86
- type: 'play';
88
+ type: 'play';
87
89
  }
88
90
  /**
89
91
  * Event fired when a stop action occurs.
90
92
  */
91
93
  interface StopEvent extends BaseEvent {
92
- type: 'stop';
94
+ type: 'stop';
93
95
  }
94
96
  /**
95
97
  * Event fired when a WASM module is initialized and ready.
96
98
  */
97
99
  interface ReadyEvent extends BaseEvent {
98
- type: 'ready';
100
+ type: 'ready';
99
101
  }
100
102
  interface StateMachineStartEvent extends BaseEvent {
101
- type: 'stateMachineStart';
103
+ type: 'stateMachineStart';
102
104
  }
103
105
  interface StateMachineStopEvent extends BaseEvent {
104
- type: 'stateMachineStop';
106
+ type: 'stateMachineStop';
105
107
  }
106
108
  interface StateMachineTransitionEvent extends BaseEvent {
107
- fromState: string;
108
- toState: string;
109
- type: 'stateMachineTransition';
109
+ fromState: string;
110
+ toState: string;
111
+ type: 'stateMachineTransition';
110
112
  }
111
113
  interface StateMachineStateEnteredEvent extends BaseEvent {
112
- state: string;
113
- type: 'stateMachineStateEntered';
114
+ state: string;
115
+ type: 'stateMachineStateEntered';
114
116
  }
115
117
  interface StateMachineStateExitEvent extends BaseEvent {
116
- state: string;
117
- type: 'stateMachineStateExit';
118
+ state: string;
119
+ type: 'stateMachineStateExit';
118
120
  }
119
121
  interface StateMachineCustomEvent extends BaseEvent {
120
- eventName: string;
121
- type: 'stateMachineCustomEvent';
122
+ eventName: string;
123
+ type: 'stateMachineCustomEvent';
122
124
  }
123
125
  interface StateMachineErrorEvent extends BaseEvent {
124
- error: string;
125
- type: 'stateMachineError';
126
+ error: string;
127
+ type: 'stateMachineError';
126
128
  }
127
129
  interface StateMachineBooleanInputValueChangeEvent extends BaseEvent {
128
- inputName: string;
129
- newValue: boolean;
130
- oldValue: boolean;
131
- type: 'stateMachineBooleanInputValueChange';
130
+ inputName: string;
131
+ newValue: boolean;
132
+ oldValue: boolean;
133
+ type: 'stateMachineBooleanInputValueChange';
132
134
  }
133
135
  interface StateMachineNumericInputValueChangeEvent extends BaseEvent {
134
- inputName: string;
135
- newValue: number;
136
- oldValue: number;
137
- type: 'stateMachineNumericInputValueChange';
136
+ inputName: string;
137
+ newValue: number;
138
+ oldValue: number;
139
+ type: 'stateMachineNumericInputValueChange';
138
140
  }
139
141
  interface StateMachineStringInputValueChangeEvent extends BaseEvent {
140
- inputName: string;
141
- newValue: string;
142
- oldValue: string;
143
- type: 'stateMachineStringInputValueChange';
142
+ inputName: string;
143
+ newValue: string;
144
+ oldValue: string;
145
+ type: 'stateMachineStringInputValueChange';
144
146
  }
145
147
  interface StateMachineInputFiredEvent extends BaseEvent {
146
- inputName: string;
147
- type: 'stateMachineInputFired';
148
+ inputName: string;
149
+ type: 'stateMachineInputFired';
148
150
  }
149
151
  interface StateMachineInternalMessage extends BaseEvent {
150
- message: string;
151
- type: 'stateMachineInternalMessage';
152
+ message: string;
153
+ type: 'stateMachineInternalMessage';
152
154
  }
153
155
  /**
154
156
  * Type representing all possible event types.
155
157
  */
156
158
  type Event = LoopEvent | FrameEvent | LoadEvent | LoadErrorEvent | RenderErrorEvent | CompleteEvent | PauseEvent | PlayEvent | StopEvent | DestroyEvent | FreezeEvent | UnfreezeEvent | RenderEvent | ReadyEvent | StateMachineStartEvent | StateMachineStopEvent | StateMachineTransitionEvent | StateMachineStateEnteredEvent | StateMachineStateExitEvent | StateMachineCustomEvent | StateMachineErrorEvent | StateMachineBooleanInputValueChangeEvent | StateMachineNumericInputValueChangeEvent | StateMachineStringInputValueChangeEvent | StateMachineInputFiredEvent | StateMachineInternalMessage;
157
- interface EventListener<T extends EventType> {
158
- (event: EventByType<T>): void;
159
- }
159
+ type EventListener<T extends EventType> = (event: EventByType<T>) => void;
160
160
  /**
161
161
  * Manages registration and dispatching of event listeners.
162
162
  */
163
163
  declare class EventManager {
164
- private readonly _eventListeners;
165
- addEventListener<T extends EventType>(type: T, listener: EventListener<T>): void;
166
- removeEventListener<T extends EventType>(type: T, listener?: EventListener<T>): void;
167
- dispatch<T extends EventType>(event: EventByType<T>): void;
168
- removeAllEventListeners(): void;
164
+ private readonly _eventListeners;
165
+ addEventListener<T extends EventType>(type: T, listener: EventListener<T>): void;
166
+ removeEventListener<T extends EventType>(type: T, listener?: EventListener<T>): void;
167
+ dispatch<T extends EventType>(event: EventByType<T>): void;
168
+ removeAllEventListeners(): void;
169
169
  }
170
-
170
+ //#endregion
171
+ //#region src/types.d.ts
171
172
  /**
172
173
  * 3x3 transformation matrix for the entire animation on the canvas.
173
174
  * Represented as a flattened 9-element tuple in row-major order: [m00, m01, m02, m10, m11, m12, m20, m21, m22].
@@ -179,26 +180,26 @@ type Transform = [number, number, number, number, number, number, number, number
179
180
  * Controls how the animation is rendered and when rendering is optimized.
180
181
  */
181
182
  interface RenderConfig {
182
- /**
183
- * Automatically resize canvas when container size changes.
184
- * Set to true to maintain responsiveness without manual resize calls.
185
- */
186
- autoResize?: boolean;
187
- /**
188
- * Pixel density multiplier for high-DPI displays.
189
- * Higher values increase quality but use more memory. Defaults to window.devicePixelRatio.
190
- */
191
- devicePixelRatio?: number;
192
- /**
193
- * Pause rendering when canvas is outside the viewport.
194
- * Set to true (default) to improve performance when animation isn't visible.
195
- */
196
- freezeOnOffscreen?: boolean;
197
- /**
198
- * Rendering quality level (0-100).
199
- * Lower values reduce quality but improve performance on resource-constrained devices.
200
- */
201
- quality?: number;
183
+ /**
184
+ * Automatically resize canvas when container size changes.
185
+ * Set to true to maintain responsiveness without manual resize calls.
186
+ */
187
+ autoResize?: boolean;
188
+ /**
189
+ * Pixel density multiplier for high-DPI displays.
190
+ * Higher values increase quality but use more memory. Defaults to window.devicePixelRatio.
191
+ */
192
+ devicePixelRatio?: number;
193
+ /**
194
+ * Pause rendering when canvas is outside the viewport.
195
+ * Set to true (default) to improve performance when animation isn't visible.
196
+ */
197
+ freezeOnOffscreen?: boolean;
198
+ /**
199
+ * Rendering quality level (0-100).
200
+ * Lower values reduce quality but improve performance on resource-constrained devices.
201
+ */
202
+ quality?: number;
202
203
  }
203
204
  /**
204
205
  * Animation playback direction mode.
@@ -220,213 +221,209 @@ type Fit = 'contain' | 'cover' | 'fill' | 'none' | 'fit-width' | 'fit-height';
220
221
  * Determines how the animation fits and aligns within the available space.
221
222
  */
222
223
  interface Layout {
223
- /**
224
- * Alignment position as [x, y] coordinates in 0-1 range.
225
- * [0.5, 0.5] centers the animation, [0, 0] is top-left, [1, 1] is bottom-right.
226
- */
227
- align?: [number, number];
228
- /**
229
- * Fit mode controlling how animation scales to canvas dimensions.
230
- * Defaults to 'contain' to show the full animation without cropping.
231
- */
232
- fit?: Fit;
224
+ /**
225
+ * Alignment position as [x, y] coordinates in 0-1 range.
226
+ * [0.5, 0.5] centers the animation, [0, 0] is top-left, [1, 1] is bottom-right.
227
+ */
228
+ align?: [number, number];
229
+ /**
230
+ * Fit mode controlling how animation scales to canvas dimensions.
231
+ * Defaults to 'contain' to show the full animation without cropping.
232
+ */
233
+ fit?: Fit;
233
234
  }
234
235
  /**
235
236
  * Dimensions of a rendering surface for custom canvas implementations.
236
237
  * Used when providing a custom render surface instead of HTMLCanvasElement.
237
238
  */
238
239
  interface RenderSurface {
239
- /** Height of the render surface in pixels */
240
- height: number;
241
- /** Width of the render surface in pixels */
242
- width: number;
240
+ /** Height of the render surface in pixels */
241
+ height: number;
242
+ /** Width of the render surface in pixels */
243
+ width: number;
243
244
  }
244
245
  /**
245
246
  * Main configuration object for initializing a DotLottie player.
246
247
  * Specifies the animation source, playback behavior, rendering options, and canvas target.
247
248
  */
248
249
  interface Config {
249
- /**
250
- * ID of the specific animation to play from a multi-animation dotLottie file.
251
- * Leave undefined for single-animation files or to play the default animation.
252
- */
253
- animationId?: string;
254
- /**
255
- * Automatically start playback once the animation is loaded.
256
- * Set to true for animations that should play immediately without user interaction.
257
- */
258
- autoplay?: boolean;
259
- /**
260
- * Background color as a CSS color string (e.g., '#FFFFFF' or 'transparent').
261
- * Applied to the canvas element or as a fill behind the animation.
262
- */
263
- backgroundColor?: string;
264
- /**
265
- * Target canvas element for rendering.
266
- * Can be HTMLCanvasElement, OffscreenCanvas, or custom RenderSurface with dimensions.
267
- */
268
- canvas?: HTMLCanvasElement | OffscreenCanvas | RenderSurface;
269
- /**
270
- * Animation data to load directly.
271
- * Use this to load from a string, ArrayBuffer, or parsed JSON instead of fetching from src.
272
- */
273
- data?: Data;
274
- /**
275
- * Layout configuration for positioning and scaling the animation.
276
- * Controls fit mode and alignment within the canvas.
277
- */
278
- layout?: Layout;
279
- /**
280
- * Enable continuous looping of the animation.
281
- * Set to true to repeat indefinitely, or use loopCount for a specific number of loops.
282
- */
283
- loop?: boolean;
284
- /**
285
- * Number of additional times to replay the animation after the first play.
286
- * Requires `loop` to be true. A value of 0 means infinite replays; a positive value `n` means
287
- * the animation plays a total of `n + 1` times (initial play + `n` replays).
288
- */
289
- loopCount?: number;
290
- /**
291
- * Named marker to use as the playback segment.
292
- * Plays only the portion of the animation defined by this marker instead of the full animation.
293
- */
294
- marker?: string;
295
- /**
296
- * Playback direction mode.
297
- * Controls whether animation plays forward, reverse, or alternates (bounce).
298
- */
299
- mode?: Mode;
300
- /**
301
- * Rendering configuration controlling canvas behavior.
302
- * Includes autoResize, devicePixelRatio, freezeOnOffscreen, and quality settings.
303
- */
304
- renderConfig?: RenderConfig;
305
- /**
306
- * Frame range to play as [startFrame, endFrame].
307
- * Restricts playback to a specific portion of the animation instead of the full sequence.
308
- */
309
- segment?: [number, number];
310
- /**
311
- * Playback speed multiplier.
312
- * 1 is normal speed, 2 is double speed, 0.5 is half speed.
313
- */
314
- speed?: number;
315
- /**
316
- * URL to fetch the animation from.
317
- * Use this to load .lottie or .json files from a remote or local path.
318
- */
319
- src?: string;
320
- /**
321
- * State machine security configuration.
322
- * Controls URL opening policies for state machine-driven animations.
323
- */
324
- stateMachineConfig?: StateMachineConfig;
325
- /**
326
- * ID of the state machine to load and activate.
327
- * State machines enable interactive, event-driven animation behaviors.
328
- */
329
- stateMachineId?: string;
330
- /**
331
- * ID of the theme to apply to the animation.
332
- * Themes modify colors and visual properties defined in the dotLottie manifest.
333
- */
334
- themeId?: string;
335
- /**
336
- * Enable frame interpolation for smoother playback.
337
- * Set to true (default) for smoother animation, false for exact frame-by-frame playback.
338
- */
339
- useFrameInterpolation?: boolean;
250
+ /**
251
+ * ID of the specific animation to play from a multi-animation dotLottie file.
252
+ * Leave undefined for single-animation files or to play the default animation.
253
+ */
254
+ animationId?: string;
255
+ /**
256
+ * Automatically start playback once the animation is loaded.
257
+ * Set to true for animations that should play immediately without user interaction.
258
+ */
259
+ autoplay?: boolean;
260
+ /**
261
+ * Background color as a CSS color string (e.g., '#FFFFFF' or 'transparent').
262
+ * Applied to the canvas element or as a fill behind the animation.
263
+ */
264
+ backgroundColor?: string;
265
+ /**
266
+ * Target canvas element for rendering.
267
+ * Can be HTMLCanvasElement, OffscreenCanvas, or custom RenderSurface with dimensions.
268
+ */
269
+ canvas?: HTMLCanvasElement | OffscreenCanvas | RenderSurface;
270
+ /**
271
+ * Animation data to load directly.
272
+ * Use this to load from a string, ArrayBuffer, or parsed JSON instead of fetching from src.
273
+ */
274
+ data?: Data;
275
+ /**
276
+ * Layout configuration for positioning and scaling the animation.
277
+ * Controls fit mode and alignment within the canvas.
278
+ */
279
+ layout?: Layout;
280
+ /**
281
+ * Enable continuous looping of the animation.
282
+ * Set to true to repeat indefinitely, or use loopCount for a specific number of loops.
283
+ */
284
+ loop?: boolean;
285
+ /**
286
+ * Number of additional times to replay the animation after the first play.
287
+ * Requires `loop` to be true. A value of 0 means infinite replays; a positive value `n` means
288
+ * the animation plays a total of `n + 1` times (initial play + `n` replays).
289
+ */
290
+ loopCount?: number;
291
+ /**
292
+ * Named marker to use as the playback segment.
293
+ * Plays only the portion of the animation defined by this marker instead of the full animation.
294
+ */
295
+ marker?: string;
296
+ /**
297
+ * Playback direction mode.
298
+ * Controls whether animation plays forward, reverse, or alternates (bounce).
299
+ */
300
+ mode?: Mode;
301
+ /**
302
+ * Rendering configuration controlling canvas behavior.
303
+ * Includes autoResize, devicePixelRatio, freezeOnOffscreen, and quality settings.
304
+ */
305
+ renderConfig?: RenderConfig;
306
+ /**
307
+ * Frame range to play as [startFrame, endFrame].
308
+ * Restricts playback to a specific portion of the animation instead of the full sequence.
309
+ */
310
+ segment?: [number, number];
311
+ /**
312
+ * Playback speed multiplier.
313
+ * 1 is normal speed, 2 is double speed, 0.5 is half speed.
314
+ */
315
+ speed?: number;
316
+ /**
317
+ * URL to fetch the animation from.
318
+ * Use this to load .lottie or .json files from a remote or local path.
319
+ */
320
+ src?: string;
321
+ /**
322
+ * State machine security configuration.
323
+ * Controls URL opening policies for state machine-driven animations.
324
+ */
325
+ stateMachineConfig?: StateMachineConfig;
326
+ /**
327
+ * ID of the state machine to load and activate.
328
+ * State machines enable interactive, event-driven animation behaviors.
329
+ */
330
+ stateMachineId?: string;
331
+ /**
332
+ * ID of the theme to apply to the animation.
333
+ * Themes modify colors and visual properties defined in the dotLottie manifest.
334
+ */
335
+ themeId?: string;
336
+ /**
337
+ * Enable frame interpolation for smoother playback.
338
+ * Set to true (default) for smoother animation, false for exact frame-by-frame playback.
339
+ */
340
+ useFrameInterpolation?: boolean;
340
341
  }
341
342
  interface StateMachineConfig {
342
- /**
343
- * Controls whether and which URLs can be opened by a state machine.
344
- *
345
- * - requireUserInteraction: When true, URLs open only after an explicit user action
346
- * (e.g., click/pointer down) on the animation.
347
- * - whitelist: List of allowed URL patterns. An empty list blocks all URLs. Use
348
- * "*" to allow all URLs. Wildcards are supported in host and path (e.g.,
349
- * "*.example.com/*").
350
- *
351
- * @example
352
- * ```typescript
353
- * // Require user interaction before opening any URL
354
- * openUrlPolicy: { requireUserInteraction: true, whitelist: ["*"] }
355
- *
356
- * // Block all URLs
357
- * openUrlPolicy: { whitelist: [] }
358
- *
359
- * // Allow all URLs
360
- * openUrlPolicy: { whitelist: ["*"] }
361
- *
362
- * // Allow a specific domain only
363
- * openUrlPolicy: { whitelist: ["https://example.com"] }
364
- *
365
- * // Allow subdomains and any path under lottiefiles.com
366
- * openUrlPolicy: { whitelist: ["*.lottiefiles.com/*"] }
367
- * ```
368
- *
369
- * By default, URLs are denied and require user interaction.
370
- */
371
- openUrlPolicy?: {
372
- requireUserInteraction?: boolean;
373
- whitelist?: string[];
374
- };
343
+ /**
344
+ * Controls whether and which URLs can be opened by a state machine.
345
+ *
346
+ * - requireUserInteraction: When true, URLs open only after an explicit user action
347
+ * (e.g., click/pointer down) on the animation.
348
+ * - whitelist: List of allowed URL patterns. An empty list blocks all URLs. Use
349
+ * "*" to allow all URLs. Wildcards are supported in host and path (e.g.,
350
+ * "*.example.com/*").
351
+ *
352
+ * @example
353
+ * ```typescript
354
+ * // Require user interaction before opening any URL
355
+ * openUrlPolicy: { requireUserInteraction: true, whitelist: ["*"] }
356
+ *
357
+ * // Block all URLs
358
+ * openUrlPolicy: { whitelist: [] }
359
+ *
360
+ * // Allow all URLs
361
+ * openUrlPolicy: { whitelist: ["*"] }
362
+ *
363
+ * // Allow a specific domain only
364
+ * openUrlPolicy: { whitelist: ["https://example.com"] }
365
+ *
366
+ * // Allow subdomains and any path under lottiefiles.com
367
+ * openUrlPolicy: { whitelist: ["*.lottiefiles.com/*"] }
368
+ * ```
369
+ *
370
+ * By default, URLs are denied and require user interaction.
371
+ */
372
+ openUrlPolicy?: {
373
+ requireUserInteraction?: boolean;
374
+ whitelist?: string[];
375
+ };
375
376
  }
376
377
  /**
377
378
  * dotLottie manifest containing metadata about available animations, themes, and state machines.
378
379
  * Included in .lottie files to describe the contents and relationships between components.
379
380
  */
380
381
  interface Manifest {
381
- /**
382
- * List of animations available in this dotLottie file.
383
- * Each animation can have its own ID, themes, and background color.
384
- */
385
- animations: Array<{
386
- /** Background color for this animation */
387
- background?: string;
388
- /** Unique identifier for this animation */
389
- id: string;
390
- /** Default theme to apply when this animation loads */
391
- initialTheme?: string;
392
- /** List of theme IDs compatible with this animation */
393
- themes?: string[];
394
- }>;
395
- /** Tool or application that created this dotLottie file */
396
- generator?: string;
397
- /** List of available state machines for interactive behavior */
398
- stateMachines?: Array<{
399
- id: string;
400
- }>;
401
- /** List of available themes that can modify animation appearance */
402
- themes?: Array<{
403
- id: string;
404
- }>;
405
- /** dotLottie specification version */
406
- version?: string;
382
+ /**
383
+ * List of animations available in this dotLottie file.
384
+ * Each animation can have its own ID, themes, and background color.
385
+ */
386
+ animations: Array<{
387
+ /** Background color for this animation */background?: string; /** Unique identifier for this animation */
388
+ id: string; /** Default theme to apply when this animation loads */
389
+ initialTheme?: string; /** List of theme IDs compatible with this animation */
390
+ themes?: string[];
391
+ }>;
392
+ /** Tool or application that created this dotLottie file */
393
+ generator?: string;
394
+ /** List of available state machines for interactive behavior */
395
+ stateMachines?: Array<{
396
+ id: string;
397
+ }>;
398
+ /** List of available themes that can modify animation appearance */
399
+ themes?: Array<{
400
+ id: string;
401
+ }>;
402
+ /** dotLottie specification version */
403
+ version?: string;
407
404
  }
408
405
  /**
409
406
  * Bezier easing handle for keyframe interpolation
410
407
  */
411
408
  interface BezierHandle {
412
- x: number | number[];
413
- y: number | number[];
409
+ x: number | number[];
410
+ y: number | number[];
414
411
  }
415
412
  /**
416
413
  * Keyframe in Lottie native format
417
414
  * The value type (Color, Vector, number, etc.)
418
415
  */
419
416
  interface Keyframe<T> {
420
- /** Hold keyframe - no interpolation to next keyframe */
421
- h?: 0 | 1;
422
- /** Incoming bezier handle (optional, for easing) */
423
- i?: BezierHandle;
424
- /** Outgoing bezier handle (optional, for easing) */
425
- o?: BezierHandle;
426
- /** Start value at this keyframe */
427
- s: T;
428
- /** Time (frame number) */
429
- t: number;
417
+ /** Hold keyframe - no interpolation to next keyframe */
418
+ h?: 0 | 1;
419
+ /** Incoming bezier handle (optional, for easing) */
420
+ i?: BezierHandle;
421
+ /** Outgoing bezier handle (optional, for easing) */
422
+ o?: BezierHandle;
423
+ /** Start value at this keyframe */
424
+ s: T;
425
+ /** Time (frame number) */
426
+ t: number;
430
427
  }
431
428
  /**
432
429
  * Color as RGB or RGBA array with values normalized to [0, 1]
@@ -478,24 +475,24 @@ type GradientSlotValue = Gradient | Array<Keyframe<Gradient>>;
478
475
  * @see https://lottiefiles.github.io/lottie-docs/text/#text-document
479
476
  */
480
477
  interface TextDocument {
481
- /** Font family */
482
- f?: string;
483
- /** Fill color [r, g, b] or [r, g, b, a] in [0, 1] range */
484
- fc?: Color;
485
- /** Justify: 0=left, 1=right, 2=center */
486
- j?: 0 | 1 | 2;
487
- /** Line height */
488
- lh?: number;
489
- /** Font size */
490
- s?: number;
491
- /** Stroke color [r, g, b] or [r, g, b, a] in [0, 1] range */
492
- sc?: Color;
493
- /** Stroke width */
494
- sw?: number;
495
- /** Text content (newlines encoded with carriage return) */
496
- t?: string;
497
- /** Tracking (letter spacing) */
498
- tr?: number;
478
+ /** Font family */
479
+ f?: string;
480
+ /** Fill color [r, g, b] or [r, g, b, a] in [0, 1] range */
481
+ fc?: Color;
482
+ /** Justify: 0=left, 1=right, 2=center */
483
+ j?: 0 | 1 | 2;
484
+ /** Line height */
485
+ lh?: number;
486
+ /** Font size */
487
+ s?: number;
488
+ /** Stroke color [r, g, b] or [r, g, b, a] in [0, 1] range */
489
+ sc?: Color;
490
+ /** Stroke width */
491
+ sw?: number;
492
+ /** Text content (newlines encoded with carriage return) */
493
+ t?: string;
494
+ /** Tracking (letter spacing) */
495
+ tr?: number;
499
496
  }
500
497
  /**
501
498
  * Text slot value - always static (text documents don't support animation)
@@ -510,62 +507,62 @@ type SlotType = 'color' | 'gradient' | 'image' | 'text' | 'scalar' | 'vector';
510
507
  * Base properties shared by all theme keyframes.
511
508
  */
512
509
  interface ThemeBaseKeyframe {
513
- /** Timeline position in animation frames */
514
- frame: number;
515
- /** When true, holds value without interpolation until next keyframe */
516
- hold?: boolean;
517
- /** Incoming Bézier handle for easing into this keyframe */
518
- inTangent?: BezierHandle;
519
- /** Outgoing Bézier handle for easing out of this keyframe */
520
- outTangent?: BezierHandle;
510
+ /** Timeline position in animation frames */
511
+ frame: number;
512
+ /** When true, holds value without interpolation until next keyframe */
513
+ hold?: boolean;
514
+ /** Incoming Bézier handle for easing into this keyframe */
515
+ inTangent?: BezierHandle;
516
+ /** Outgoing Bézier handle for easing out of this keyframe */
517
+ outTangent?: BezierHandle;
521
518
  }
522
519
  /**
523
520
  * Color keyframe for animated color transitions.
524
521
  */
525
522
  interface ThemeColorKeyframe extends ThemeBaseKeyframe {
526
- /** Color value as normalized RGB or RGBA (0-1 range) */
527
- value: Color;
523
+ /** Color value as normalized RGB or RGBA (0-1 range) */
524
+ value: Color;
528
525
  }
529
526
  /**
530
527
  * Scalar keyframe for animated numeric properties.
531
528
  */
532
529
  interface ThemeScalarKeyframe extends ThemeBaseKeyframe {
533
- /** Numeric value at this keyframe */
534
- value: number;
530
+ /** Numeric value at this keyframe */
531
+ value: number;
535
532
  }
536
533
  /**
537
534
  * Position keyframe for animated position properties.
538
535
  */
539
536
  interface ThemePositionKeyframe extends ThemeBaseKeyframe {
540
- /** Position as 2D or 3D coordinates */
541
- value: Vector;
542
- /** Incoming tangent for spatial interpolation (curved paths) */
543
- valueInTangent?: number[];
544
- /** Outgoing tangent for spatial interpolation (curved paths) */
545
- valueOutTangent?: number[];
537
+ /** Position as 2D or 3D coordinates */
538
+ value: Vector;
539
+ /** Incoming tangent for spatial interpolation (curved paths) */
540
+ valueInTangent?: number[];
541
+ /** Outgoing tangent for spatial interpolation (curved paths) */
542
+ valueOutTangent?: number[];
546
543
  }
547
544
  /**
548
545
  * Vector keyframe for animated vector properties (scale, size, etc.).
549
546
  */
550
547
  interface ThemeVectorKeyframe extends ThemeBaseKeyframe {
551
- /** Vector value as [x, y] or [x, y, z] */
552
- value: Vector;
548
+ /** Vector value as [x, y] or [x, y, z] */
549
+ value: Vector;
553
550
  }
554
551
  /**
555
552
  * Gradient color stop definition.
556
553
  */
557
554
  interface ThemeGradientStop {
558
- /** Color as RGB or RGBA (0-1 range) */
559
- color: Color;
560
- /** Position along gradient line (0-1) */
561
- offset: number;
555
+ /** Color as RGB or RGBA (0-1 range) */
556
+ color: Color;
557
+ /** Position along gradient line (0-1) */
558
+ offset: number;
562
559
  }
563
560
  /**
564
561
  * Gradient keyframe for animated gradient transitions.
565
562
  */
566
563
  interface ThemeGradientKeyframe extends ThemeBaseKeyframe {
567
- /** Array of gradient stops at this keyframe */
568
- value: ThemeGradientStop[];
564
+ /** Array of gradient stops at this keyframe */
565
+ value: ThemeGradientStop[];
569
566
  }
570
567
  /**
571
568
  * Text justification options.
@@ -581,135 +578,135 @@ type ThemeTextCaps = 'Regular' | 'AllCaps' | 'SmallCaps';
581
578
  * @see https://dotlottie.io/spec/2.0/#text-document
582
579
  */
583
580
  interface ThemeTextDocument {
584
- /** Vertical baseline offset in pixels */
585
- baselineShift?: number;
586
- /** Fill color as RGB or RGBA (0-1 range) */
587
- fillColor?: Color;
588
- /** Font family name */
589
- fontName?: string;
590
- /** Font size in points */
591
- fontSize?: number;
592
- /** Text alignment and justification */
593
- justify?: ThemeTextJustify;
594
- /** Line height spacing multiplier */
595
- lineHeight?: number;
596
- /** Stroke color as RGB or RGBA (0-1 range) */
597
- strokeColor?: Color;
598
- /** When true, stroke renders over fill */
599
- strokeOverFill?: boolean;
600
- /** Stroke width in pixels */
601
- strokeWidth?: number;
602
- /** Text content to display */
603
- text?: string;
604
- /** Text capitalization style */
605
- textCaps?: ThemeTextCaps;
606
- /** Letter spacing in 1/1000 em units */
607
- tracking?: number;
608
- /** Text wrap box position [x, y] */
609
- wrapPosition?: [number, number];
610
- /** Text wrap bounding box [width, height] */
611
- wrapSize?: [number, number];
581
+ /** Vertical baseline offset in pixels */
582
+ baselineShift?: number;
583
+ /** Fill color as RGB or RGBA (0-1 range) */
584
+ fillColor?: Color;
585
+ /** Font family name */
586
+ fontName?: string;
587
+ /** Font size in points */
588
+ fontSize?: number;
589
+ /** Text alignment and justification */
590
+ justify?: ThemeTextJustify;
591
+ /** Line height spacing multiplier */
592
+ lineHeight?: number;
593
+ /** Stroke color as RGB or RGBA (0-1 range) */
594
+ strokeColor?: Color;
595
+ /** When true, stroke renders over fill */
596
+ strokeOverFill?: boolean;
597
+ /** Stroke width in pixels */
598
+ strokeWidth?: number;
599
+ /** Text content to display */
600
+ text?: string;
601
+ /** Text capitalization style */
602
+ textCaps?: ThemeTextCaps;
603
+ /** Letter spacing in 1/1000 em units */
604
+ tracking?: number;
605
+ /** Text wrap box position [x, y] */
606
+ wrapPosition?: [number, number];
607
+ /** Text wrap bounding box [width, height] */
608
+ wrapSize?: [number, number];
612
609
  }
613
610
  /**
614
611
  * Text keyframe for animated text document properties.
615
612
  */
616
613
  interface ThemeTextKeyframe {
617
- /** Timeline position in animation frames */
618
- frame: number;
619
- /** Text document configuration at this keyframe */
620
- value: ThemeTextDocument;
614
+ /** Timeline position in animation frames */
615
+ frame: number;
616
+ /** Text document configuration at this keyframe */
617
+ value: ThemeTextDocument;
621
618
  }
622
619
  /**
623
620
  * Image value for theme image rules.
624
621
  */
625
622
  interface ThemeImageValue {
626
- /** Display height in pixels */
627
- height?: number;
628
- /** Reference to image in dotLottie package (i/ folder) */
629
- id?: string;
630
- /** External URL or data URI (fallback if id not found) */
631
- url?: string;
632
- /** Display width in pixels */
633
- width?: number;
623
+ /** Display height in pixels */
624
+ height?: number;
625
+ /** Reference to image in dotLottie package (i/ folder) */
626
+ id?: string;
627
+ /** External URL or data URI (fallback if id not found) */
628
+ url?: string;
629
+ /** Display width in pixels */
630
+ width?: number;
634
631
  }
635
632
  /**
636
633
  * Base properties shared by all theme rules.
637
634
  */
638
635
  interface ThemeBaseRule {
639
- /** Limit rule to specific animations (omit to apply to all) */
640
- animations?: string[];
641
- /** Lottie expression for dynamic values */
642
- expression?: string;
643
- /** Slot ID in the Lottie animation (case-sensitive) */
644
- id: string;
636
+ /** Limit rule to specific animations (omit to apply to all) */
637
+ animations?: string[];
638
+ /** Lottie expression for dynamic values */
639
+ expression?: string;
640
+ /** Slot ID in the Lottie animation (case-sensitive) */
641
+ id: string;
645
642
  }
646
643
  /**
647
644
  * Color rule for overriding color properties (fill, stroke, text color).
648
645
  */
649
646
  interface ThemeColorRule extends ThemeBaseRule {
650
- /** Animated color keyframes */
651
- keyframes?: ThemeColorKeyframe[];
652
- type: 'Color';
653
- /** Static color value (RGB or RGBA, 0-1 range) */
654
- value?: Color;
647
+ /** Animated color keyframes */
648
+ keyframes?: ThemeColorKeyframe[];
649
+ type: 'Color';
650
+ /** Static color value (RGB or RGBA, 0-1 range) */
651
+ value?: Color;
655
652
  }
656
653
  /**
657
654
  * Scalar rule for overriding numeric properties (opacity, stroke width, rotation).
658
655
  */
659
656
  interface ThemeScalarRule extends ThemeBaseRule {
660
- /** Animated scalar keyframes */
661
- keyframes?: ThemeScalarKeyframe[];
662
- type: 'Scalar';
663
- /** Static numeric value */
664
- value?: number;
657
+ /** Animated scalar keyframes */
658
+ keyframes?: ThemeScalarKeyframe[];
659
+ type: 'Scalar';
660
+ /** Static numeric value */
661
+ value?: number;
665
662
  }
666
663
  /**
667
664
  * Position rule for overriding position properties.
668
665
  */
669
666
  interface ThemePositionRule extends ThemeBaseRule {
670
- /** Animated position keyframes */
671
- keyframes?: ThemePositionKeyframe[];
672
- type: 'Position';
673
- /** Static position (2D or 3D coordinates) */
674
- value?: Vector;
667
+ /** Animated position keyframes */
668
+ keyframes?: ThemePositionKeyframe[];
669
+ type: 'Position';
670
+ /** Static position (2D or 3D coordinates) */
671
+ value?: Vector;
675
672
  }
676
673
  /**
677
674
  * Vector rule for overriding vector properties (scale, size).
678
675
  */
679
676
  interface ThemeVectorRule extends ThemeBaseRule {
680
- /** Animated vector keyframes */
681
- keyframes?: ThemeVectorKeyframe[];
682
- type: 'Vector';
683
- /** Static vector value */
684
- value?: Vector;
677
+ /** Animated vector keyframes */
678
+ keyframes?: ThemeVectorKeyframe[];
679
+ type: 'Vector';
680
+ /** Static vector value */
681
+ value?: Vector;
685
682
  }
686
683
  /**
687
684
  * Gradient rule for overriding gradient properties.
688
685
  */
689
686
  interface ThemeGradientRule extends ThemeBaseRule {
690
- /** Animated gradient keyframes */
691
- keyframes?: ThemeGradientKeyframe[];
692
- type: 'Gradient';
693
- /** Static gradient (array of color stops) */
694
- value?: ThemeGradientStop[];
687
+ /** Animated gradient keyframes */
688
+ keyframes?: ThemeGradientKeyframe[];
689
+ type: 'Gradient';
690
+ /** Static gradient (array of color stops) */
691
+ value?: ThemeGradientStop[];
695
692
  }
696
693
  /**
697
694
  * Image rule for overriding image assets.
698
695
  */
699
696
  interface ThemeImageRule extends ThemeBaseRule {
700
- type: 'Image';
701
- /** Image replacement configuration (required for Image rules) */
702
- value: ThemeImageValue;
697
+ type: 'Image';
698
+ /** Image replacement configuration (required for Image rules) */
699
+ value: ThemeImageValue;
703
700
  }
704
701
  /**
705
702
  * Text rule for overriding text document properties.
706
703
  */
707
704
  interface ThemeTextRule extends ThemeBaseRule {
708
- /** Animated text keyframes */
709
- keyframes?: ThemeTextKeyframe[];
710
- type: 'Text';
711
- /** Static text document configuration */
712
- value?: ThemeTextDocument;
705
+ /** Animated text keyframes */
706
+ keyframes?: ThemeTextKeyframe[];
707
+ type: 'Text';
708
+ /** Static text document configuration */
709
+ value?: ThemeTextDocument;
713
710
  }
714
711
  /**
715
712
  * Union of all theme rule types.
@@ -745,783 +742,785 @@ type ThemeRule = ThemeColorRule | ThemeScalarRule | ThemePositionRule | ThemeVec
745
742
  * ```
746
743
  */
747
744
  interface Theme {
748
- /** Array of rules defining property overrides */
749
- rules: ThemeRule[];
745
+ /** Array of rules defining property overrides */
746
+ rules: ThemeRule[];
750
747
  }
751
-
748
+ //#endregion
749
+ //#region src/dotlottie.d.ts
752
750
  declare class DotLottie {
753
- private _canvas;
754
- private _pendingLoad;
755
- private _context;
756
- private readonly _eventManager;
757
- private _animationFrameId;
758
- private readonly _frameManager;
759
- private _dotLottieCore;
760
- private _stateMachineId;
761
- private _stateMachineConfig;
762
- private _isStateMachineRunning;
763
- private _stateMachineObserverHandle;
764
- private _stateMachineInternalMessageObserver;
765
- private _dotLottieObserverHandle;
766
- private static _wasmModule;
767
- private _renderConfig;
768
- private _isFrozen;
769
- private _backgroundColor;
770
- private _boundOnClick;
771
- private _boundOnPointerUp;
772
- private _boundOnPointerDown;
773
- private _boundOnPointerMove;
774
- private _boundOnPointerEnter;
775
- private _boundOnPointerLeave;
776
- private _bufferMismatchCount;
777
- private _lastExpectedBufferSize;
778
- /**
779
- * Creates a new DotLottie player instance for rendering Lottie animations.
780
- * Initializes the WASM module, event system, and loads animation if src or data is provided in config.
781
- * @param config - Configuration object specifying animation source, playback settings, and rendering options
782
- */
783
- constructor(config: Config);
784
- private _dispatchError;
785
- private _fetchData;
786
- private _loadFromData;
787
- private _loadFromSrc;
788
- /**
789
- * Gets the raw pixel buffer containing the rendered animation frame.
790
- * Returns RGBA pixel data as a Uint8Array for advanced image processing or custom rendering.
791
- */
792
- get buffer(): Uint8Array | null;
793
- /**
794
- * Gets the ID of the currently active animation from a multi-animation dotLottie file.
795
- * Returns undefined if no specific animation is active or for single-animation files.
796
- */
797
- get activeAnimationId(): string | undefined;
798
- /**
799
- * Gets the ID of the currently active theme applied to the animation.
800
- * Returns undefined if no theme is active. Themes modify colors and visual properties.
801
- */
802
- get activeThemeId(): string | undefined;
803
- /**
804
- * Gets the current layout configuration for positioning and scaling the animation.
805
- * Includes fit mode (contain, cover, fill, etc.) and alignment [x, y] values (0-1 range).
806
- */
807
- get layout(): Layout | undefined;
808
- /**
809
- * Gets the currently active marker name if a marker-based segment is set.
810
- * Returns undefined if no marker is active. Use setMarker() to activate a named segment.
811
- */
812
- get marker(): string | undefined;
813
- /**
814
- * Gets the animation manifest containing metadata about animations, themes, and states.
815
- * Returns null if no manifest is available or if the loaded animation doesn't include one.
816
- */
817
- get manifest(): Manifest | null;
818
- /**
819
- * Gets the current rendering configuration.
820
- * Includes settings like devicePixelRatio, autoResize, and freezeOnOffscreen.
821
- */
822
- get renderConfig(): RenderConfig;
823
- /**
824
- * Gets the currently active playback segment as [startFrame, endFrame].
825
- * If no segment is set, returns undefined and the full animation plays.
826
- */
827
- get segment(): [number, number] | undefined;
828
- /**
829
- * Gets the current loop configuration.
830
- * Returns true if the animation is set to loop continuously.
831
- */
832
- get loop(): boolean;
833
- /**
834
- * Gets the current playback mode.
835
- * Determines playback direction: 'forward', 'reverse', 'bounce' (forward then reverse), or 'reverse-bounce'.
836
- */
837
- get mode(): Mode;
838
- /**
839
- * Indicates whether rendering is currently frozen.
840
- * True when freeze() has been called and the rendering loop is paused to save resources.
841
- */
842
- get isFrozen(): boolean;
843
- /**
844
- * Indicates whether a state machine is currently active and running.
845
- * True after stateMachineStart() is called and until stateMachineStop() is called.
846
- */
847
- get isStateMachineRunning(): boolean;
848
- /**
849
- * Gets the current background color.
850
- * Returns the background color as a string (e.g., '#FFFFFF' or 'transparent').
851
- */
852
- get backgroundColor(): string;
853
- /**
854
- * Gets the autoplay configuration.
855
- * Returns true if the animation is configured to start playing automatically when loaded.
856
- */
857
- get autoplay(): boolean;
858
- /**
859
- * Gets the frame interpolation setting.
860
- * Returns true if frame interpolation is enabled for smoother animation playback.
861
- */
862
- get useFrameInterpolation(): boolean;
863
- /**
864
- * Gets the current playback speed.
865
- * Returns the speed multiplier (1 = normal speed, 2 = double speed, 0.5 = half speed).
866
- */
867
- get speed(): number;
868
- /**
869
- * Indicates whether the WASM module and core player have been initialized.
870
- * Check this before performing operations that require the player to be ready.
871
- */
872
- get isReady(): boolean;
873
- /**
874
- * Indicates whether an animation has been successfully loaded and is ready for playback.
875
- * Check this before calling play() or other playback methods to ensure the animation is ready.
876
- */
877
- get isLoaded(): boolean;
878
- /**
879
- * Indicates whether the animation is currently playing.
880
- * True when animation is actively playing, false when paused, stopped, or not started.
881
- */
882
- get isPlaying(): boolean;
883
- /**
884
- * Indicates whether the animation is currently paused.
885
- * True when pause() has been called and animation is not playing or stopped.
886
- */
887
- get isPaused(): boolean;
888
- /**
889
- * Indicates whether the animation is currently stopped.
890
- * True when stop() has been called or animation hasn't started yet.
891
- */
892
- get isStopped(): boolean;
893
- /**
894
- * Gets the current frame number of the animation.
895
- * Useful for tracking playback position or implementing custom frame displays. Rounded to 2 decimal places.
896
- */
897
- get currentFrame(): number;
898
- /**
899
- * Gets the number of times the animation has completed a loop during the current playback.
900
- * Increments each time the animation completes one full cycle.
901
- */
902
- get loopCount(): number;
903
- /**
904
- * Gets the total number of frames in the animation.
905
- * Use with currentFrame to calculate playback progress as a percentage.
906
- */
907
- get totalFrames(): number;
908
- /**
909
- * Gets the total duration of the animation in seconds.
910
- * Represents the time to play from the first frame to the last at normal speed (speed = 1).
911
- */
912
- get duration(): number;
913
- /**
914
- * Gets the duration of the currently active segment in seconds.
915
- * If no segment is set, returns the full animation duration.
916
- */
917
- get segmentDuration(): number;
918
- /**
919
- * Gets the canvas element used for rendering the animation.
920
- * Returns the HTMLCanvasElement, OffscreenCanvas, or RenderSurface set during initialization.
921
- */
922
- get canvas(): HTMLCanvasElement | OffscreenCanvas | RenderSurface | null;
923
- /**
924
- * Dynamically loads a new animation, replacing the current one if any.
925
- * Stops current playback, cleans up resources, and loads from the provided src or data.
926
- * @param config - Configuration for the new animation (all Config properties except canvas)
927
- */
928
- load(config: Omit<Config, 'canvas'>): void;
929
- private _draw;
930
- private _cleanupCanvas;
931
- private _initializeCanvas;
932
- private _stopAnimationLoop;
933
- private _startAnimationLoop;
934
- private _animationLoop;
935
- /**
936
- * Starts or resumes animation playback from the current frame.
937
- * Unfreezes rendering if frozen and starts the animation loop. Updates isPlaying state to true.
938
- */
939
- play(): void;
940
- /**
941
- * Pauses animation playback at the current frame.
942
- * Stops the animation loop while preserving the current frame position. Updates isPaused state to true.
943
- */
944
- pause(): void;
945
- /**
946
- * Stops animation playback and resets to the start frame.
947
- * Halts the animation loop and returns to the beginning. Updates isStopped state to true.
948
- */
949
- stop(): void;
950
- /**
951
- * Seeks to a specific frame in the animation and renders it.
952
- * Useful for implementing custom scrubbing controls or precise frame positioning.
953
- * @param frame - The target frame number to seek to
954
- */
955
- setFrame(frame: number): void;
956
- /**
957
- * Changes the animation playback speed.
958
- * Values above 1 speed up playback, below 1 slow it down.
959
- * @param speed - Playback speed multiplier (e.g., 2 for 2x speed, 0.5 for half speed)
960
- */
961
- setSpeed(speed: number): void;
962
- /**
963
- * Changes the background color of the canvas or animation.
964
- * For HTMLCanvasElement, sets the CSS background. For other surfaces, renders behind the animation.
965
- * @param color - CSS color string (e.g., '#FFFFFF', 'rgba(0,0,0,0.5)', 'transparent')
966
- */
967
- setBackgroundColor(color: string): void;
968
- /**
969
- * Enables or disables continuous looping of the animation.
970
- * When enabled with loopCount set to 0, animation repeats indefinitely.
971
- * @param loop - True to enable looping, false to play once
972
- */
973
- setLoop(loop: boolean): void;
974
- /**
975
- * Sets the number of additional times to replay the animation after the first play.
976
- * Requires loop to be true. A value of 0 means infinite replays; a positive value n means
977
- * the animation plays a total of n + 1 times (initial play + n replays).
978
- * @param loopCount - Number of additional replays (0 = infinite, 1 = plays twice, 2 = plays three times, etc.)
979
- */
980
- setLoopCount(loopCount: number): void;
981
- /**
982
- * Enables or disables frame interpolation for smoother playback.
983
- * When enabled, interpolates between frames. When disabled, shows exact frame-by-frame animation.
984
- * @param useFrameInterpolation - True for smooth interpolation, false for exact frames
985
- */
986
- setUseFrameInterpolation(useFrameInterpolation: boolean): void;
987
- /**
988
- * Subscribes to animation events like play, pause, frame, complete, etc.
989
- * Use this to react to animation state changes and playback progress.
990
- * @param type - Event type to listen for (e.g., 'play', 'frame', 'complete')
991
- * @param listener - Callback function invoked when the event occurs
992
- */
993
- addEventListener<T extends EventType>(type: T, listener: EventListener<T>): void;
994
- /**
995
- * Unsubscribes from animation events.
996
- * If no listener is provided, removes all listeners for the given event type.
997
- * @param type - Event type to stop listening for
998
- * @param listener - Specific callback to remove, or undefined to remove all
999
- */
1000
- removeEventListener<T extends EventType>(type: T, listener?: EventListener<T>): void;
1001
- /**
1002
- * Cleans up and destroys the player instance, releasing all resources.
1003
- * Stops playback, removes event listeners, and frees WASM memory. Call when the player is no longer needed.
1004
- */
1005
- destroy(): void;
1006
- /**
1007
- * Pauses the rendering loop without changing playback state.
1008
- * Useful for reducing CPU/GPU usage when the animation is offscreen or hidden. Dispatches 'freeze' event.
1009
- */
1010
- freeze(): void;
1011
- /**
1012
- * Resumes the rendering loop after being frozen.
1013
- * Restarts frame rendering while maintaining the current playback state. Dispatches 'unfreeze' event.
1014
- */
1015
- unfreeze(): void;
1016
- /**
1017
- * Recalculates and updates canvas dimensions based on current size.
1018
- * Call this when the canvas container size changes to maintain proper rendering. Usually handled by autoResize.
1019
- */
1020
- resize(): void;
1021
- /**
1022
- * Changes the canvas element used for rendering.
1023
- * Useful for moving the animation to a different canvas without recreating the player instance.
1024
- * @param canvas - New HTMLCanvasElement, OffscreenCanvas, or RenderSurface to render to
1025
- */
1026
- setCanvas(canvas: HTMLCanvasElement | OffscreenCanvas | RenderSurface): void;
1027
- /**
1028
- * Applies a 3x3 transformation matrix to the entire animation on the canvas.
1029
- * Use this to translate, rotate, scale, or skew the animation rendering.
1030
- * @param transform - 9-element array representing the transformation matrix in row-major order
1031
- * @returns True if transformation was applied successfully, false otherwise
1032
- */
1033
- setTransform(transform: Transform): boolean;
1034
- /**
1035
- * Gets the 3x3 transformation matrix applied to the animation.
1036
- * Returns a 9-element array representing affine transformations (translation, rotation, scale, skew).
1037
- * @returns Transform array of 9 numbers, or undefined if not available
1038
- */
1039
- getTransform(): Transform | undefined;
1040
- /**
1041
- * Sets a frame range to play instead of the full animation.
1042
- * Useful for playing specific sections or creating animation sequences from subsections.
1043
- * @param startFrame - Starting frame number (inclusive)
1044
- * @param endFrame - Ending frame number (inclusive)
1045
- */
1046
- setSegment(startFrame: number, endFrame: number): void;
1047
- /**
1048
- * Changes the playback direction mode.
1049
- * Controls whether animation plays forward, in reverse, or alternates (bounce).
1050
- * @param mode - Playback mode: 'forward', 'reverse', 'bounce', or 'reverse-bounce'
1051
- */
1052
- setMode(mode: Mode): void;
1053
- /**
1054
- * Updates rendering configuration like autoResize, devicePixelRatio, and freezeOnOffscreen.
1055
- * Dynamically changes how the canvas behaves without reloading the animation.
1056
- * @param config - Partial RenderConfig with properties to update
1057
- */
1058
- setRenderConfig(config: RenderConfig): void;
1059
- /**
1060
- * Switches to a different animation within a multi-animation dotLottie file.
1061
- * Use this to load a different animation by its ID without creating a new player instance.
1062
- * @param animationId - ID of the animation to load (must exist in the manifest)
1063
- */
1064
- loadAnimation(animationId: string): void;
1065
- /**
1066
- * Activates a named marker to play only that marked segment.
1067
- * Markers define named sections within an animation. Use markers() to list available markers.
1068
- * @param marker - Name of the marker to activate
1069
- */
1070
- setMarker(marker: string): void;
1071
- /**
1072
- * Gets all markers defined in the animation with their time and duration.
1073
- * Markers represent named sections that can be played using setMarker().
1074
- * @returns Array of marker objects with name, time, and duration properties
1075
- */
1076
- markers(): Marker[];
1077
- /**
1078
- * Applies a theme to the animation, modifying colors and visual properties.
1079
- * Themes are predefined in the dotLottie manifest. Returns true if theme was successfully loaded.
1080
- * @param themeId - ID of the theme to apply (must exist in manifest)
1081
- * @returns True if theme loaded successfully, false otherwise
1082
- */
1083
- setTheme(themeId: string): boolean;
1084
- /**
1085
- * Removes the currently applied theme and restores original animation colors.
1086
- * Use this to revert to the default appearance after applying a theme.
1087
- * @returns True if theme was reset successfully, false otherwise
1088
- */
1089
- resetTheme(): boolean;
1090
- /**
1091
- * Applies a custom theme from theme data instead of manifest theme ID.
1092
- * Useful for dynamically generated or user-created themes not in the manifest.
1093
- *
1094
- * @param themeData - Theme data as a JSON string or a structured Theme object
1095
- * @returns True if theme loaded successfully, false otherwise
1096
- *
1097
- * @example
1098
- * ```typescript
1099
- * // Using a string (existing behavior)
1100
- * dotLottie.setThemeData('{"rules":[{"id":"bg","type":"Color","value":[1,0,0]}]}');
1101
- *
1102
- * // Using a Theme object (new behavior)
1103
- * dotLottie.setThemeData({
1104
- * rules: [
1105
- * {
1106
- * id: 'background_color',
1107
- * type: 'Color',
1108
- * value: [0.2, 0.4, 0.8]
1109
- * },
1110
- * {
1111
- * id: 'title',
1112
- * type: 'Text',
1113
- * value: {
1114
- * text: 'Hello World',
1115
- * fontSize: 48,
1116
- * fillColor: [1, 1, 1]
1117
- * }
1118
- * }
1119
- * ]
1120
- * });
1121
- * ```
1122
- */
1123
- setThemeData(themeData: Theme | string): boolean;
1124
- /**
1125
- * Sets multiple slot values at once for parameterized animations.
1126
- * Slots allow runtime customization of colors, text, images, or other properties.
1127
- * @param slots - Object mapping slot IDs to their values
1128
- */
1129
- setSlots(slots: Record<string, unknown>): void;
1130
- /**
1131
- * Check if value is an array of keyframes (has objects with 't' and 's' properties)
1132
- */
1133
- private _isKeyframeArray;
1134
- /**
1135
- * Get all slot IDs in the animation
1136
- * @returns Array of slot ID strings
1137
- */
1138
- getSlotIds(): string[];
1139
- /**
1140
- * Get the type of a slot
1141
- * @param slotId - The slot ID to query
1142
- * @returns The slot type ('color', 'gradient', 'text', 'scalar', 'vector', 'position', 'image') or undefined
1143
- */
1144
- getSlotType(slotId: string): SlotType | undefined;
1145
- /**
1146
- * Get the current value of a slot
1147
- * @param slotId - The slot ID to query
1148
- * @returns The parsed slot value or undefined if not found
1149
- */
1150
- getSlot(slotId: string): unknown;
1151
- /**
1152
- * Get all slots as an object with slot IDs as keys
1153
- * @returns Object containing all slots, or empty object if not loaded
1154
- * @example
1155
- * const slots = dotLottie.getSlots();
1156
- */
1157
- getSlots(): Record<string, unknown>;
1158
- /**
1159
- * Set a color slot value
1160
- * @param slotId - The slot ID to set
1161
- * @param value - Static color [r, g, b, a] or array of keyframes
1162
- * @returns true if successful
1163
- * @example
1164
- * // Static red color
1165
- * dotLottie.setColorSlot('myColor', [1, 0, 0, 1]);
1166
- * // Animated color (red to blue)
1167
- * dotLottie.setColorSlot('myColor', [\{ t: 0, s: [1, 0, 0, 1] \}, \{ t: 60, s: [0, 0, 1, 1] \}]);
1168
- */
1169
- setColorSlot(slotId: string, value: ColorSlotValue): boolean;
1170
- /**
1171
- * Set a scalar slot value (single number like rotation, opacity)
1172
- * @param slotId - The slot ID to set
1173
- * @param value - Static number or array of keyframes
1174
- * @returns true if successful
1175
- * @example
1176
- * // Static rotation
1177
- * dotLottie.setScalarSlot('rotation', 45);
1178
- * // Animated rotation
1179
- * dotLottie.setScalarSlot('rotation', [\{ t: 0, s: 0 \}, \{ t: 60, s: 360 \}]);
1180
- */
1181
- setScalarSlot(slotId: string, value: ScalarSlotValue): boolean;
1182
- /**
1183
- * Set a vector slot value (2D or 3D point for position, scale, etc.)
1184
- * Handles both "vector" and "position" slot types
1185
- * @param slotId - The slot ID to set
1186
- * @param value - Static vector [x, y] or array of keyframes
1187
- * @returns true if successful
1188
- * @example
1189
- * // Static scale
1190
- * dotLottie.setVectorSlot('scale', [150, 150]);
1191
- * // Animated position
1192
- * dotLottie.setVectorSlot('position', [\{ t: 0, s: [0, 0] \}, \{ t: 60, s: [100, 200] \}]);
1193
- */
1194
- setVectorSlot(slotId: string, value: VectorSlotValue): boolean;
1195
- /**
1196
- * Set a gradient slot value
1197
- * @param slotId - The slot ID to set
1198
- * @param value - Static gradient [offset, r, g, b, ...] or array of keyframes
1199
- * @returns true if successful
1200
- * @example
1201
- * // Static red to blue gradient
1202
- * dotLottie.setGradientSlot('myGradient', [0, 1, 0, 0, 1, 0, 0, 1]);
1203
- * // Animated gradient
1204
- * dotLottie.setGradientSlot('myGradient', [\{ t: 0, s: [0, 1, 0, 0, 1, 0, 0, 1] \}]);
1205
- */
1206
- setGradientSlot(slotId: string, value: GradientSlotValue): boolean;
1207
- /**
1208
- * Set a text slot value (always static - text documents don't support animation)
1209
- * Supports partial updates - only provided properties will be changed, others inherit from existing value
1210
- * @param slotId - The slot ID to set
1211
- * @param value - Text document properties (partial allowed)
1212
- * @returns true if successful
1213
- * @example
1214
- * // Set all properties
1215
- * dotLottie.setTextSlot('title', \{ t: 'Hello World', s: 24, fc: [0, 0, 0, 1] \});
1216
- * // Partial update - only change text, keep existing font size, color, etc.
1217
- * dotLottie.setTextSlot('title', \{ t: 'New Text' \});
1218
- */
1219
- setTextSlot(slotId: string, value: TextSlotValue): boolean;
1220
- /**
1221
- * Reset a slot to its original value
1222
- * @param slotId - The slot ID to reset
1223
- * @returns true if successful
1224
- */
1225
- resetSlot(slotId: string): boolean;
1226
- /**
1227
- * Clear a slot's custom value
1228
- * @param slotId - The slot ID to clear
1229
- * @returns true if successful
1230
- */
1231
- clearSlot(slotId: string): boolean;
1232
- /**
1233
- * Reset all slots to their original values
1234
- * @returns true if successful
1235
- */
1236
- resetSlots(): boolean;
1237
- /**
1238
- * Clear all slot custom values
1239
- * @returns true if successful
1240
- */
1241
- clearSlots(): boolean;
1242
- /**
1243
- * Updates the layout configuration for positioning and scaling the animation.
1244
- * Changes how the animation fits and aligns within the canvas without requiring a reload.
1245
- * @param layout - New layout configuration with fit mode and alignment values
1246
- */
1247
- setLayout(layout: Layout): void;
1248
- /**
1249
- * Sets a custom viewport region for rendering a portion of the animation.
1250
- * Defines a rectangular area to render, useful for implementing animation clipping or panning effects.
1251
- * @param x - X coordinate of the viewport's top-left corner
1252
- * @param y - Y coordinate of the viewport's top-left corner
1253
- * @param width - Width of the viewport in pixels
1254
- * @param height - Height of the viewport in pixels
1255
- * @returns True if viewport was set successfully, false otherwise
1256
- */
1257
- setViewport(x: number, y: number, width: number, height: number): boolean;
1258
- /**
1259
- * Configures the URL for loading the WASM module.
1260
- * Call this before creating any player instances to load the WASM from a custom CDN or local path.
1261
- * @param url - URL pointing to the dotlottie WASM file
1262
- */
1263
- static setWasmUrl(url: string): void;
1264
- /**
1265
- * @experimental
1266
- * Register a custom font for use in animations
1267
- * @param fontName - The name of the font to register
1268
- * @param fontSource - Either a URL string to fetch the font, or ArrayBuffer/Uint8Array of font data
1269
- * @returns Promise<boolean> - true if registration succeeded, false otherwise
1270
- */
1271
- static registerFont(fontName: string, fontSource: string | ArrayBuffer | Uint8Array): Promise<boolean>;
1272
- /**
1273
- * @experimental
1274
- * Animates smoothly to a specific frame over a duration using linear easing.
1275
- * Creates a tween animation transitioning from the current frame to the target frame.
1276
- * @param frame - Target frame number to tween to
1277
- * @param duration - Duration of the tween animation in seconds
1278
- * @returns True if tween started successfully, false otherwise
1279
- */
1280
- tween(frame: number, duration: number): boolean;
1281
- /**
1282
- * @experimental
1283
- * Start a tween animation to a specific marker
1284
- * @param marker - The marker name to tween to
1285
- * @param duration - Duration of the tween animation in seconds
1286
- * @returns true if tween was started successfully
1287
- */
1288
- tweenToMarker(marker: string, duration: number): boolean;
1289
- /**
1290
- * Gets the original dimensions of the animation as defined in the source file.
1291
- * Returns width and height in pixels representing the animation's intrinsic size.
1292
- * @returns Object with width and height properties in pixels
1293
- */
1294
- animationSize(): {
1295
- height: number;
1296
- width: number;
1297
- };
1298
- /**
1299
- * Gets the Oriented Bounding Box (OBB) points of a layer by its name.
1300
- * Returns 8 numbers representing 4 corner points (x,y) in clockwise order from top-left: [x0, y0, x1, y1, x2, y2, x3, y3].
1301
- * @param layerName - Name of the layer to get bounds for
1302
- * @returns Array of 8 numbers representing the bounding box corners, or undefined if layer not found
1303
- */
1304
- getLayerBoundingBox(layerName: string): number[] | undefined;
1305
- /**
1306
- * Converts theme data into Lottie slot format for dynamic content replacement.
1307
- * Utility function for transforming theme definitions into slot-compatible data structures.
1308
- * @param theme - Theme data as a JSON string
1309
- * @param slots - Slot definitions as a JSON string
1310
- * @returns Transformed slots data as a JSON string
1311
- */
1312
- static transformThemeToLottieSlots(theme: string, slots: string): string;
1313
- private _setupStateMachineObservers;
1314
- private _cleanupStateMachineObservers;
1315
- /**
1316
- * @experimental
1317
- * Loads a state machine by its ID from the dotLottie manifest.
1318
- * State machines enable interactive, event-driven animation behaviors.
1319
- * @param stateMachineId - The ID of the state machine to load (must exist in manifest)
1320
- * @returns True if the state machine was loaded successfully, false otherwise
1321
- */
1322
- stateMachineLoad(stateMachineId: string): boolean;
1323
- /**
1324
- * @experimental
1325
- * Load a state machine from data string
1326
- * @param stateMachineData - The state machine data as a string
1327
- * @returns true if the state machine was loaded successfully
1328
- */
1329
- stateMachineLoadData(stateMachineData: string): boolean;
1330
- /**
1331
- * @experimental
1332
- * Set the state machine config
1333
- * @param config - The state machine config
1334
- */
1335
- stateMachineSetConfig(config: StateMachineConfig | null): void;
1336
- /**
1337
- * @experimental
1338
- * Start the state machine
1339
- * @returns true if the state machine was started successfully
1340
- */
1341
- stateMachineStart(): boolean;
1342
- /**
1343
- * @experimental
1344
- * Stop the state machine
1345
- * @returns true if the state machine was stopped successfully
1346
- */
1347
- stateMachineStop(): boolean;
1348
- /**
1349
- * @experimental
1350
- * Get the current status of the state machine
1351
- * @returns The current status of the state machine as a string
1352
- */
1353
- stateMachineGetStatus(): string;
1354
- /**
1355
- * @experimental
1356
- * Get the current state of the state machine
1357
- * @returns The current state of the state machine as a string
1358
- */
1359
- stateMachineGetCurrentState(): string;
1360
- /**
1361
- * @experimental
1362
- * Get the active state machine ID
1363
- * @returns The active state machine ID as a string
1364
- */
1365
- stateMachineGetActiveId(): string;
1366
- /**
1367
- * @experimental
1368
- * Override the current state of the state machine
1369
- * @param state - The state to override to
1370
- * @param immediate - Whether to immediately transition to the state
1371
- * @returns true if the state override was successful
1372
- */
1373
- stateMachineOverrideState(state: string, immediate?: boolean): boolean;
1374
- /**
1375
- * @experimental
1376
- * Get a specific state machine by ID
1377
- * @param stateMachineId - The ID of the state machine to get
1378
- * @returns The state machine data as a string
1379
- */
1380
- stateMachineGet(stateMachineId: string): string;
1381
- /**
1382
- * @experimental
1383
- * Get the list of state machine listeners
1384
- * @returns Array of listener names
1385
- */
1386
- stateMachineGetListeners(): string[];
1387
- /**
1388
- * @experimental
1389
- * Set a boolean input value for the state machine
1390
- * @param name - The name of the boolean input
1391
- * @param value - The boolean value to set
1392
- */
1393
- stateMachineSetBooleanInput(name: string, value: boolean): boolean;
1394
- /**
1395
- * @experimental
1396
- * Set a numeric input value for the state machine
1397
- * @param name - The name of the numeric input
1398
- * @param value - The numeric value to set
1399
- */
1400
- stateMachineSetNumericInput(name: string, value: number): boolean;
1401
- /**
1402
- * @experimental
1403
- * Set a string input value for the state machine
1404
- * @param name - The name of the string input
1405
- * @param value - The string value to set
1406
- */
1407
- stateMachineSetStringInput(name: string, value: string): boolean;
1408
- /**
1409
- * @experimental
1410
- * Get a boolean input value from the state machine
1411
- * @param name - The name of the boolean input
1412
- * @returns The boolean value or undefined if not found
1413
- */
1414
- stateMachineGetBooleanInput(name: string): boolean | undefined;
1415
- /**
1416
- * @experimental
1417
- * Get a numeric input value from the state machine
1418
- * @param name - The name of the numeric input
1419
- * @returns The numeric value or undefined if not found
1420
- */
1421
- stateMachineGetNumericInput(name: string): number | undefined;
1422
- /**
1423
- * @experimental
1424
- * Get a string input value from the state machine
1425
- * @param name - The name of the string input
1426
- * @returns The string value or undefined if not found
1427
- */
1428
- stateMachineGetStringInput(name: string): string | undefined;
1429
- /**
1430
- * @experimental
1431
- * Get all the inputs of the current state machine. Returns the key name, followed by it's type as a string.
1432
- * @returns An array of input keys followed by it's type at n+1.
1433
- */
1434
- stateMachineGetInputs(): string[];
1435
- /**
1436
- * @experimental
1437
- * Fire an event in the state machine
1438
- * @param name - The name of the event to fire
1439
- */
1440
- stateMachineFireEvent(name: string): void;
1441
- /**
1442
- * @experimental
1443
- * Post a click event to the state machine
1444
- * @param x - The x coordinate of the click
1445
- * @param y - The y coordinate of the click
1446
- * @returns The event result or undefined
1447
- */
1448
- stateMachinePostClickEvent(x: number, y: number): void;
1449
- /**
1450
- * @experimental
1451
- * Post a pointer up event to the state machine
1452
- * @param x - The x coordinate of the pointer
1453
- * @param y - The y coordinate of the pointer
1454
- * @returns The event result or undefined
1455
- */
1456
- stateMachinePostPointerUpEvent(x: number, y: number): void;
1457
- /**
1458
- * @experimental
1459
- * Post a pointer down event to the state machine
1460
- * @param x - The x coordinate of the pointer
1461
- * @param y - The y coordinate of the pointer
1462
- * @returns The event result or undefined
1463
- */
1464
- stateMachinePostPointerDownEvent(x: number, y: number): void;
1465
- /**
1466
- * @experimental
1467
- * Post a pointer move event to the state machine
1468
- * @param x - The x coordinate of the pointer
1469
- * @param y - The y coordinate of the pointer
1470
- * @returns The event result or undefined
1471
- */
1472
- stateMachinePostPointerMoveEvent(x: number, y: number): void;
1473
- /**
1474
- * @experimental
1475
- * Post a pointer enter event to the state machine
1476
- * @param x - The x coordinate of the pointer
1477
- * @param y - The y coordinate of the pointer
1478
- * @returns The event result or undefined
1479
- */
1480
- stateMachinePostPointerEnterEvent(x: number, y: number): void;
1481
- /**
1482
- * @experimental
1483
- * Post a pointer exit event to the state machine
1484
- * @param x - The x coordinate of the pointer
1485
- * @param y - The y coordinate of the pointer
1486
- * @returns The event result or undefined
1487
- */
1488
- stateMachinePostPointerExitEvent(x: number, y: number): void;
1489
- private _onClick;
1490
- private _onPointerUp;
1491
- private _onPointerDown;
1492
- private _onPointerMove;
1493
- private _onPointerEnter;
1494
- private _onPointerLeave;
1495
- private _setupStateMachineListeners;
1496
- private _cleanupStateMachineListeners;
751
+ private _canvas;
752
+ private _pendingLoad;
753
+ private _context;
754
+ private readonly _eventManager;
755
+ private _animationFrameId;
756
+ private readonly _frameManager;
757
+ private _dotLottieCore;
758
+ private _stateMachineId;
759
+ private _stateMachineConfig;
760
+ private _isStateMachineRunning;
761
+ private _stateMachineObserverHandle;
762
+ private _stateMachineInternalMessageObserver;
763
+ private _dotLottieObserverHandle;
764
+ private static _wasmModule;
765
+ private _renderConfig;
766
+ private _isFrozen;
767
+ private _backgroundColor;
768
+ private _boundOnClick;
769
+ private _boundOnPointerUp;
770
+ private _boundOnPointerDown;
771
+ private _boundOnPointerMove;
772
+ private _boundOnPointerEnter;
773
+ private _boundOnPointerLeave;
774
+ private _bufferMismatchCount;
775
+ private _lastExpectedBufferSize;
776
+ /**
777
+ * Creates a new DotLottie player instance for rendering Lottie animations.
778
+ * Initializes the WASM module, event system, and loads animation if src or data is provided in config.
779
+ * @param config - Configuration object specifying animation source, playback settings, and rendering options
780
+ */
781
+ constructor(config: Config);
782
+ private _dispatchError;
783
+ private _fetchData;
784
+ private _loadFromData;
785
+ private _loadFromSrc;
786
+ /**
787
+ * Gets the raw pixel buffer containing the rendered animation frame.
788
+ * Returns RGBA pixel data as a Uint8Array for advanced image processing or custom rendering.
789
+ */
790
+ get buffer(): Uint8Array | null;
791
+ /**
792
+ * Gets the ID of the currently active animation from a multi-animation dotLottie file.
793
+ * Returns undefined if no specific animation is active or for single-animation files.
794
+ */
795
+ get activeAnimationId(): string | undefined;
796
+ /**
797
+ * Gets the ID of the currently active theme applied to the animation.
798
+ * Returns undefined if no theme is active. Themes modify colors and visual properties.
799
+ */
800
+ get activeThemeId(): string | undefined;
801
+ /**
802
+ * Gets the current layout configuration for positioning and scaling the animation.
803
+ * Includes fit mode (contain, cover, fill, etc.) and alignment [x, y] values (0-1 range).
804
+ */
805
+ get layout(): Layout | undefined;
806
+ /**
807
+ * Gets the currently active marker name if a marker-based segment is set.
808
+ * Returns undefined if no marker is active. Use setMarker() to activate a named segment.
809
+ */
810
+ get marker(): string | undefined;
811
+ /**
812
+ * Gets the animation manifest containing metadata about animations, themes, and states.
813
+ * Returns null if no manifest is available or if the loaded animation doesn't include one.
814
+ */
815
+ get manifest(): Manifest | null;
816
+ /**
817
+ * Gets the current rendering configuration.
818
+ * Includes settings like devicePixelRatio, autoResize, and freezeOnOffscreen.
819
+ */
820
+ get renderConfig(): RenderConfig;
821
+ /**
822
+ * Gets the currently active playback segment as [startFrame, endFrame].
823
+ * If no segment is set, returns undefined and the full animation plays.
824
+ */
825
+ get segment(): [number, number] | undefined;
826
+ /**
827
+ * Gets the current loop configuration.
828
+ * Returns true if the animation is set to loop continuously.
829
+ */
830
+ get loop(): boolean;
831
+ /**
832
+ * Gets the current playback mode.
833
+ * Determines playback direction: 'forward', 'reverse', 'bounce' (forward then reverse), or 'reverse-bounce'.
834
+ */
835
+ get mode(): Mode;
836
+ /**
837
+ * Indicates whether rendering is currently frozen.
838
+ * True when freeze() has been called and the rendering loop is paused to save resources.
839
+ */
840
+ get isFrozen(): boolean;
841
+ /**
842
+ * Indicates whether a state machine is currently active and running.
843
+ * True after stateMachineStart() is called and until stateMachineStop() is called.
844
+ */
845
+ get isStateMachineRunning(): boolean;
846
+ /**
847
+ * Gets the current background color.
848
+ * Returns the background color as a string (e.g., '#FFFFFF' or 'transparent').
849
+ */
850
+ get backgroundColor(): string;
851
+ /**
852
+ * Gets the autoplay configuration.
853
+ * Returns true if the animation is configured to start playing automatically when loaded.
854
+ */
855
+ get autoplay(): boolean;
856
+ /**
857
+ * Gets the frame interpolation setting.
858
+ * Returns true if frame interpolation is enabled for smoother animation playback.
859
+ */
860
+ get useFrameInterpolation(): boolean;
861
+ /**
862
+ * Gets the current playback speed.
863
+ * Returns the speed multiplier (1 = normal speed, 2 = double speed, 0.5 = half speed).
864
+ */
865
+ get speed(): number;
866
+ /**
867
+ * Indicates whether the WASM module and core player have been initialized.
868
+ * Check this before performing operations that require the player to be ready.
869
+ */
870
+ get isReady(): boolean;
871
+ /**
872
+ * Indicates whether an animation has been successfully loaded and is ready for playback.
873
+ * Check this before calling play() or other playback methods to ensure the animation is ready.
874
+ */
875
+ get isLoaded(): boolean;
876
+ /**
877
+ * Indicates whether the animation is currently playing.
878
+ * True when animation is actively playing, false when paused, stopped, or not started.
879
+ */
880
+ get isPlaying(): boolean;
881
+ /**
882
+ * Indicates whether the animation is currently paused.
883
+ * True when pause() has been called and animation is not playing or stopped.
884
+ */
885
+ get isPaused(): boolean;
886
+ /**
887
+ * Indicates whether the animation is currently stopped.
888
+ * True when stop() has been called or animation hasn't started yet.
889
+ */
890
+ get isStopped(): boolean;
891
+ /**
892
+ * Gets the current frame number of the animation.
893
+ * Useful for tracking playback position or implementing custom frame displays. Rounded to 2 decimal places.
894
+ */
895
+ get currentFrame(): number;
896
+ /**
897
+ * Gets the number of times the animation has completed a loop during the current playback.
898
+ * Increments each time the animation completes one full cycle.
899
+ */
900
+ get loopCount(): number;
901
+ /**
902
+ * Gets the total number of frames in the animation.
903
+ * Use with currentFrame to calculate playback progress as a percentage.
904
+ */
905
+ get totalFrames(): number;
906
+ /**
907
+ * Gets the total duration of the animation in seconds.
908
+ * Represents the time to play from the first frame to the last at normal speed (speed = 1).
909
+ */
910
+ get duration(): number;
911
+ /**
912
+ * Gets the duration of the currently active segment in seconds.
913
+ * If no segment is set, returns the full animation duration.
914
+ */
915
+ get segmentDuration(): number;
916
+ /**
917
+ * Gets the canvas element used for rendering the animation.
918
+ * Returns the HTMLCanvasElement, OffscreenCanvas, or RenderSurface set during initialization.
919
+ */
920
+ get canvas(): HTMLCanvasElement | OffscreenCanvas | RenderSurface | null;
921
+ /**
922
+ * Dynamically loads a new animation, replacing the current one if any.
923
+ * Stops current playback, cleans up resources, and loads from the provided src or data.
924
+ * @param config - Configuration for the new animation (all Config properties except canvas)
925
+ */
926
+ load(config: Omit<Config, 'canvas'>): void;
927
+ private _draw;
928
+ private _cleanupCanvas;
929
+ private _initializeCanvas;
930
+ private _stopAnimationLoop;
931
+ private _startAnimationLoop;
932
+ private _animationLoop;
933
+ /**
934
+ * Starts or resumes animation playback from the current frame.
935
+ * Unfreezes rendering if frozen and starts the animation loop. Updates isPlaying state to true.
936
+ */
937
+ play(): void;
938
+ /**
939
+ * Pauses animation playback at the current frame.
940
+ * Stops the animation loop while preserving the current frame position. Updates isPaused state to true.
941
+ */
942
+ pause(): void;
943
+ /**
944
+ * Stops animation playback and resets to the start frame.
945
+ * Halts the animation loop and returns to the beginning. Updates isStopped state to true.
946
+ */
947
+ stop(): void;
948
+ /**
949
+ * Seeks to a specific frame in the animation and renders it.
950
+ * Useful for implementing custom scrubbing controls or precise frame positioning.
951
+ * @param frame - The target frame number to seek to
952
+ */
953
+ setFrame(frame: number): void;
954
+ /**
955
+ * Changes the animation playback speed.
956
+ * Values above 1 speed up playback, below 1 slow it down.
957
+ * @param speed - Playback speed multiplier (e.g., 2 for 2x speed, 0.5 for half speed)
958
+ */
959
+ setSpeed(speed: number): void;
960
+ /**
961
+ * Changes the background color of the canvas or animation.
962
+ * For HTMLCanvasElement, sets the CSS background. For other surfaces, renders behind the animation.
963
+ * @param color - CSS color string (e.g., '#FFFFFF', 'rgba(0,0,0,0.5)', 'transparent')
964
+ */
965
+ setBackgroundColor(color: string): void;
966
+ /**
967
+ * Enables or disables continuous looping of the animation.
968
+ * When enabled with loopCount set to 0, animation repeats indefinitely.
969
+ * @param loop - True to enable looping, false to play once
970
+ */
971
+ setLoop(loop: boolean): void;
972
+ /**
973
+ * Sets the number of additional times to replay the animation after the first play.
974
+ * Requires loop to be true. A value of 0 means infinite replays; a positive value n means
975
+ * the animation plays a total of n + 1 times (initial play + n replays).
976
+ * @param loopCount - Number of additional replays (0 = infinite, 1 = plays twice, 2 = plays three times, etc.)
977
+ */
978
+ setLoopCount(loopCount: number): void;
979
+ /**
980
+ * Enables or disables frame interpolation for smoother playback.
981
+ * When enabled, interpolates between frames. When disabled, shows exact frame-by-frame animation.
982
+ * @param useFrameInterpolation - True for smooth interpolation, false for exact frames
983
+ */
984
+ setUseFrameInterpolation(useFrameInterpolation: boolean): void;
985
+ /**
986
+ * Subscribes to animation events like play, pause, frame, complete, etc.
987
+ * Use this to react to animation state changes and playback progress.
988
+ * @param type - Event type to listen for (e.g., 'play', 'frame', 'complete')
989
+ * @param listener - Callback function invoked when the event occurs
990
+ */
991
+ addEventListener<T extends EventType>(type: T, listener: EventListener<T>): void;
992
+ /**
993
+ * Unsubscribes from animation events.
994
+ * If no listener is provided, removes all listeners for the given event type.
995
+ * @param type - Event type to stop listening for
996
+ * @param listener - Specific callback to remove, or undefined to remove all
997
+ */
998
+ removeEventListener<T extends EventType>(type: T, listener?: EventListener<T>): void;
999
+ /**
1000
+ * Cleans up and destroys the player instance, releasing all resources.
1001
+ * Stops playback, removes event listeners, and frees WASM memory. Call when the player is no longer needed.
1002
+ */
1003
+ destroy(): void;
1004
+ /**
1005
+ * Pauses the rendering loop without changing playback state.
1006
+ * Useful for reducing CPU/GPU usage when the animation is offscreen or hidden. Dispatches 'freeze' event.
1007
+ */
1008
+ freeze(): void;
1009
+ /**
1010
+ * Resumes the rendering loop after being frozen.
1011
+ * Restarts frame rendering while maintaining the current playback state. Dispatches 'unfreeze' event.
1012
+ */
1013
+ unfreeze(): void;
1014
+ /**
1015
+ * Recalculates and updates canvas dimensions based on current size.
1016
+ * Call this when the canvas container size changes to maintain proper rendering. Usually handled by autoResize.
1017
+ */
1018
+ resize(): void;
1019
+ /**
1020
+ * Changes the canvas element used for rendering.
1021
+ * Useful for moving the animation to a different canvas without recreating the player instance.
1022
+ * @param canvas - New HTMLCanvasElement, OffscreenCanvas, or RenderSurface to render to
1023
+ */
1024
+ setCanvas(canvas: HTMLCanvasElement | OffscreenCanvas | RenderSurface): void;
1025
+ /**
1026
+ * Applies a 3x3 transformation matrix to the entire animation on the canvas.
1027
+ * Use this to translate, rotate, scale, or skew the animation rendering.
1028
+ * @param transform - 9-element array representing the transformation matrix in row-major order
1029
+ * @returns True if transformation was applied successfully, false otherwise
1030
+ */
1031
+ setTransform(transform: Transform): boolean;
1032
+ /**
1033
+ * Gets the 3x3 transformation matrix applied to the animation.
1034
+ * Returns a 9-element array representing affine transformations (translation, rotation, scale, skew).
1035
+ * @returns Transform array of 9 numbers, or undefined if not available
1036
+ */
1037
+ getTransform(): Transform | undefined;
1038
+ /**
1039
+ * Sets a frame range to play instead of the full animation.
1040
+ * Useful for playing specific sections or creating animation sequences from subsections.
1041
+ * @param startFrame - Starting frame number (inclusive)
1042
+ * @param endFrame - Ending frame number (inclusive)
1043
+ */
1044
+ setSegment(startFrame: number, endFrame: number): void;
1045
+ /**
1046
+ * Changes the playback direction mode.
1047
+ * Controls whether animation plays forward, in reverse, or alternates (bounce).
1048
+ * @param mode - Playback mode: 'forward', 'reverse', 'bounce', or 'reverse-bounce'
1049
+ */
1050
+ setMode(mode: Mode): void;
1051
+ /**
1052
+ * Updates rendering configuration like autoResize, devicePixelRatio, and freezeOnOffscreen.
1053
+ * Dynamically changes how the canvas behaves without reloading the animation.
1054
+ * @param config - Partial RenderConfig with properties to update
1055
+ */
1056
+ setRenderConfig(config: RenderConfig): void;
1057
+ /**
1058
+ * Switches to a different animation within a multi-animation dotLottie file.
1059
+ * Use this to load a different animation by its ID without creating a new player instance.
1060
+ * @param animationId - ID of the animation to load (must exist in the manifest)
1061
+ */
1062
+ loadAnimation(animationId: string): void;
1063
+ /**
1064
+ * Activates a named marker to play only that marked segment.
1065
+ * Markers define named sections within an animation. Use markers() to list available markers.
1066
+ * @param marker - Name of the marker to activate
1067
+ */
1068
+ setMarker(marker: string): void;
1069
+ /**
1070
+ * Gets all markers defined in the animation with their time and duration.
1071
+ * Markers represent named sections that can be played using setMarker().
1072
+ * @returns Array of marker objects with name, time, and duration properties
1073
+ */
1074
+ markers(): Marker[];
1075
+ /**
1076
+ * Applies a theme to the animation, modifying colors and visual properties.
1077
+ * Themes are predefined in the dotLottie manifest. Returns true if theme was successfully loaded.
1078
+ * @param themeId - ID of the theme to apply (must exist in manifest)
1079
+ * @returns True if theme loaded successfully, false otherwise
1080
+ */
1081
+ setTheme(themeId: string): boolean;
1082
+ /**
1083
+ * Removes the currently applied theme and restores original animation colors.
1084
+ * Use this to revert to the default appearance after applying a theme.
1085
+ * @returns True if theme was reset successfully, false otherwise
1086
+ */
1087
+ resetTheme(): boolean;
1088
+ /**
1089
+ * Applies a custom theme from theme data instead of manifest theme ID.
1090
+ * Useful for dynamically generated or user-created themes not in the manifest.
1091
+ *
1092
+ * @param themeData - Theme data as a JSON string or a structured Theme object
1093
+ * @returns True if theme loaded successfully, false otherwise
1094
+ *
1095
+ * @example
1096
+ * ```typescript
1097
+ * // Using a string (existing behavior)
1098
+ * dotLottie.setThemeData('{"rules":[{"id":"bg","type":"Color","value":[1,0,0]}]}');
1099
+ *
1100
+ * // Using a Theme object (new behavior)
1101
+ * dotLottie.setThemeData({
1102
+ * rules: [
1103
+ * {
1104
+ * id: 'background_color',
1105
+ * type: 'Color',
1106
+ * value: [0.2, 0.4, 0.8]
1107
+ * },
1108
+ * {
1109
+ * id: 'title',
1110
+ * type: 'Text',
1111
+ * value: {
1112
+ * text: 'Hello World',
1113
+ * fontSize: 48,
1114
+ * fillColor: [1, 1, 1]
1115
+ * }
1116
+ * }
1117
+ * ]
1118
+ * });
1119
+ * ```
1120
+ */
1121
+ setThemeData(themeData: Theme | string): boolean;
1122
+ /**
1123
+ * Sets multiple slot values at once for parameterized animations.
1124
+ * Slots allow runtime customization of colors, text, images, or other properties.
1125
+ * @param slots - Object mapping slot IDs to their values
1126
+ */
1127
+ setSlots(slots: Record<string, unknown>): void;
1128
+ /**
1129
+ * Check if value is an array of keyframes (has objects with 't' and 's' properties)
1130
+ */
1131
+ private _isKeyframeArray;
1132
+ /**
1133
+ * Get all slot IDs in the animation
1134
+ * @returns Array of slot ID strings
1135
+ */
1136
+ getSlotIds(): string[];
1137
+ /**
1138
+ * Get the type of a slot
1139
+ * @param slotId - The slot ID to query
1140
+ * @returns The slot type ('color', 'gradient', 'text', 'scalar', 'vector', 'position', 'image') or undefined
1141
+ */
1142
+ getSlotType(slotId: string): SlotType | undefined;
1143
+ /**
1144
+ * Get the current value of a slot
1145
+ * @param slotId - The slot ID to query
1146
+ * @returns The parsed slot value or undefined if not found
1147
+ */
1148
+ getSlot(slotId: string): unknown;
1149
+ /**
1150
+ * Get all slots as an object with slot IDs as keys
1151
+ * @returns Object containing all slots, or empty object if not loaded
1152
+ * @example
1153
+ * const slots = dotLottie.getSlots();
1154
+ */
1155
+ getSlots(): Record<string, unknown>;
1156
+ /**
1157
+ * Set a color slot value
1158
+ * @param slotId - The slot ID to set
1159
+ * @param value - Static color [r, g, b, a] or array of keyframes
1160
+ * @returns true if successful
1161
+ * @example
1162
+ * // Static red color
1163
+ * dotLottie.setColorSlot('myColor', [1, 0, 0, 1]);
1164
+ * // Animated color (red to blue)
1165
+ * dotLottie.setColorSlot('myColor', [\{ t: 0, s: [1, 0, 0, 1] \}, \{ t: 60, s: [0, 0, 1, 1] \}]);
1166
+ */
1167
+ setColorSlot(slotId: string, value: ColorSlotValue): boolean;
1168
+ /**
1169
+ * Set a scalar slot value (single number like rotation, opacity)
1170
+ * @param slotId - The slot ID to set
1171
+ * @param value - Static number or array of keyframes
1172
+ * @returns true if successful
1173
+ * @example
1174
+ * // Static rotation
1175
+ * dotLottie.setScalarSlot('rotation', 45);
1176
+ * // Animated rotation
1177
+ * dotLottie.setScalarSlot('rotation', [\{ t: 0, s: 0 \}, \{ t: 60, s: 360 \}]);
1178
+ */
1179
+ setScalarSlot(slotId: string, value: ScalarSlotValue): boolean;
1180
+ /**
1181
+ * Set a vector slot value (2D or 3D point for position, scale, etc.)
1182
+ * Handles both "vector" and "position" slot types
1183
+ * @param slotId - The slot ID to set
1184
+ * @param value - Static vector [x, y] or array of keyframes
1185
+ * @returns true if successful
1186
+ * @example
1187
+ * // Static scale
1188
+ * dotLottie.setVectorSlot('scale', [150, 150]);
1189
+ * // Animated position
1190
+ * dotLottie.setVectorSlot('position', [\{ t: 0, s: [0, 0] \}, \{ t: 60, s: [100, 200] \}]);
1191
+ */
1192
+ setVectorSlot(slotId: string, value: VectorSlotValue): boolean;
1193
+ /**
1194
+ * Set a gradient slot value
1195
+ * @param slotId - The slot ID to set
1196
+ * @param value - Static gradient [offset, r, g, b, ...] or array of keyframes
1197
+ * @returns true if successful
1198
+ * @example
1199
+ * // Static red to blue gradient
1200
+ * dotLottie.setGradientSlot('myGradient', [0, 1, 0, 0, 1, 0, 0, 1]);
1201
+ * // Animated gradient
1202
+ * dotLottie.setGradientSlot('myGradient', [\{ t: 0, s: [0, 1, 0, 0, 1, 0, 0, 1] \}]);
1203
+ */
1204
+ setGradientSlot(slotId: string, value: GradientSlotValue): boolean;
1205
+ /**
1206
+ * Set a text slot value (always static - text documents don't support animation)
1207
+ * Supports partial updates - only provided properties will be changed, others inherit from existing value
1208
+ * @param slotId - The slot ID to set
1209
+ * @param value - Text document properties (partial allowed)
1210
+ * @returns true if successful
1211
+ * @example
1212
+ * // Set all properties
1213
+ * dotLottie.setTextSlot('title', \{ t: 'Hello World', s: 24, fc: [0, 0, 0, 1] \});
1214
+ * // Partial update - only change text, keep existing font size, color, etc.
1215
+ * dotLottie.setTextSlot('title', \{ t: 'New Text' \});
1216
+ */
1217
+ setTextSlot(slotId: string, value: TextSlotValue): boolean;
1218
+ /**
1219
+ * Reset a slot to its original value
1220
+ * @param slotId - The slot ID to reset
1221
+ * @returns true if successful
1222
+ */
1223
+ resetSlot(slotId: string): boolean;
1224
+ /**
1225
+ * Clear a slot's custom value
1226
+ * @param slotId - The slot ID to clear
1227
+ * @returns true if successful
1228
+ */
1229
+ clearSlot(slotId: string): boolean;
1230
+ /**
1231
+ * Reset all slots to their original values
1232
+ * @returns true if successful
1233
+ */
1234
+ resetSlots(): boolean;
1235
+ /**
1236
+ * Clear all slot custom values
1237
+ * @returns true if successful
1238
+ */
1239
+ clearSlots(): boolean;
1240
+ /**
1241
+ * Updates the layout configuration for positioning and scaling the animation.
1242
+ * Changes how the animation fits and aligns within the canvas without requiring a reload.
1243
+ * @param layout - New layout configuration with fit mode and alignment values
1244
+ */
1245
+ setLayout(layout: Layout): void;
1246
+ /**
1247
+ * Sets a custom viewport region for rendering a portion of the animation.
1248
+ * Defines a rectangular area to render, useful for implementing animation clipping or panning effects.
1249
+ * @param x - X coordinate of the viewport's top-left corner
1250
+ * @param y - Y coordinate of the viewport's top-left corner
1251
+ * @param width - Width of the viewport in pixels
1252
+ * @param height - Height of the viewport in pixels
1253
+ * @returns True if viewport was set successfully, false otherwise
1254
+ */
1255
+ setViewport(x: number, y: number, width: number, height: number): boolean;
1256
+ /**
1257
+ * Configures the URL for loading the WASM module.
1258
+ * Call this before creating any player instances to load the WASM from a custom CDN or local path.
1259
+ * @param url - URL pointing to the dotlottie WASM file
1260
+ */
1261
+ static setWasmUrl(url: string): void;
1262
+ /**
1263
+ * @experimental
1264
+ * Register a custom font for use in animations
1265
+ * @param fontName - The name of the font to register
1266
+ * @param fontSource - Either a URL string to fetch the font, or ArrayBuffer/Uint8Array of font data
1267
+ * @returns Promise<boolean> - true if registration succeeded, false otherwise
1268
+ */
1269
+ static registerFont(fontName: string, fontSource: string | ArrayBuffer | Uint8Array): Promise<boolean>;
1270
+ /**
1271
+ * @experimental
1272
+ * Animates smoothly to a specific frame over a duration using linear easing.
1273
+ * Creates a tween animation transitioning from the current frame to the target frame.
1274
+ * @param frame - Target frame number to tween to
1275
+ * @param duration - Duration of the tween animation in seconds
1276
+ * @returns True if tween started successfully, false otherwise
1277
+ */
1278
+ tween(frame: number, duration: number): boolean;
1279
+ /**
1280
+ * @experimental
1281
+ * Start a tween animation to a specific marker
1282
+ * @param marker - The marker name to tween to
1283
+ * @param duration - Duration of the tween animation in seconds
1284
+ * @returns true if tween was started successfully
1285
+ */
1286
+ tweenToMarker(marker: string, duration: number): boolean;
1287
+ /**
1288
+ * Gets the original dimensions of the animation as defined in the source file.
1289
+ * Returns width and height in pixels representing the animation's intrinsic size.
1290
+ * @returns Object with width and height properties in pixels
1291
+ */
1292
+ animationSize(): {
1293
+ height: number;
1294
+ width: number;
1295
+ };
1296
+ /**
1297
+ * Gets the Oriented Bounding Box (OBB) points of a layer by its name.
1298
+ * Returns 8 numbers representing 4 corner points (x,y) in clockwise order from top-left: [x0, y0, x1, y1, x2, y2, x3, y3].
1299
+ * @param layerName - Name of the layer to get bounds for
1300
+ * @returns Array of 8 numbers representing the bounding box corners, or undefined if layer not found
1301
+ */
1302
+ getLayerBoundingBox(layerName: string): number[] | undefined;
1303
+ /**
1304
+ * Converts theme data into Lottie slot format for dynamic content replacement.
1305
+ * Utility function for transforming theme definitions into slot-compatible data structures.
1306
+ * @param theme - Theme data as a JSON string
1307
+ * @param slots - Slot definitions as a JSON string
1308
+ * @returns Transformed slots data as a JSON string
1309
+ */
1310
+ static transformThemeToLottieSlots(theme: string, slots: string): string;
1311
+ private _setupStateMachineObservers;
1312
+ private _cleanupStateMachineObservers;
1313
+ /**
1314
+ * @experimental
1315
+ * Loads a state machine by its ID from the dotLottie manifest.
1316
+ * State machines enable interactive, event-driven animation behaviors.
1317
+ * @param stateMachineId - The ID of the state machine to load (must exist in manifest)
1318
+ * @returns True if the state machine was loaded successfully, false otherwise
1319
+ */
1320
+ stateMachineLoad(stateMachineId: string): boolean;
1321
+ /**
1322
+ * @experimental
1323
+ * Load a state machine from data string
1324
+ * @param stateMachineData - The state machine data as a string
1325
+ * @returns true if the state machine was loaded successfully
1326
+ */
1327
+ stateMachineLoadData(stateMachineData: string): boolean;
1328
+ /**
1329
+ * @experimental
1330
+ * Set the state machine config
1331
+ * @param config - The state machine config
1332
+ */
1333
+ stateMachineSetConfig(config: StateMachineConfig | null): void;
1334
+ /**
1335
+ * @experimental
1336
+ * Start the state machine
1337
+ * @returns true if the state machine was started successfully
1338
+ */
1339
+ stateMachineStart(): boolean;
1340
+ /**
1341
+ * @experimental
1342
+ * Stop the state machine
1343
+ * @returns true if the state machine was stopped successfully
1344
+ */
1345
+ stateMachineStop(): boolean;
1346
+ /**
1347
+ * @experimental
1348
+ * Get the current status of the state machine
1349
+ * @returns The current status of the state machine as a string
1350
+ */
1351
+ stateMachineGetStatus(): string;
1352
+ /**
1353
+ * @experimental
1354
+ * Get the current state of the state machine
1355
+ * @returns The current state of the state machine as a string
1356
+ */
1357
+ stateMachineGetCurrentState(): string;
1358
+ /**
1359
+ * @experimental
1360
+ * Get the active state machine ID
1361
+ * @returns The active state machine ID as a string
1362
+ */
1363
+ stateMachineGetActiveId(): string;
1364
+ /**
1365
+ * @experimental
1366
+ * Override the current state of the state machine
1367
+ * @param state - The state to override to
1368
+ * @param immediate - Whether to immediately transition to the state
1369
+ * @returns true if the state override was successful
1370
+ */
1371
+ stateMachineOverrideState(state: string, immediate?: boolean): boolean;
1372
+ /**
1373
+ * @experimental
1374
+ * Get a specific state machine by ID
1375
+ * @param stateMachineId - The ID of the state machine to get
1376
+ * @returns The state machine data as a string
1377
+ */
1378
+ stateMachineGet(stateMachineId: string): string;
1379
+ /**
1380
+ * @experimental
1381
+ * Get the list of state machine listeners
1382
+ * @returns Array of listener names
1383
+ */
1384
+ stateMachineGetListeners(): string[];
1385
+ /**
1386
+ * @experimental
1387
+ * Set a boolean input value for the state machine
1388
+ * @param name - The name of the boolean input
1389
+ * @param value - The boolean value to set
1390
+ */
1391
+ stateMachineSetBooleanInput(name: string, value: boolean): boolean;
1392
+ /**
1393
+ * @experimental
1394
+ * Set a numeric input value for the state machine
1395
+ * @param name - The name of the numeric input
1396
+ * @param value - The numeric value to set
1397
+ */
1398
+ stateMachineSetNumericInput(name: string, value: number): boolean;
1399
+ /**
1400
+ * @experimental
1401
+ * Set a string input value for the state machine
1402
+ * @param name - The name of the string input
1403
+ * @param value - The string value to set
1404
+ */
1405
+ stateMachineSetStringInput(name: string, value: string): boolean;
1406
+ /**
1407
+ * @experimental
1408
+ * Get a boolean input value from the state machine
1409
+ * @param name - The name of the boolean input
1410
+ * @returns The boolean value or undefined if not found
1411
+ */
1412
+ stateMachineGetBooleanInput(name: string): boolean | undefined;
1413
+ /**
1414
+ * @experimental
1415
+ * Get a numeric input value from the state machine
1416
+ * @param name - The name of the numeric input
1417
+ * @returns The numeric value or undefined if not found
1418
+ */
1419
+ stateMachineGetNumericInput(name: string): number | undefined;
1420
+ /**
1421
+ * @experimental
1422
+ * Get a string input value from the state machine
1423
+ * @param name - The name of the string input
1424
+ * @returns The string value or undefined if not found
1425
+ */
1426
+ stateMachineGetStringInput(name: string): string | undefined;
1427
+ /**
1428
+ * @experimental
1429
+ * Get all the inputs of the current state machine. Returns the key name, followed by it's type as a string.
1430
+ * @returns An array of input keys followed by it's type at n+1.
1431
+ */
1432
+ stateMachineGetInputs(): string[];
1433
+ /**
1434
+ * @experimental
1435
+ * Fire an event in the state machine
1436
+ * @param name - The name of the event to fire
1437
+ */
1438
+ stateMachineFireEvent(name: string): void;
1439
+ /**
1440
+ * @experimental
1441
+ * Post a click event to the state machine
1442
+ * @param x - The x coordinate of the click
1443
+ * @param y - The y coordinate of the click
1444
+ * @returns The event result or undefined
1445
+ */
1446
+ stateMachinePostClickEvent(x: number, y: number): void;
1447
+ /**
1448
+ * @experimental
1449
+ * Post a pointer up event to the state machine
1450
+ * @param x - The x coordinate of the pointer
1451
+ * @param y - The y coordinate of the pointer
1452
+ * @returns The event result or undefined
1453
+ */
1454
+ stateMachinePostPointerUpEvent(x: number, y: number): void;
1455
+ /**
1456
+ * @experimental
1457
+ * Post a pointer down event to the state machine
1458
+ * @param x - The x coordinate of the pointer
1459
+ * @param y - The y coordinate of the pointer
1460
+ * @returns The event result or undefined
1461
+ */
1462
+ stateMachinePostPointerDownEvent(x: number, y: number): void;
1463
+ /**
1464
+ * @experimental
1465
+ * Post a pointer move event to the state machine
1466
+ * @param x - The x coordinate of the pointer
1467
+ * @param y - The y coordinate of the pointer
1468
+ * @returns The event result or undefined
1469
+ */
1470
+ stateMachinePostPointerMoveEvent(x: number, y: number): void;
1471
+ /**
1472
+ * @experimental
1473
+ * Post a pointer enter event to the state machine
1474
+ * @param x - The x coordinate of the pointer
1475
+ * @param y - The y coordinate of the pointer
1476
+ * @returns The event result or undefined
1477
+ */
1478
+ stateMachinePostPointerEnterEvent(x: number, y: number): void;
1479
+ /**
1480
+ * @experimental
1481
+ * Post a pointer exit event to the state machine
1482
+ * @param x - The x coordinate of the pointer
1483
+ * @param y - The y coordinate of the pointer
1484
+ * @returns The event result or undefined
1485
+ */
1486
+ stateMachinePostPointerExitEvent(x: number, y: number): void;
1487
+ private _onClick;
1488
+ private _onPointerUp;
1489
+ private _onPointerDown;
1490
+ private _onPointerMove;
1491
+ private _onPointerEnter;
1492
+ private _onPointerLeave;
1493
+ private _setupStateMachineListeners;
1494
+ private _cleanupStateMachineListeners;
1497
1495
  }
1498
-
1496
+ //#endregion
1497
+ //#region src/worker/dotlottie.d.ts
1499
1498
  interface DotLottieInstanceState {
1500
- activeAnimationId: string | undefined;
1501
- activeThemeId: string | undefined;
1502
- autoplay: boolean;
1503
- backgroundColor: string;
1504
- currentFrame: number;
1505
- duration: number;
1506
- isFrozen: boolean;
1507
- isLoaded: boolean;
1508
- isPaused: boolean;
1509
- isPlaying: boolean;
1510
- isReady: boolean;
1511
- isStopped: boolean;
1512
- layout: Layout | undefined;
1513
- loop: boolean;
1514
- loopCount: number;
1515
- manifest: Manifest | null;
1516
- marker: string | undefined;
1517
- markers: Marker[];
1518
- mode: Mode;
1519
- renderConfig: RenderConfig;
1520
- segment: [number, number] | undefined;
1521
- segmentDuration: number;
1522
- speed: number;
1523
- totalFrames: number;
1524
- useFrameInterpolation: boolean;
1499
+ activeAnimationId: string | undefined;
1500
+ activeThemeId: string | undefined;
1501
+ autoplay: boolean;
1502
+ backgroundColor: string;
1503
+ currentFrame: number;
1504
+ duration: number;
1505
+ isFrozen: boolean;
1506
+ isLoaded: boolean;
1507
+ isPaused: boolean;
1508
+ isPlaying: boolean;
1509
+ isReady: boolean;
1510
+ isStopped: boolean;
1511
+ layout: Layout | undefined;
1512
+ loop: boolean;
1513
+ loopCount: number;
1514
+ manifest: Manifest | null;
1515
+ marker: string | undefined;
1516
+ markers: Marker[];
1517
+ mode: Mode;
1518
+ renderConfig: RenderConfig;
1519
+ segment: [number, number] | undefined;
1520
+ segmentDuration: number;
1521
+ speed: number;
1522
+ totalFrames: number;
1523
+ useFrameInterpolation: boolean;
1525
1524
  }
1526
1525
  /**
1527
1526
  * Worker-based DotLottie player that offloads animation processing to a Web Worker thread.
@@ -1529,354 +1528,355 @@ interface DotLottieInstanceState {
1529
1528
  * All methods are async (return Promises) due to worker communication. Requires HTMLCanvasElement or OffscreenCanvas.
1530
1529
  */
1531
1530
  declare class DotLottieWorker {
1532
- private static readonly _workerManager;
1533
- private readonly _eventManager;
1534
- private readonly _id;
1535
- private readonly _worker;
1536
- private _canvas;
1537
- private _dotLottieInstanceState;
1538
- private static _wasmUrl;
1539
- private _created;
1540
- private _boundOnClick;
1541
- private _boundOnPointerUp;
1542
- private _boundOnPointerDown;
1543
- private _boundOnPointerMove;
1544
- private _boundOnPointerEnter;
1545
- private _boundOnPointerLeave;
1546
- private _pendingConfig;
1547
- /**
1548
- * Creates a worker-based DotLottie player instance that runs in a separate thread.
1549
- * Use workerId to share a worker across multiple animations for better resource management.
1550
- * @param config - Configuration with optional workerId to share worker threads
1551
- * @throws Error if canvas is not HTMLCanvasElement or OffscreenCanvas
1552
- */
1553
- constructor(config: Config & {
1554
- workerId?: string;
1555
- });
1556
- private _handleWorkerEvent;
1557
- private _create;
1558
- get loopCount(): number;
1559
- get isLoaded(): boolean;
1560
- get isPlaying(): boolean;
1561
- get isPaused(): boolean;
1562
- get isStopped(): boolean;
1563
- get currentFrame(): number;
1564
- get isFrozen(): boolean;
1565
- get segmentDuration(): number;
1566
- get totalFrames(): number;
1567
- get segment(): [number, number] | undefined;
1568
- get speed(): number;
1569
- get duration(): number;
1570
- get isReady(): boolean;
1571
- get mode(): Mode;
1572
- get canvas(): HTMLCanvasElement | OffscreenCanvas | null;
1573
- /**
1574
- * Sets the canvas element for rendering in the worker thread.
1575
- * Cannot change canvas after worker instance is created with a different canvas.
1576
- * @param canvas - HTMLCanvasElement or OffscreenCanvas to render to
1577
- * @returns Promise that resolves when canvas has been set
1578
- * @throws Error if canvas is not HTMLCanvasElement or OffscreenCanvas
1579
- * @throws Error if trying to change canvas after instance is already created
1580
- */
1581
- setCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): Promise<void>;
1582
- get autoplay(): boolean;
1583
- get backgroundColor(): string;
1584
- get loop(): boolean;
1585
- get useFrameInterpolation(): boolean;
1586
- get renderConfig(): RenderConfig;
1587
- get manifest(): Manifest | null;
1588
- get activeAnimationId(): string | undefined;
1589
- get marker(): string | undefined;
1590
- get activeThemeId(): string | undefined;
1591
- get layout(): Layout | undefined;
1592
- /**
1593
- * Starts or resumes animation playback in the worker thread.
1594
- * Updates the internal playback state (e.g., isPlaying) to reflect that playback has started.
1595
- * @returns Promise that resolves when playback has started and state has been updated
1596
- */
1597
- play(): Promise<void>;
1598
- /**
1599
- * Pauses animation playback in the worker thread.
1600
- * Awaits worker response before resolving. Updates isPaused state to true.
1601
- * @returns Promise that resolves when playback has paused
1602
- */
1603
- pause(): Promise<void>;
1604
- /**
1605
- * Stops animation playback and resets to start frame in the worker thread.
1606
- * Awaits worker response before resolving. Updates isStopped state to true.
1607
- * @returns Promise that resolves when playback has stopped
1608
- */
1609
- stop(): Promise<void>;
1610
- /**
1611
- * Changes the animation playback speed in the worker thread.
1612
- * Awaits worker response before resolving.
1613
- * @param speed - Playback speed multiplier (e.g., 2 for 2x speed, 0.5 for half speed)
1614
- * @returns Promise that resolves when speed has been updated
1615
- */
1616
- setSpeed(speed: number): Promise<void>;
1617
- setMode(mode: Mode): Promise<void>;
1618
- setFrame(frame: number): Promise<void>;
1619
- setSegment(start: number, end: number): Promise<void>;
1620
- setRenderConfig(renderConfig: RenderConfig): Promise<void>;
1621
- setUseFrameInterpolation(useFrameInterpolation: boolean): Promise<void>;
1622
- setTheme(themeId: string): Promise<boolean>;
1623
- /**
1624
- * Dynamically loads a new animation in the worker thread, replacing the current one.
1625
- * Awaits worker response before resolving. Stops current playback and cleans up resources.
1626
- * @param config - Configuration for the new animation (all Config properties except canvas)
1627
- * @returns Promise that resolves when animation has been loaded
1628
- */
1629
- load(config: Omit<Config, 'canvas'>): Promise<void>;
1630
- setLoop(loop: boolean): Promise<void>;
1631
- /**
1632
- * Sets the number of additional times to replay the animation after the first play in the worker thread.
1633
- * Requires loop to be true. A value of 0 means infinite replays; a positive value n means
1634
- * the animation plays a total of n + 1 times (initial play + n replays).
1635
- * @param loopCount - Number of additional replays (0 = infinite, 1 = plays twice, 2 = plays three times, etc.)
1636
- * @returns Promise that resolves when loopCount has been updated
1637
- */
1638
- setLoopCount(loopCount: number): Promise<void>;
1639
- /**
1640
- * Recalculates and updates canvas dimensions in the worker thread.
1641
- * Awaits worker response before resolving. Call when canvas container size changes.
1642
- * @returns Promise that resolves when resize has completed
1643
- */
1644
- resize(): Promise<void>;
1645
- /**
1646
- * Cleans up and destroys the player instance in the worker thread, releasing resources.
1647
- * Awaits worker response before resolving. Stops playback and removes event listeners.
1648
- * @returns Promise that resolves when cleanup has completed
1649
- */
1650
- destroy(): Promise<void>;
1651
- freeze(): Promise<void>;
1652
- unfreeze(): Promise<void>;
1653
- setBackgroundColor(backgroundColor: string): Promise<void>;
1654
- loadAnimation(animationId: string): Promise<void>;
1655
- setLayout(layout: Layout): Promise<void>;
1656
- private _updateDotLottieInstanceState;
1657
- markers(): Marker[];
1658
- setMarker(marker: string): Promise<void>;
1659
- setThemeData(themeData: string): Promise<boolean>;
1660
- setViewport(x: number, y: number, width: number, height: number): Promise<boolean>;
1661
- animationSize(): Promise<{
1662
- height: number;
1663
- width: number;
1664
- }>;
1665
- /**
1666
- * @experimental
1667
- * Start a tween animation between two frame values with custom easing
1668
- * @param frame - Starting frame value
1669
- * @param duration - Duration of the tween in seconds
1670
- * @returns true if tween was started successfully
1671
- */
1672
- tween(frame: number, duration: number): Promise<boolean>;
1673
- /**
1674
- * @experimental
1675
- * Start a tween animation to a specific marker
1676
- * @param marker - The marker name to tween to
1677
- * @param duration - Duration of the tween in seconds
1678
- * @returns true if tween was started successfully
1679
- */
1680
- tweenToMarker(marker: string, duration: number): Promise<boolean>;
1681
- setTransform(transform: Transform): Promise<boolean>;
1682
- getTransform(): Promise<Transform | undefined>;
1683
- private _sendMessage;
1684
- addEventListener<T extends EventType>(type: T, listener: EventListener<T>): void;
1685
- removeEventListener<T extends EventType>(type: T, listener?: EventListener<T>): void;
1686
- static setWasmUrl(url: string): void;
1687
- /**
1688
- * @experimental
1689
- *
1690
- * Register a custom font for use in animations in worker contexts
1691
- * @param fontName - The name of the font to register
1692
- * @param fontSource - Either a URL string to fetch the font, or ArrayBuffer/Uint8Array of font data
1693
- * @returns Promise<boolean> - true if registration message was sent successfully
1694
- */
1695
- static registerFont(fontName: string, fontSource: string | ArrayBuffer | Uint8Array): Promise<boolean>;
1696
- /**
1697
- * @experimental
1698
- * Load a state machine by ID
1699
- * @param stateMachineId - The ID of the state machine to load
1700
- * @returns true if the state machine was loaded successfully
1701
- */
1702
- stateMachineLoad(stateMachineId: string): Promise<boolean>;
1703
- /**
1704
- * @experimental
1705
- * Load a state machine from data string
1706
- * @param stateMachineData - The state machine data as a string
1707
- * @returns true if the state machine was loaded successfully
1708
- */
1709
- stateMachineLoadData(stateMachineData: string): Promise<boolean>;
1710
- /**
1711
- * @experimental
1712
- * Start the state machine
1713
- * @returns true if the state machine was started successfully
1714
- */
1715
- stateMachineStart(): Promise<boolean>;
1716
- /**
1717
- * @experimental
1718
- * Stop the state machine
1719
- * @returns true if the state machine was stopped successfully
1720
- */
1721
- stateMachineStop(): Promise<boolean>;
1722
- /**
1723
- * @experimental
1724
- * Set a numeric input value for the state machine
1725
- * @param name - The name of the numeric input
1726
- * @param value - The numeric value to set
1727
- * @returns true if the input was set successfully
1728
- */
1729
- stateMachineSetNumericInput(name: string, value: number): Promise<boolean>;
1730
- /**
1731
- * @experimental
1732
- * Set a boolean input value for the state machine
1733
- * @param name - The name of the boolean input
1734
- * @param value - The boolean value to set
1735
- * @returns true if the input was set successfully
1736
- */
1737
- stateMachineSetBooleanInput(name: string, value: boolean): Promise<boolean>;
1738
- /**
1739
- * @experimental
1740
- * Set the state machine config
1741
- * @param config - The state machine config
1742
- */
1743
- stateMachineSetConfig(config: StateMachineConfig | null): Promise<void>;
1744
- /**
1745
- * @experimental
1746
- * Set a string input value for the state machine
1747
- * @param name - The name of the string input
1748
- * @param value - The string value to set
1749
- * @returns true if the input was set successfully
1750
- */
1751
- stateMachineSetStringInput(name: string, value: string): Promise<boolean>;
1752
- /**
1753
- * @experimental
1754
- * Get a numeric input value from the state machine
1755
- * @param name - The name of the numeric input
1756
- * @returns The numeric value or undefined if not found
1757
- */
1758
- stateMachineGetNumericInput(name: string): Promise<number | undefined>;
1759
- /**
1760
- * @experimental
1761
- * Get a boolean input value from the state machine
1762
- * @param name - The name of the boolean input
1763
- * @returns The boolean value or undefined if not found
1764
- */
1765
- stateMachineGetBooleanInput(name: string): Promise<boolean | undefined>;
1766
- /**
1767
- * @experimental
1768
- * Get a string input value from the state machine
1769
- * @param name - The name of the string input
1770
- * @returns The string value or undefined if not found
1771
- */
1772
- stateMachineGetStringInput(name: string): Promise<string | undefined>;
1773
- /**
1774
- * @experimental
1775
- * Get all inputs
1776
- * @returns All input keys, followed by their type
1777
- */
1778
- stateMachineGetInputs(): Promise<string[] | undefined>;
1779
- /**
1780
- * @experimental
1781
- * Fire an event in the state machine
1782
- * @param name - The name of the event to fire
1783
- */
1784
- stateMachineFireEvent(name: string): Promise<void>;
1785
- /**
1786
- * @experimental
1787
- * Get the current status of the state machine
1788
- * @returns The current status of the state machine as a string
1789
- */
1790
- stateMachineGetStatus(): Promise<string>;
1791
- /**
1792
- * @experimental
1793
- * Get the current state of the state machine
1794
- * @returns The current state of the state machine as a string
1795
- */
1796
- stateMachineGetCurrentState(): Promise<string>;
1797
- /**
1798
- * @experimental
1799
- * Get the active state machine ID
1800
- * @returns The active state machine ID as a string
1801
- */
1802
- stateMachineGetActiveId(): Promise<string>;
1803
- /**
1804
- * @experimental
1805
- * Override the current state of the state machine
1806
- * @param state - The state to override to
1807
- * @param immediate - Whether to immediately transition to the state
1808
- * @returns true if the state override was successful
1809
- */
1810
- stateMachineOverrideState(state: string, immediate?: boolean): Promise<boolean>;
1811
- /**
1812
- * @experimental
1813
- * Get a specific state machine by ID
1814
- * @param stateMachineId - The ID of the state machine to get
1815
- * @returns The state machine data as a string
1816
- */
1817
- stateMachineGet(stateMachineId: string): Promise<string>;
1818
- /**
1819
- * @experimental
1820
- * Get the list of state machine listeners
1821
- * @returns Array of listener names
1822
- */
1823
- stateMachineGetListeners(): Promise<string[]>;
1824
- /**
1825
- * @experimental
1826
- * Post a click event to the state machine
1827
- * @param x - The x coordinate of the click
1828
- * @param y - The y coordinate of the click
1829
- * @returns The event result or undefined
1830
- */
1831
- stateMachinePostClickEvent(x: number, y: number): Promise<void>;
1832
- /**
1833
- * @experimental
1834
- * Post a pointer up event to the state machine
1835
- * @param x - The x coordinate of the pointer
1836
- * @param y - The y coordinate of the pointer
1837
- * @returns The event result or undefined
1838
- */
1839
- stateMachinePostPointerUpEvent(x: number, y: number): Promise<void>;
1840
- /**
1841
- * @experimental
1842
- * Post a pointer down event to the state machine
1843
- * @param x - The x coordinate of the pointer
1844
- * @param y - The y coordinate of the pointer
1845
- * @returns The event result or undefined
1846
- */
1847
- stateMachinePostPointerDownEvent(x: number, y: number): Promise<void>;
1848
- /**
1849
- * @experimental
1850
- * Post a pointer move event to the state machine
1851
- * @param x - The x coordinate of the pointer
1852
- * @param y - The y coordinate of the pointer
1853
- * @returns The event result or undefined
1854
- */
1855
- stateMachinePostPointerMoveEvent(x: number, y: number): Promise<void>;
1856
- /**
1857
- * @experimental
1858
- * Post a pointer enter event to the state machine
1859
- * @param x - The x coordinate of the pointer
1860
- * @param y - The y coordinate of the pointer
1861
- * @returns The event result or undefined
1862
- */
1863
- stateMachinePostPointerEnterEvent(x: number, y: number): Promise<void>;
1864
- /**
1865
- * @experimental
1866
- * Post a pointer exit event to the state machine
1867
- * @param x - The x coordinate of the pointer
1868
- * @param y - The y coordinate of the pointer
1869
- * @returns The event result or undefined
1870
- */
1871
- stateMachinePostPointerExitEvent(x: number, y: number): Promise<void>;
1872
- private _onClick;
1873
- private _onPointerUp;
1874
- private _onPointerDown;
1875
- private _onPointerMove;
1876
- private _onPointerEnter;
1877
- private _onPointerLeave;
1878
- private _setupStateMachineListeners;
1879
- private _cleanupStateMachineListeners;
1531
+ private static readonly _workerManager;
1532
+ private readonly _eventManager;
1533
+ private readonly _id;
1534
+ private readonly _worker;
1535
+ private _canvas;
1536
+ private _dotLottieInstanceState;
1537
+ private static _wasmUrl;
1538
+ private _created;
1539
+ private _boundOnClick;
1540
+ private _boundOnPointerUp;
1541
+ private _boundOnPointerDown;
1542
+ private _boundOnPointerMove;
1543
+ private _boundOnPointerEnter;
1544
+ private _boundOnPointerLeave;
1545
+ private _pendingConfig;
1546
+ /**
1547
+ * Creates a worker-based DotLottie player instance that runs in a separate thread.
1548
+ * Use workerId to share a worker across multiple animations for better resource management.
1549
+ * @param config - Configuration with optional workerId to share worker threads
1550
+ * @throws Error if canvas is not HTMLCanvasElement or OffscreenCanvas
1551
+ */
1552
+ constructor(config: Config & {
1553
+ workerId?: string;
1554
+ });
1555
+ private _handleWorkerEvent;
1556
+ private _create;
1557
+ get loopCount(): number;
1558
+ get isLoaded(): boolean;
1559
+ get isPlaying(): boolean;
1560
+ get isPaused(): boolean;
1561
+ get isStopped(): boolean;
1562
+ get currentFrame(): number;
1563
+ get isFrozen(): boolean;
1564
+ get segmentDuration(): number;
1565
+ get totalFrames(): number;
1566
+ get segment(): [number, number] | undefined;
1567
+ get speed(): number;
1568
+ get duration(): number;
1569
+ get isReady(): boolean;
1570
+ get mode(): Mode;
1571
+ get canvas(): HTMLCanvasElement | OffscreenCanvas | null;
1572
+ /**
1573
+ * Sets the canvas element for rendering in the worker thread.
1574
+ * Cannot change canvas after worker instance is created with a different canvas.
1575
+ * @param canvas - HTMLCanvasElement or OffscreenCanvas to render to
1576
+ * @returns Promise that resolves when canvas has been set
1577
+ * @throws Error if canvas is not HTMLCanvasElement or OffscreenCanvas
1578
+ * @throws Error if trying to change canvas after instance is already created
1579
+ */
1580
+ setCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): Promise<void>;
1581
+ get autoplay(): boolean;
1582
+ get backgroundColor(): string;
1583
+ get loop(): boolean;
1584
+ get useFrameInterpolation(): boolean;
1585
+ get renderConfig(): RenderConfig;
1586
+ get manifest(): Manifest | null;
1587
+ get activeAnimationId(): string | undefined;
1588
+ get marker(): string | undefined;
1589
+ get activeThemeId(): string | undefined;
1590
+ get layout(): Layout | undefined;
1591
+ /**
1592
+ * Starts or resumes animation playback in the worker thread.
1593
+ * Updates the internal playback state (e.g., isPlaying) to reflect that playback has started.
1594
+ * @returns Promise that resolves when playback has started and state has been updated
1595
+ */
1596
+ play(): Promise<void>;
1597
+ /**
1598
+ * Pauses animation playback in the worker thread.
1599
+ * Awaits worker response before resolving. Updates isPaused state to true.
1600
+ * @returns Promise that resolves when playback has paused
1601
+ */
1602
+ pause(): Promise<void>;
1603
+ /**
1604
+ * Stops animation playback and resets to start frame in the worker thread.
1605
+ * Awaits worker response before resolving. Updates isStopped state to true.
1606
+ * @returns Promise that resolves when playback has stopped
1607
+ */
1608
+ stop(): Promise<void>;
1609
+ /**
1610
+ * Changes the animation playback speed in the worker thread.
1611
+ * Awaits worker response before resolving.
1612
+ * @param speed - Playback speed multiplier (e.g., 2 for 2x speed, 0.5 for half speed)
1613
+ * @returns Promise that resolves when speed has been updated
1614
+ */
1615
+ setSpeed(speed: number): Promise<void>;
1616
+ setMode(mode: Mode): Promise<void>;
1617
+ setFrame(frame: number): Promise<void>;
1618
+ setSegment(start: number, end: number): Promise<void>;
1619
+ setRenderConfig(renderConfig: RenderConfig): Promise<void>;
1620
+ setUseFrameInterpolation(useFrameInterpolation: boolean): Promise<void>;
1621
+ setTheme(themeId: string): Promise<boolean>;
1622
+ /**
1623
+ * Dynamically loads a new animation in the worker thread, replacing the current one.
1624
+ * Awaits worker response before resolving. Stops current playback and cleans up resources.
1625
+ * @param config - Configuration for the new animation (all Config properties except canvas)
1626
+ * @returns Promise that resolves when animation has been loaded
1627
+ */
1628
+ load(config: Omit<Config, 'canvas'>): Promise<void>;
1629
+ setLoop(loop: boolean): Promise<void>;
1630
+ /**
1631
+ * Sets the number of additional times to replay the animation after the first play in the worker thread.
1632
+ * Requires loop to be true. A value of 0 means infinite replays; a positive value n means
1633
+ * the animation plays a total of n + 1 times (initial play + n replays).
1634
+ * @param loopCount - Number of additional replays (0 = infinite, 1 = plays twice, 2 = plays three times, etc.)
1635
+ * @returns Promise that resolves when loopCount has been updated
1636
+ */
1637
+ setLoopCount(loopCount: number): Promise<void>;
1638
+ /**
1639
+ * Recalculates and updates canvas dimensions in the worker thread.
1640
+ * Awaits worker response before resolving. Call when canvas container size changes.
1641
+ * @returns Promise that resolves when resize has completed
1642
+ */
1643
+ resize(): Promise<void>;
1644
+ /**
1645
+ * Cleans up and destroys the player instance in the worker thread, releasing resources.
1646
+ * Awaits worker response before resolving. Stops playback and removes event listeners.
1647
+ * @returns Promise that resolves when cleanup has completed
1648
+ */
1649
+ destroy(): Promise<void>;
1650
+ freeze(): Promise<void>;
1651
+ unfreeze(): Promise<void>;
1652
+ setBackgroundColor(backgroundColor: string): Promise<void>;
1653
+ loadAnimation(animationId: string): Promise<void>;
1654
+ setLayout(layout: Layout): Promise<void>;
1655
+ private _updateDotLottieInstanceState;
1656
+ markers(): Marker[];
1657
+ setMarker(marker: string): Promise<void>;
1658
+ setThemeData(themeData: string): Promise<boolean>;
1659
+ setViewport(x: number, y: number, width: number, height: number): Promise<boolean>;
1660
+ animationSize(): Promise<{
1661
+ height: number;
1662
+ width: number;
1663
+ }>;
1664
+ /**
1665
+ * @experimental
1666
+ * Start a tween animation between two frame values with custom easing
1667
+ * @param frame - Starting frame value
1668
+ * @param duration - Duration of the tween in seconds
1669
+ * @returns true if tween was started successfully
1670
+ */
1671
+ tween(frame: number, duration: number): Promise<boolean>;
1672
+ /**
1673
+ * @experimental
1674
+ * Start a tween animation to a specific marker
1675
+ * @param marker - The marker name to tween to
1676
+ * @param duration - Duration of the tween in seconds
1677
+ * @returns true if tween was started successfully
1678
+ */
1679
+ tweenToMarker(marker: string, duration: number): Promise<boolean>;
1680
+ setTransform(transform: Transform): Promise<boolean>;
1681
+ getTransform(): Promise<Transform | undefined>;
1682
+ private _sendMessage;
1683
+ addEventListener<T extends EventType>(type: T, listener: EventListener<T>): void;
1684
+ removeEventListener<T extends EventType>(type: T, listener?: EventListener<T>): void;
1685
+ static setWasmUrl(url: string): void;
1686
+ /**
1687
+ * @experimental
1688
+ *
1689
+ * Register a custom font for use in animations in worker contexts
1690
+ * @param fontName - The name of the font to register
1691
+ * @param fontSource - Either a URL string to fetch the font, or ArrayBuffer/Uint8Array of font data
1692
+ * @returns Promise<boolean> - true if registration message was sent successfully
1693
+ */
1694
+ static registerFont(fontName: string, fontSource: string | ArrayBuffer | Uint8Array): Promise<boolean>;
1695
+ /**
1696
+ * @experimental
1697
+ * Load a state machine by ID
1698
+ * @param stateMachineId - The ID of the state machine to load
1699
+ * @returns true if the state machine was loaded successfully
1700
+ */
1701
+ stateMachineLoad(stateMachineId: string): Promise<boolean>;
1702
+ /**
1703
+ * @experimental
1704
+ * Load a state machine from data string
1705
+ * @param stateMachineData - The state machine data as a string
1706
+ * @returns true if the state machine was loaded successfully
1707
+ */
1708
+ stateMachineLoadData(stateMachineData: string): Promise<boolean>;
1709
+ /**
1710
+ * @experimental
1711
+ * Start the state machine
1712
+ * @returns true if the state machine was started successfully
1713
+ */
1714
+ stateMachineStart(): Promise<boolean>;
1715
+ /**
1716
+ * @experimental
1717
+ * Stop the state machine
1718
+ * @returns true if the state machine was stopped successfully
1719
+ */
1720
+ stateMachineStop(): Promise<boolean>;
1721
+ /**
1722
+ * @experimental
1723
+ * Set a numeric input value for the state machine
1724
+ * @param name - The name of the numeric input
1725
+ * @param value - The numeric value to set
1726
+ * @returns true if the input was set successfully
1727
+ */
1728
+ stateMachineSetNumericInput(name: string, value: number): Promise<boolean>;
1729
+ /**
1730
+ * @experimental
1731
+ * Set a boolean input value for the state machine
1732
+ * @param name - The name of the boolean input
1733
+ * @param value - The boolean value to set
1734
+ * @returns true if the input was set successfully
1735
+ */
1736
+ stateMachineSetBooleanInput(name: string, value: boolean): Promise<boolean>;
1737
+ /**
1738
+ * @experimental
1739
+ * Set the state machine config
1740
+ * @param config - The state machine config
1741
+ */
1742
+ stateMachineSetConfig(config: StateMachineConfig | null): Promise<void>;
1743
+ /**
1744
+ * @experimental
1745
+ * Set a string input value for the state machine
1746
+ * @param name - The name of the string input
1747
+ * @param value - The string value to set
1748
+ * @returns true if the input was set successfully
1749
+ */
1750
+ stateMachineSetStringInput(name: string, value: string): Promise<boolean>;
1751
+ /**
1752
+ * @experimental
1753
+ * Get a numeric input value from the state machine
1754
+ * @param name - The name of the numeric input
1755
+ * @returns The numeric value or undefined if not found
1756
+ */
1757
+ stateMachineGetNumericInput(name: string): Promise<number | undefined>;
1758
+ /**
1759
+ * @experimental
1760
+ * Get a boolean input value from the state machine
1761
+ * @param name - The name of the boolean input
1762
+ * @returns The boolean value or undefined if not found
1763
+ */
1764
+ stateMachineGetBooleanInput(name: string): Promise<boolean | undefined>;
1765
+ /**
1766
+ * @experimental
1767
+ * Get a string input value from the state machine
1768
+ * @param name - The name of the string input
1769
+ * @returns The string value or undefined if not found
1770
+ */
1771
+ stateMachineGetStringInput(name: string): Promise<string | undefined>;
1772
+ /**
1773
+ * @experimental
1774
+ * Get all inputs
1775
+ * @returns All input keys, followed by their type
1776
+ */
1777
+ stateMachineGetInputs(): Promise<string[] | undefined>;
1778
+ /**
1779
+ * @experimental
1780
+ * Fire an event in the state machine
1781
+ * @param name - The name of the event to fire
1782
+ */
1783
+ stateMachineFireEvent(name: string): Promise<void>;
1784
+ /**
1785
+ * @experimental
1786
+ * Get the current status of the state machine
1787
+ * @returns The current status of the state machine as a string
1788
+ */
1789
+ stateMachineGetStatus(): Promise<string>;
1790
+ /**
1791
+ * @experimental
1792
+ * Get the current state of the state machine
1793
+ * @returns The current state of the state machine as a string
1794
+ */
1795
+ stateMachineGetCurrentState(): Promise<string>;
1796
+ /**
1797
+ * @experimental
1798
+ * Get the active state machine ID
1799
+ * @returns The active state machine ID as a string
1800
+ */
1801
+ stateMachineGetActiveId(): Promise<string>;
1802
+ /**
1803
+ * @experimental
1804
+ * Override the current state of the state machine
1805
+ * @param state - The state to override to
1806
+ * @param immediate - Whether to immediately transition to the state
1807
+ * @returns true if the state override was successful
1808
+ */
1809
+ stateMachineOverrideState(state: string, immediate?: boolean): Promise<boolean>;
1810
+ /**
1811
+ * @experimental
1812
+ * Get a specific state machine by ID
1813
+ * @param stateMachineId - The ID of the state machine to get
1814
+ * @returns The state machine data as a string
1815
+ */
1816
+ stateMachineGet(stateMachineId: string): Promise<string>;
1817
+ /**
1818
+ * @experimental
1819
+ * Get the list of state machine listeners
1820
+ * @returns Array of listener names
1821
+ */
1822
+ stateMachineGetListeners(): Promise<string[]>;
1823
+ /**
1824
+ * @experimental
1825
+ * Post a click event to the state machine
1826
+ * @param x - The x coordinate of the click
1827
+ * @param y - The y coordinate of the click
1828
+ * @returns The event result or undefined
1829
+ */
1830
+ stateMachinePostClickEvent(x: number, y: number): Promise<void>;
1831
+ /**
1832
+ * @experimental
1833
+ * Post a pointer up event to the state machine
1834
+ * @param x - The x coordinate of the pointer
1835
+ * @param y - The y coordinate of the pointer
1836
+ * @returns The event result or undefined
1837
+ */
1838
+ stateMachinePostPointerUpEvent(x: number, y: number): Promise<void>;
1839
+ /**
1840
+ * @experimental
1841
+ * Post a pointer down event to the state machine
1842
+ * @param x - The x coordinate of the pointer
1843
+ * @param y - The y coordinate of the pointer
1844
+ * @returns The event result or undefined
1845
+ */
1846
+ stateMachinePostPointerDownEvent(x: number, y: number): Promise<void>;
1847
+ /**
1848
+ * @experimental
1849
+ * Post a pointer move event to the state machine
1850
+ * @param x - The x coordinate of the pointer
1851
+ * @param y - The y coordinate of the pointer
1852
+ * @returns The event result or undefined
1853
+ */
1854
+ stateMachinePostPointerMoveEvent(x: number, y: number): Promise<void>;
1855
+ /**
1856
+ * @experimental
1857
+ * Post a pointer enter event to the state machine
1858
+ * @param x - The x coordinate of the pointer
1859
+ * @param y - The y coordinate of the pointer
1860
+ * @returns The event result or undefined
1861
+ */
1862
+ stateMachinePostPointerEnterEvent(x: number, y: number): Promise<void>;
1863
+ /**
1864
+ * @experimental
1865
+ * Post a pointer exit event to the state machine
1866
+ * @param x - The x coordinate of the pointer
1867
+ * @param y - The y coordinate of the pointer
1868
+ * @returns The event result or undefined
1869
+ */
1870
+ stateMachinePostPointerExitEvent(x: number, y: number): Promise<void>;
1871
+ private _onClick;
1872
+ private _onPointerUp;
1873
+ private _onPointerDown;
1874
+ private _onPointerMove;
1875
+ private _onPointerEnter;
1876
+ private _onPointerLeave;
1877
+ private _setupStateMachineListeners;
1878
+ private _cleanupStateMachineListeners;
1880
1879
  }
1881
-
1882
- export { type BaseEvent, type BezierHandle, type Color, type ColorSlotValue, type CompleteEvent, type Config, type Data, type DestroyEvent, DotLottie, type DotLottieInstanceState, DotLottieWorker, type Event, type EventListener, EventManager, type EventType, type Fit, type FrameEvent, type FreezeEvent, type Gradient, type GradientSlotValue, type Keyframe, type Layout, type LoadErrorEvent, type LoadEvent, type LoopEvent, type Manifest, type Mode, type PauseEvent, type PlayEvent, type ReadyEvent, type RenderConfig, type RenderErrorEvent, type RenderEvent, type RenderSurface, type ScalarSlotValue, type SlotType, type StateMachineBooleanInputValueChangeEvent, type StateMachineConfig, type StateMachineCustomEvent, type StateMachineErrorEvent, type StateMachineInputFiredEvent, type StateMachineInternalMessage, type StateMachineNumericInputValueChangeEvent, type StateMachineStartEvent, type StateMachineStateEnteredEvent, type StateMachineStateExitEvent, type StateMachineStopEvent, type StateMachineStringInputValueChangeEvent, type StateMachineTransitionEvent, type StopEvent, type TextDocument, type TextSlotValue, type Theme, type ThemeBaseKeyframe, type ThemeBaseRule, type ThemeColorKeyframe, type ThemeColorRule, type ThemeGradientKeyframe, type ThemeGradientRule, type ThemeGradientStop, type ThemeImageRule, type ThemeImageValue, type ThemePositionKeyframe, type ThemePositionRule, type ThemeRule, type ThemeScalarKeyframe, type ThemeScalarRule, type ThemeTextCaps, type ThemeTextDocument, type ThemeTextJustify, type ThemeTextKeyframe, type ThemeTextRule, type ThemeVectorKeyframe, type ThemeVectorRule, type Transform, type UnfreezeEvent, type Vector, type VectorSlotValue };
1880
+ //#endregion
1881
+ export { BaseEvent, BezierHandle, Color, ColorSlotValue, CompleteEvent, Config, Data, DestroyEvent, DotLottie, DotLottieInstanceState, DotLottieWorker, Event, EventListener, EventManager, EventType, Fit, FrameEvent, FreezeEvent, Gradient, GradientSlotValue, Keyframe, Layout, LoadErrorEvent, LoadEvent, LoopEvent, Manifest, Mode, PauseEvent, PlayEvent, ReadyEvent, RenderConfig, RenderErrorEvent, RenderEvent, RenderSurface, ScalarSlotValue, SlotType, StateMachineBooleanInputValueChangeEvent, StateMachineConfig, StateMachineCustomEvent, StateMachineErrorEvent, StateMachineInputFiredEvent, StateMachineInternalMessage, StateMachineNumericInputValueChangeEvent, StateMachineStartEvent, StateMachineStateEnteredEvent, StateMachineStateExitEvent, StateMachineStopEvent, StateMachineStringInputValueChangeEvent, StateMachineTransitionEvent, StopEvent, TextDocument, TextSlotValue, Theme, ThemeBaseKeyframe, ThemeBaseRule, ThemeColorKeyframe, ThemeColorRule, ThemeGradientKeyframe, ThemeGradientRule, ThemeGradientStop, ThemeImageRule, ThemeImageValue, ThemePositionKeyframe, ThemePositionRule, ThemeRule, ThemeScalarKeyframe, ThemeScalarRule, ThemeTextCaps, ThemeTextDocument, ThemeTextJustify, ThemeTextKeyframe, ThemeTextRule, ThemeVectorKeyframe, ThemeVectorRule, Transform, UnfreezeEvent, Vector, VectorSlotValue };
1882
+ //# sourceMappingURL=index.d.ts.map