@lordicon/utils-lottie 0.9.4

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/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2025 Lordicon
4
+
5
+ ====
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+
25
+ ====
26
+
27
+ Files located in the node_modules and encoders directories are externally
28
+ maintained libraries used by this software which have their own
29
+ licenses; we recommend you read them, as their terms may differ from the
30
+ terms above.
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # Lottie Utilities
2
+
3
+ Utilities for working with Lottie animation files.
4
+
5
+ - 📦 Parse Lottie files and extract their structure.
6
+ - 🎛️ Retrieve properties for dynamic updates (colors, stroke, etc.).
7
+ - ✏️ Update Lottie files with new property values.
8
+ - 🧹 Remove unnecessary elements to optimize your Lottie animations.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @lordicon/utils-lottie
14
+ ```
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Deep clone value.
3
+ * @param value Value to clone.
4
+ */
5
+ export declare function deepClone<T = any>(value: T): T;
6
+ /**
7
+ * Checks if value is null or undefined.
8
+ * @param value Value to check.
9
+ * @returns True if value is null or undefined, false otherwise.
10
+ */
11
+ export declare function isNil(value: any): boolean;
12
+ /**
13
+ * Checks if value is object like.
14
+ * @param value Value to check.
15
+ * @returns True if value is object like, false otherwise.
16
+ */
17
+ export declare function isObjectLike(value: any): value is object;
18
+ /**
19
+ * Checks if path is a direct property of object.
20
+ * @param object Object to check.
21
+ * @param path Path to check.
22
+ */
23
+ export declare function has<T>(object: T, path: string | string[]): boolean;
24
+ /**
25
+ * Get object value from path. Otherwise return defaultValue.
26
+ * @param object Object to get value from.
27
+ * @param path Path to the value.
28
+ * @param defaultValue Default value to return if not found.
29
+ */
30
+ export declare function get<T>(object: T, path: string | string[], defaultValue?: any): any;
31
+ /**
32
+ * Update object value on path.
33
+ * @param object Object to update.
34
+ * @param path Path to the value.
35
+ * @param value New value to set.
36
+ */
37
+ export declare function set(object: any, path: string | string[], value: any): void;
package/dist/icon.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { IconProperties, LottieData } from './interfaces';
2
+ /**
3
+ * Create new customized icon data.
4
+ * @param data Original Lottie data.
5
+ * @param assign Icon properties to assign.
6
+ * @param params Additional parameters.
7
+ * @returns Customized Lottie data.
8
+ */
9
+ export declare function customizeIcon(data: LottieData, assign: IconProperties, minify?: 'full' | 'partial'): LottieData;
@@ -0,0 +1,6 @@
1
+ export { deepClone, get, has, isNil, isObjectLike, set } from './helpers';
2
+ export { customizeIcon } from './icon';
3
+ export * from './interfaces';
4
+ export { extractLottieProperties, hexToRgb, hexToTupleColor, resetLottieProperties, rgbToHex, tupleColorToHex, updateLottieProperties } from './lottie';
5
+ export { parseColor, parseColors, parseState, parseStroke } from './parsers';
6
+ export { readStates } from './states';
package/dist/index.js ADDED
@@ -0,0 +1,398 @@
1
+ function S(e) {
2
+ return structuredClone(e);
3
+ }
4
+ function _(e) {
5
+ return e == null;
6
+ }
7
+ function m(e) {
8
+ return e !== null && typeof e == "object";
9
+ }
10
+ function H(e, f) {
11
+ const r = Array.isArray(f) ? f : f.split(".");
12
+ let t = e;
13
+ for (const n of r) {
14
+ if (!m(t) || !(n in t))
15
+ return !1;
16
+ t = t[n];
17
+ }
18
+ return !0;
19
+ }
20
+ function R(e, f, r) {
21
+ const t = Array.isArray(f) ? f : f.split(".");
22
+ let n = e;
23
+ for (const o of t) {
24
+ if (!m(n) || !(o in n))
25
+ return r;
26
+ n = n[o];
27
+ }
28
+ return n === void 0 ? r : n;
29
+ }
30
+ function a(e, f, r) {
31
+ let t = e;
32
+ const n = Array.isArray(f) ? f : f.split(".");
33
+ for (let o = 0; o < n.length; ++o)
34
+ o === n.length - 1 ? t[n[o]] = r : t = t[n[o]];
35
+ }
36
+ const O = {
37
+ aliceblue: "#f0f8ff",
38
+ antiquewhite: "#faebd7",
39
+ aqua: "#00ffff",
40
+ aquamarine: "#7fffd4",
41
+ azure: "#f0ffff",
42
+ beige: "#f5f5dc",
43
+ bisque: "#ffe4c4",
44
+ black: "#000000",
45
+ blanchedalmond: "#ffebcd",
46
+ blue: "#0000ff",
47
+ blueviolet: "#8a2be2",
48
+ brown: "#a52a2a",
49
+ burlywood: "#deb887",
50
+ cadetblue: "#5f9ea0",
51
+ chartreuse: "#7fff00",
52
+ chocolate: "#d2691e",
53
+ coral: "#ff7f50",
54
+ cornflowerblue: "#6495ed",
55
+ cornsilk: "#fff8dc",
56
+ crimson: "#dc143c",
57
+ cyan: "#00ffff",
58
+ darkblue: "#00008b",
59
+ darkcyan: "#008b8b",
60
+ darkgoldenrod: "#b8860b",
61
+ darkgray: "#a9a9a9",
62
+ darkgreen: "#006400",
63
+ darkkhaki: "#bdb76b",
64
+ darkmagenta: "#8b008b",
65
+ darkolivegreen: "#556b2f",
66
+ darkorange: "#ff8c00",
67
+ darkorchid: "#9932cc",
68
+ darkred: "#8b0000",
69
+ darksalmon: "#e9967a",
70
+ darkseagreen: "#8fbc8f",
71
+ darkslateblue: "#483d8b",
72
+ darkslategray: "#2f4f4f",
73
+ darkturquoise: "#00ced1",
74
+ darkviolet: "#9400d3",
75
+ deeppink: "#ff1493",
76
+ deepskyblue: "#00bfff",
77
+ dimgray: "#696969",
78
+ dodgerblue: "#1e90ff",
79
+ firebrick: "#b22222",
80
+ floralwhite: "#fffaf0",
81
+ forestgreen: "#228b22",
82
+ fuchsia: "#ff00ff",
83
+ gainsboro: "#dcdcdc",
84
+ ghostwhite: "#f8f8ff",
85
+ gold: "#ffd700",
86
+ goldenrod: "#daa520",
87
+ gray: "#808080",
88
+ green: "#008000",
89
+ greenyellow: "#adff2f",
90
+ honeydew: "#f0fff0",
91
+ hotpink: "#ff69b4",
92
+ "indianred ": "#cd5c5c",
93
+ indigo: "#4b0082",
94
+ ivory: "#fffff0",
95
+ khaki: "#f0e68c",
96
+ lavender: "#e6e6fa",
97
+ lavenderblush: "#fff0f5",
98
+ lawngreen: "#7cfc00",
99
+ lemonchiffon: "#fffacd",
100
+ lightblue: "#add8e6",
101
+ lightcoral: "#f08080",
102
+ lightcyan: "#e0ffff",
103
+ lightgoldenrodyellow: "#fafad2",
104
+ lightgrey: "#d3d3d3",
105
+ lightgreen: "#90ee90",
106
+ lightpink: "#ffb6c1",
107
+ lightsalmon: "#ffa07a",
108
+ lightseagreen: "#20b2aa",
109
+ lightskyblue: "#87cefa",
110
+ lightslategray: "#778899",
111
+ lightsteelblue: "#b0c4de",
112
+ lightyellow: "#ffffe0",
113
+ lime: "#00ff00",
114
+ limegreen: "#32cd32",
115
+ linen: "#faf0e6",
116
+ magenta: "#ff00ff",
117
+ maroon: "#800000",
118
+ mediumaquamarine: "#66cdaa",
119
+ mediumblue: "#0000cd",
120
+ mediumorchid: "#ba55d3",
121
+ mediumpurple: "#9370d8",
122
+ mediumseagreen: "#3cb371",
123
+ mediumslateblue: "#7b68ee",
124
+ mediumspringgreen: "#00fa9a",
125
+ mediumturquoise: "#48d1cc",
126
+ mediumvioletred: "#c71585",
127
+ midnightblue: "#191970",
128
+ mintcream: "#f5fffa",
129
+ mistyrose: "#ffe4e1",
130
+ moccasin: "#ffe4b5",
131
+ navajowhite: "#ffdead",
132
+ navy: "#000080",
133
+ oldlace: "#fdf5e6",
134
+ olive: "#808000",
135
+ olivedrab: "#6b8e23",
136
+ orange: "#ffa500",
137
+ orangered: "#ff4500",
138
+ orchid: "#da70d6",
139
+ palegoldenrod: "#eee8aa",
140
+ palegreen: "#98fb98",
141
+ paleturquoise: "#afeeee",
142
+ palevioletred: "#d87093",
143
+ papayawhip: "#ffefd5",
144
+ peachpuff: "#ffdab9",
145
+ peru: "#cd853f",
146
+ pink: "#ffc0cb",
147
+ plum: "#dda0dd",
148
+ powderblue: "#b0e0e6",
149
+ purple: "#800080",
150
+ rebeccapurple: "#663399",
151
+ red: "#ff0000",
152
+ rosybrown: "#bc8f8f",
153
+ royalblue: "#4169e1",
154
+ saddlebrown: "#8b4513",
155
+ salmon: "#fa8072",
156
+ sandybrown: "#f4a460",
157
+ seagreen: "#2e8b57",
158
+ seashell: "#fff5ee",
159
+ sienna: "#a0522d",
160
+ silver: "#c0c0c0",
161
+ skyblue: "#87ceeb",
162
+ slateblue: "#6a5acd",
163
+ slategray: "#708090",
164
+ snow: "#fffafa",
165
+ springgreen: "#00ff7f",
166
+ steelblue: "#4682b4",
167
+ tan: "#d2b48c",
168
+ teal: "#008080",
169
+ thistle: "#d8bfd8",
170
+ tomato: "#ff6347",
171
+ turquoise: "#40e0d0",
172
+ violet: "#ee82ee",
173
+ wheat: "#f5deb3",
174
+ white: "#ffffff",
175
+ whitesmoke: "#f5f5f5",
176
+ yellow: "#ffff00",
177
+ yellowgreen: "#9acd32"
178
+ };
179
+ function y(e) {
180
+ return e.startsWith("#") ? e.length === 4 ? `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}` : e : O[e.toLowerCase()] || "#000000";
181
+ }
182
+ function z(e) {
183
+ return !e || typeof e != "string" ? void 0 : e.split(",").filter((r) => r).map((r) => r.split(":")).filter((r) => r.length == 2).reduce((r, t) => {
184
+ const n = t[0];
185
+ return r[n.toLowerCase()] = y(t[1]), r;
186
+ }, {});
187
+ }
188
+ function A(e) {
189
+ if (e === "light" || e === 1 || e === "1")
190
+ return 1;
191
+ if (e === "regular" || e === 2 || e === "2")
192
+ return 2;
193
+ if (e === "bold" || e === 3 || e === "3")
194
+ return 3;
195
+ }
196
+ function C(e) {
197
+ if (typeof e == "string")
198
+ return e;
199
+ }
200
+ function k(e) {
201
+ const f = e.toString(16);
202
+ return f.length == 1 ? "0" + f : f;
203
+ }
204
+ function d(e) {
205
+ return Math.round(e / 255 * 1e3) / 1e3;
206
+ }
207
+ function g(e) {
208
+ return Math.round(e * 255);
209
+ }
210
+ function j(e) {
211
+ return "#" + k(e.r) + k(e.g) + k(e.b);
212
+ }
213
+ function B(e) {
214
+ let f = parseInt(e[0] != "#" ? e : e.substring(1), 16);
215
+ return {
216
+ r: f >> 16 & 255,
217
+ g: f >> 8 & 255,
218
+ b: f & 255
219
+ };
220
+ }
221
+ function $(e) {
222
+ const {
223
+ r: f,
224
+ g: r,
225
+ b: t
226
+ } = B(e);
227
+ return [d(f), d(r), d(t)];
228
+ }
229
+ function U(e) {
230
+ const f = {
231
+ r: g(e[0]),
232
+ g: g(e[1]),
233
+ b: g(e[2])
234
+ };
235
+ return j(f);
236
+ }
237
+ function q(e, { lottieInstance: f } = {}) {
238
+ const r = [];
239
+ return !e || !e.layers || e.layers.forEach((t, n) => {
240
+ !t.nm || !t.ef || t.ef.forEach((o, s) => {
241
+ var b, h, w;
242
+ const c = (w = (h = (b = o == null ? void 0 : o.ef) == null ? void 0 : b[0]) == null ? void 0 : h.v) == null ? void 0 : w.k;
243
+ if (c === void 0)
244
+ return;
245
+ let i;
246
+ f ? i = `renderer.elements.${n}.effectsManager.effectElements.${s}.effectElements.0.p.v` : i = `layers.${n}.ef.${s}.ef.0.v.k`;
247
+ let l;
248
+ if (o.mn === "ADBE Color Control" ? l = "color" : o.mn === "ADBE Slider Control" ? l = "slider" : o.mn === "ADBE Point Control" ? l = "point" : o.mn === "ADBE Checkbox Control" ? l = "checkbox" : o.mn.startsWith("Pseudo/") && (l = "feature"), !l)
249
+ return;
250
+ const u = o.nm.toLowerCase();
251
+ r.push({
252
+ name: u,
253
+ path: i,
254
+ value: c,
255
+ type: l
256
+ });
257
+ });
258
+ }), r;
259
+ }
260
+ function W(e, f) {
261
+ for (const r of f)
262
+ a(e, r.path, r.value);
263
+ }
264
+ function x(e, f, r) {
265
+ for (const t of f)
266
+ t.type === "color" ? typeof r == "object" && "r" in r && "g" in r && "b" in r ? a(e, t.path, [d(r.r), d(r.g), d(r.b)]) : Array.isArray(r) ? a(e, t.path, r) : typeof r == "string" && a(e, t.path, $(y(r))) : t.type === "point" ? typeof r == "object" && "x" in r && "y" in r ? (a(e, t.path + ".0", r.x), a(e, t.path + ".1", r.y)) : Array.isArray(r) && (a(e, t.path + ".0", r[0]), a(e, t.path + ".1", r[1])) : a(e, t.path, r);
267
+ }
268
+ function p(e, f) {
269
+ const r = [];
270
+ for (const t of Object.keys(e)) {
271
+ const n = e[t];
272
+ m(n) && r.push(...p(n, f));
273
+ }
274
+ return e.x && typeof e.x == "string" && e.x.includes(f) && r.push(e), r;
275
+ }
276
+ function E(e, f, r) {
277
+ const t = A(r);
278
+ if (!t)
279
+ return;
280
+ const n = f.map((o) => o.name);
281
+ if (n.includes("stroke-layers")) {
282
+ const o = {
283
+ 1: p(e, "effect('stroke-layers')('Menu') == 1"),
284
+ 2: p(e, "effect('stroke-layers')('Menu') == 2"),
285
+ 3: p(e, "effect('stroke-layers')('Menu') == 3")
286
+ };
287
+ for (const s of [1, 2, 3])
288
+ for (const c of o[s])
289
+ s == t ? c.k = 100 : c.k = 0;
290
+ } else if (n.includes("stroke")) {
291
+ const o = /\$bm_div\(value,[ ]{0,}([0-9]+)\)/gm, s = f.filter((i) => i.name === "stroke")[0], c = p(e, "effect('stroke')('Menu')");
292
+ for (const i of c) {
293
+ const l = s && s.value ? t / s.value : t;
294
+ if (m(i.k) && Array.isArray(i.k))
295
+ for (const u of i.k)
296
+ Array.isArray(u.s) && (u.s = u.s.map((b) => b * l));
297
+ else
298
+ i.k = i.k * l;
299
+ i.x = i.x.replace(o, `$bm_div(value, ${t})`);
300
+ }
301
+ }
302
+ for (const o of f)
303
+ (o.name === "stroke" || o.name === "stroke-layers") && x(e, [o], t);
304
+ }
305
+ function L(e, f, r) {
306
+ for (const t of Object.keys(r)) {
307
+ const n = y(r[t]), o = p(e, `effect('${t}')('Color')`);
308
+ for (const s of o)
309
+ s.k = [...$(n), 1];
310
+ for (const s of f)
311
+ s.name === t && x(e, [s], n);
312
+ }
313
+ }
314
+ function P(e, f, r) {
315
+ const t = C(r);
316
+ if (t)
317
+ for (const n of e.markers || []) {
318
+ const [o, s] = n.cm.split(":"), c = s || o;
319
+ n.cm = c, c === t && (n.cm = `default:${c}`, e.ip = n.tm, e.op = n.tm + n.dr);
320
+ }
321
+ }
322
+ function M(e, f, r) {
323
+ const t = C(r);
324
+ if (!t)
325
+ return;
326
+ const n = (e.markers || []).map((s) => {
327
+ const [c, i] = s.cm.split(":");
328
+ return i || c;
329
+ });
330
+ t && e.markers && (e.markers = e.markers.filter((s) => {
331
+ const [c, i] = s.cm.split(":");
332
+ return (i || c) === t;
333
+ }));
334
+ for (const s of ["assets", "layers"])
335
+ e[s] = e[s].filter((c) => {
336
+ const [i, l] = c.nm.split(":"), u = l || i;
337
+ return n.includes(u) ? u === t : !0;
338
+ });
339
+ const o = e.ip;
340
+ e.ip = 0, e.op = e.op - o;
341
+ for (const s of e.markers || [])
342
+ s.tm = s.tm - o;
343
+ for (const s of e.layers || [])
344
+ s.ip >= o && (s.ip = s.ip - o, s.st = s.st - o, s.op = s.op - o);
345
+ }
346
+ function T(e, f, r) {
347
+ const t = A(r);
348
+ if (!t)
349
+ return;
350
+ const n = {
351
+ 1: "light",
352
+ 2: "regular",
353
+ 3: "bold"
354
+ };
355
+ for (const o of ["assets", "layers"])
356
+ e[o] = e[o].filter((s) => {
357
+ const [c, i] = s.nm.split(":");
358
+ return !(i && t && c != n[t]);
359
+ });
360
+ for (const o of f)
361
+ o.name === "stroke" || o.name;
362
+ }
363
+ function K(e, f, r) {
364
+ const t = q(e), n = S(e);
365
+ return f.stroke && E(n, t, f.stroke), f.colors && L(n, t, f.colors), f.state && P(n, t, f.state), (r === "partial" || r === "full") && f.stroke && T(n, t, f.stroke), r === "full" && f.state && M(n, t, f.state), n;
366
+ }
367
+ function D(e) {
368
+ return !e || !e.markers || !Array.isArray(e.markers) ? [] : e.markers.map((f) => {
369
+ const [r, t] = f.cm.split(":");
370
+ return {
371
+ time: f.tm,
372
+ duration: f.dr,
373
+ name: t || r,
374
+ default: !!(t && r.includes("default"))
375
+ };
376
+ });
377
+ }
378
+ export {
379
+ K as customizeIcon,
380
+ S as deepClone,
381
+ q as extractLottieProperties,
382
+ R as get,
383
+ H as has,
384
+ B as hexToRgb,
385
+ $ as hexToTupleColor,
386
+ _ as isNil,
387
+ m as isObjectLike,
388
+ y as parseColor,
389
+ z as parseColors,
390
+ C as parseState,
391
+ A as parseStroke,
392
+ D as readStates,
393
+ W as resetLottieProperties,
394
+ j as rgbToHex,
395
+ a as set,
396
+ U as tupleColorToHex,
397
+ x as updateLottieProperties
398
+ };
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Icon data in JSON format.
3
+ */
4
+ export type LottieData = any;
5
+ /**
6
+ * AnimationItem from `@lordicon/internal`.
7
+ */
8
+ export type LottieAnimation = any;
9
+ /**
10
+ * Supported property types.
11
+ */
12
+ export type LottiePropertyType = 'color' | 'slider' | 'point' | 'checkbox' | 'feature';
13
+ /**
14
+ * Interface for found property.
15
+ */
16
+ export interface LottieProperty {
17
+ name: string;
18
+ path: string;
19
+ type: LottiePropertyType;
20
+ value: any;
21
+ }
22
+ /**
23
+ * Supported stroke values.
24
+ */
25
+ export type Stroke = 1 | 2 | 3 | 'light' | 'regular' | 'bold';
26
+ /**
27
+ * Type for RGB color in Lottie format.
28
+ */
29
+ export type RGBTuple = [number, number, number];
30
+ /**
31
+ * Interface for colors parameters.
32
+ */
33
+ export interface RGBColor {
34
+ r: number;
35
+ g: number;
36
+ b: number;
37
+ }
38
+ /**
39
+ * Interface for the object that stores multiple colors.
40
+ *
41
+ * Example:
42
+ * ```js
43
+ * {
44
+ * primary: 'red',
45
+ * secondary: '#ff0000',
46
+ * }
47
+ * ```
48
+ */
49
+ export interface ColorsMap {
50
+ [key: string]: string;
51
+ }
52
+ /**
53
+ * Interface for icon properties.
54
+ *
55
+ * Example:
56
+ * ```js
57
+ * {
58
+ * stroke: 'bold',
59
+ * colors: {
60
+ * primary: 'red',
61
+ * },
62
+ * }
63
+ * ```
64
+ */
65
+ export interface IconProperties {
66
+ /**
67
+ * State (motion type) of the icon. States allow switching between multiple animations built into a single icon file.
68
+ */
69
+ state?: string;
70
+ /**
71
+ * Colors.
72
+ */
73
+ colors?: ColorsMap;
74
+ /**
75
+ * Stroke.
76
+ */
77
+ stroke?: Stroke;
78
+ }
79
+ /**
80
+ * Animation state details.
81
+ */
82
+ export interface IconState {
83
+ name: string;
84
+ time: number;
85
+ duration: number;
86
+ default?: boolean;
87
+ }
@@ -0,0 +1,47 @@
1
+ import { LottieAnimation, LottieProperty, RGBColor, LottieData, RGBTuple } from './interfaces';
2
+ /**
3
+ * Convert from color object to hex value.
4
+ * @param value - Color object containing r, g, b properties.
5
+ * @returns Hexadecimal string representation of the color.
6
+ */
7
+ export declare function rgbToHex(value: RGBColor): string;
8
+ /**
9
+ * Conver from hex to color object.
10
+ * @param hex - Hexadecimal string representation of the color.
11
+ * @returns RGBColor object containing r, g, b properties.
12
+ */
13
+ export declare function hexToRgb(hex: string): RGBColor;
14
+ /**
15
+ * Convert hex color to tuple color representation.
16
+ * @param hex - Hexadecimal string representation of the color.
17
+ * @returns RGBTuple representing the color in the range of 0 to 1.
18
+ */
19
+ export declare function hexToTupleColor(hex: string): RGBTuple;
20
+ /**
21
+ * Convert tuple color to hex representation.
22
+ * @param value RGBTuple representing the color in the range of 0 to 1.
23
+ * @returns Hexadecimal string representation of the color.
24
+ */
25
+ export declare function tupleColorToHex(value: RGBTuple): string;
26
+ /**
27
+ * Return all supported customizable properties.
28
+ * @param data Icon data.
29
+ * @param options Options.
30
+ * @returns Array of LottieProperty objects.
31
+ */
32
+ export declare function extractLottieProperties(data: LottieData, { lottieInstance }?: {
33
+ lottieInstance?: boolean;
34
+ }): LottieProperty[];
35
+ /**
36
+ * Reset data to default values by indicated properties.
37
+ * @param data Lottie data or animation to reset.
38
+ * @param properties Array of properties to reset.
39
+ */
40
+ export declare function resetLottieProperties(data: LottieData | LottieAnimation, properties: LottieProperty[]): void;
41
+ /**
42
+ * Update data to value by indicated properties.
43
+ * @param data Lottie data or animation to update.
44
+ * @param properties Array of properties to update.
45
+ * @param value New value to set.
46
+ */
47
+ export declare function updateLottieProperties(data: LottieData | LottieAnimation, properties: LottieProperty[], value: any): void;
@@ -0,0 +1,37 @@
1
+ import { ColorsMap } from './interfaces.js';
2
+ /**
3
+ * Return hex color from name.
4
+ *
5
+ * Example:
6
+ * ```js
7
+ * parseColor('red'); // #ff0000
8
+ * ```
9
+ *
10
+ * @param colorName Color name.
11
+ * @returns Hexadecimal color string.
12
+ */
13
+ export declare function parseColor(colorName: string): string;
14
+ /**
15
+ * Parse colors attribute.
16
+ *
17
+ * Example:
18
+ * ```js
19
+ * parseColors('primary:red,secondary:#00ff00'); // { primary: '#ff0000', secondary: '#00ff00' }
20
+ * ```
21
+ *
22
+ * @param colors Colors definied in string.
23
+ * @returns Object with colors.
24
+ */
25
+ export declare function parseColors(colors: string): ColorsMap | undefined;
26
+ /**
27
+ * Parse stroke attribute to supported range.
28
+ * @param value Stroke value.
29
+ * @returns Stroke value in the range of 1 to 3, or undefined if not valid.
30
+ */
31
+ export declare function parseStroke(value: string | number): (1 | 2 | 3 | undefined);
32
+ /**
33
+ * Parse state attribute.
34
+ * @param value State value.
35
+ * @returns Returns the state as a string if valid, otherwise undefined.
36
+ */
37
+ export declare function parseState(value: any): (string | undefined);
@@ -0,0 +1,7 @@
1
+ import { IconState, LottieData } from './interfaces.js';
2
+ /**
3
+ * Read states from lottie data.
4
+ * @param data Lottie data to read states from.
5
+ * @returns Array of icon states extracted from the data.
6
+ */
7
+ export declare function readStates(data: LottieData): IconState[];
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@lordicon/utils-lottie",
3
+ "version": "0.9.4",
4
+ "author": "Marcin Baszczewski <marcin@baszczewski.pl> (https://www.baszczewski.pl/)",
5
+ "homepage": "https://lordicon.com/",
6
+ "repository": "https://github.com/lordicondev/utils-lottie",
7
+ "license": "MIT",
8
+ "private": false,
9
+ "sideEffects": false,
10
+ "type": "module",
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "files": [
14
+ "dist/**/*",
15
+ "README.md"
16
+ ],
17
+ "keywords": [
18
+ "lordicon",
19
+ "lottie"
20
+ ],
21
+ "scripts": {
22
+ "start": "vite --config vite-examples.config.ts",
23
+ "build": "vite build",
24
+ "prepack": "npm run build",
25
+ "test": "vitest"
26
+ },
27
+ "dependencies": {},
28
+ "devDependencies": {
29
+ "@lordicon/internal": "^0.2.0",
30
+ "@types/node": "^22.9.0",
31
+ "typescript": "~5.6.2",
32
+ "vite": "^6.2.3",
33
+ "vite-plugin-dts": "^4.5.4",
34
+ "vitest": "^3.2.3"
35
+ },
36
+ "engines": {
37
+ "node": ">=20.0.0"
38
+ }
39
+ }