@lordicon/utils-lottie 0.9.4 → 0.9.6
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 +2 -2
- package/dist/index.js +158 -133
- package/dist/interfaces.d.ts +6 -5
- package/dist/lottie.d.ts +36 -28
- package/dist/parsers.d.ts +16 -13
- package/dist/{helpers.d.ts → utils.d.ts} +5 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { deepClone, get, has, isNil, isObjectLike, set } from './helpers';
|
|
2
1
|
export { customizeIcon } from './icon';
|
|
3
2
|
export * from './interfaces';
|
|
4
|
-
export { extractLottieProperties, hexToRgb, hexToTupleColor, resetLottieProperties, rgbToHex, tupleColorToHex, updateLottieProperties } from './lottie';
|
|
3
|
+
export { extractLottieProperties, hexToRgb, hexToTupleColor, remapColors, resetLottieProperties, rgbToHex, tupleColorToHex, updateLottieProperties } from './lottie';
|
|
5
4
|
export { parseColor, parseColors, parseState, parseStroke } from './parsers';
|
|
6
5
|
export { readStates } from './states';
|
|
6
|
+
export { deepClone, get, has, isNil, isObjectLike, set } from './utils';
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,3 @@
|
|
|
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
1
|
const O = {
|
|
37
2
|
aliceblue: "#f0f8ff",
|
|
38
3
|
antiquewhite: "#faebd7",
|
|
@@ -176,16 +141,16 @@ const O = {
|
|
|
176
141
|
yellow: "#ffff00",
|
|
177
142
|
yellowgreen: "#9acd32"
|
|
178
143
|
};
|
|
179
|
-
function
|
|
144
|
+
function h(e) {
|
|
180
145
|
return e.startsWith("#") ? e.length === 4 ? `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}` : e : O[e.toLowerCase()] || "#000000";
|
|
181
146
|
}
|
|
182
|
-
function
|
|
147
|
+
function U(e) {
|
|
183
148
|
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
|
|
185
|
-
return r[
|
|
149
|
+
const o = t[0];
|
|
150
|
+
return r[o.toLowerCase()] = h(t[1]), r;
|
|
186
151
|
}, {});
|
|
187
152
|
}
|
|
188
|
-
function
|
|
153
|
+
function C(e) {
|
|
189
154
|
if (e === "light" || e === 1 || e === "1")
|
|
190
155
|
return 1;
|
|
191
156
|
if (e === "regular" || e === 2 || e === "2")
|
|
@@ -193,10 +158,45 @@ function A(e) {
|
|
|
193
158
|
if (e === "bold" || e === 3 || e === "3")
|
|
194
159
|
return 3;
|
|
195
160
|
}
|
|
196
|
-
function
|
|
161
|
+
function $(e) {
|
|
197
162
|
if (typeof e == "string")
|
|
198
163
|
return e;
|
|
199
164
|
}
|
|
165
|
+
function j(e) {
|
|
166
|
+
return structuredClone(e);
|
|
167
|
+
}
|
|
168
|
+
function H(e) {
|
|
169
|
+
return e == null;
|
|
170
|
+
}
|
|
171
|
+
function m(e) {
|
|
172
|
+
return e !== null && typeof e == "object";
|
|
173
|
+
}
|
|
174
|
+
function z(e, f) {
|
|
175
|
+
const r = Array.isArray(f) ? f : f.split(".");
|
|
176
|
+
let t = e;
|
|
177
|
+
for (const o of r) {
|
|
178
|
+
if (!m(t) || !(o in t))
|
|
179
|
+
return !1;
|
|
180
|
+
t = t[o];
|
|
181
|
+
}
|
|
182
|
+
return !0;
|
|
183
|
+
}
|
|
184
|
+
function F(e, f, r) {
|
|
185
|
+
const t = Array.isArray(f) ? f : f.split(".");
|
|
186
|
+
let o = e;
|
|
187
|
+
for (const n of t) {
|
|
188
|
+
if (!m(o) || !(n in o))
|
|
189
|
+
return r;
|
|
190
|
+
o = o[n];
|
|
191
|
+
}
|
|
192
|
+
return o === void 0 ? r : o;
|
|
193
|
+
}
|
|
194
|
+
function a(e, f, r) {
|
|
195
|
+
let t = e;
|
|
196
|
+
const o = Array.isArray(f) ? f : f.split(".");
|
|
197
|
+
for (let n = 0; n < o.length; ++n)
|
|
198
|
+
n === o.length - 1 ? t[o[n]] = r : t = t[o[n]];
|
|
199
|
+
}
|
|
200
200
|
function k(e) {
|
|
201
201
|
const f = e.toString(16);
|
|
202
202
|
return f.length == 1 ? "0" + f : f;
|
|
@@ -207,10 +207,10 @@ function d(e) {
|
|
|
207
207
|
function g(e) {
|
|
208
208
|
return Math.round(e * 255);
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function E(e) {
|
|
211
211
|
return "#" + k(e.r) + k(e.g) + k(e.b);
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function P(e) {
|
|
214
214
|
let f = parseInt(e[0] != "#" ? e : e.substring(1), 16);
|
|
215
215
|
return {
|
|
216
216
|
r: f >> 16 & 255,
|
|
@@ -218,40 +218,40 @@ function B(e) {
|
|
|
218
218
|
b: f & 255
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function y(e) {
|
|
222
222
|
const {
|
|
223
223
|
r: f,
|
|
224
224
|
g: r,
|
|
225
225
|
b: t
|
|
226
|
-
} =
|
|
226
|
+
} = P(e);
|
|
227
227
|
return [d(f), d(r), d(t)];
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function T(e) {
|
|
230
230
|
const f = {
|
|
231
231
|
r: g(e[0]),
|
|
232
232
|
g: g(e[1]),
|
|
233
233
|
b: g(e[2])
|
|
234
234
|
};
|
|
235
|
-
return
|
|
235
|
+
return E(f);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function S(e, { lottieInstance: f } = {}) {
|
|
238
238
|
const r = [];
|
|
239
|
-
return !e || !e.layers || e.layers.forEach((t,
|
|
240
|
-
!t.nm || !t.ef || t.ef.forEach((
|
|
241
|
-
var b,
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
239
|
+
return !e || !e.layers || e.layers.forEach((t, o) => {
|
|
240
|
+
!t.nm || !t.ef || t.ef.forEach((n, s) => {
|
|
241
|
+
var b, w, A;
|
|
242
|
+
const i = (A = (w = (b = n == null ? void 0 : n.ef) == null ? void 0 : b[0]) == null ? void 0 : w.v) == null ? void 0 : A.k;
|
|
243
|
+
if (i === void 0)
|
|
244
244
|
return;
|
|
245
|
-
let
|
|
246
|
-
f ?
|
|
245
|
+
let c;
|
|
246
|
+
f ? c = `renderer.elements.${o}.effectsManager.effectElements.${s}.effectElements.0.p.v` : c = `layers.${o}.ef.${s}.ef.0.v.k`;
|
|
247
247
|
let l;
|
|
248
|
-
if (
|
|
248
|
+
if (n.mn === "ADBE Color Control" ? l = "color" : n.mn === "ADBE Slider Control" ? l = "slider" : n.mn === "ADBE Point Control" ? l = "point" : n.mn === "ADBE Checkbox Control" ? l = "checkbox" : n.mn.startsWith("Pseudo/") && (l = "feature"), !l)
|
|
249
249
|
return;
|
|
250
|
-
const u =
|
|
250
|
+
const u = n.nm.toLowerCase();
|
|
251
251
|
r.push({
|
|
252
252
|
name: u,
|
|
253
|
-
path:
|
|
254
|
-
value:
|
|
253
|
+
path: c,
|
|
254
|
+
value: i,
|
|
255
255
|
type: l
|
|
256
256
|
});
|
|
257
257
|
});
|
|
@@ -263,136 +263,161 @@ function W(e, f) {
|
|
|
263
263
|
}
|
|
264
264
|
function x(e, f, r) {
|
|
265
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,
|
|
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(h(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 v(e, f) {
|
|
269
|
+
if (Object.keys(f).length > 0) {
|
|
270
|
+
const t = S(e).filter((o) => o.type === "color");
|
|
271
|
+
for (const o of t) {
|
|
272
|
+
const n = T(o.value);
|
|
273
|
+
for (const [s, i] of Object.entries(f))
|
|
274
|
+
n === s && a(e, o.path, y(i));
|
|
275
|
+
}
|
|
276
|
+
return e;
|
|
277
|
+
} else
|
|
278
|
+
return e;
|
|
267
279
|
}
|
|
268
280
|
function p(e, f) {
|
|
269
281
|
const r = [];
|
|
270
282
|
for (const t of Object.keys(e)) {
|
|
271
|
-
const
|
|
272
|
-
m(
|
|
283
|
+
const o = e[t];
|
|
284
|
+
m(o) && r.push(...p(o, f));
|
|
273
285
|
}
|
|
274
286
|
return e.x && typeof e.x == "string" && e.x.includes(f) && r.push(e), r;
|
|
275
287
|
}
|
|
276
|
-
function
|
|
277
|
-
const t =
|
|
288
|
+
function q(e, f, r) {
|
|
289
|
+
const t = C(r);
|
|
278
290
|
if (!t)
|
|
279
291
|
return;
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
282
|
-
const
|
|
292
|
+
const o = f.map((n) => n.name);
|
|
293
|
+
if (o.includes("stroke-layers")) {
|
|
294
|
+
const n = {
|
|
283
295
|
1: p(e, "effect('stroke-layers')('Menu') == 1"),
|
|
284
296
|
2: p(e, "effect('stroke-layers')('Menu') == 2"),
|
|
285
297
|
3: p(e, "effect('stroke-layers')('Menu') == 3")
|
|
286
298
|
};
|
|
287
299
|
for (const s of [1, 2, 3])
|
|
288
|
-
for (const
|
|
289
|
-
s == t ?
|
|
290
|
-
} else if (
|
|
291
|
-
const
|
|
292
|
-
for (const
|
|
300
|
+
for (const i of n[s])
|
|
301
|
+
s == t ? i.k = 100 : i.k = 0;
|
|
302
|
+
} else if (o.includes("stroke")) {
|
|
303
|
+
const n = /\$bm_div\(value,[ ]{0,}([0-9]+)\)/gm, s = f.filter((c) => c.name === "stroke")[0], i = p(e, "effect('stroke')('Menu')");
|
|
304
|
+
for (const c of i) {
|
|
293
305
|
const l = s && s.value ? t / s.value : t;
|
|
294
|
-
if (m(
|
|
295
|
-
for (const u of
|
|
306
|
+
if (m(c.k) && Array.isArray(c.k))
|
|
307
|
+
for (const u of c.k)
|
|
296
308
|
Array.isArray(u.s) && (u.s = u.s.map((b) => b * l));
|
|
297
309
|
else
|
|
298
|
-
|
|
299
|
-
|
|
310
|
+
c.k = c.k * l;
|
|
311
|
+
c.x = c.x.replace(n, `$bm_div(value, ${t})`);
|
|
300
312
|
}
|
|
301
313
|
}
|
|
302
|
-
for (const
|
|
303
|
-
(
|
|
314
|
+
for (const n of f)
|
|
315
|
+
(n.name === "stroke" || n.name === "stroke-layers") && x(e, [n], t);
|
|
304
316
|
}
|
|
305
|
-
function
|
|
317
|
+
function B(e, f, r) {
|
|
306
318
|
for (const t of Object.keys(r)) {
|
|
307
|
-
const
|
|
308
|
-
for (const s of
|
|
309
|
-
s.k = [
|
|
319
|
+
const o = h(r[t]), n = p(e, `effect('${t}')('Color')`);
|
|
320
|
+
for (const s of n)
|
|
321
|
+
s.k = [...y(o), 1];
|
|
310
322
|
for (const s of f)
|
|
311
|
-
s.name === t && x(e, [s],
|
|
323
|
+
s.name === t && x(e, [s], o);
|
|
312
324
|
}
|
|
313
325
|
}
|
|
314
|
-
function
|
|
315
|
-
const t =
|
|
326
|
+
function L(e, f, r) {
|
|
327
|
+
const t = $(r);
|
|
316
328
|
if (t)
|
|
317
|
-
for (const
|
|
318
|
-
const [
|
|
319
|
-
|
|
329
|
+
for (const o of e.markers || []) {
|
|
330
|
+
const [n, s] = o.cm.split(":"), i = s || n;
|
|
331
|
+
o.cm = i, i === t && (o.cm = `default:${i}`, e.ip = o.tm, e.op = o.tm + o.dr);
|
|
320
332
|
}
|
|
321
333
|
}
|
|
322
334
|
function M(e, f, r) {
|
|
323
|
-
const t =
|
|
335
|
+
const t = $(r);
|
|
324
336
|
if (!t)
|
|
325
337
|
return;
|
|
326
|
-
const
|
|
327
|
-
const [
|
|
328
|
-
return
|
|
338
|
+
const o = (e.markers || []).map((s) => {
|
|
339
|
+
const [i, c] = s.cm.split(":");
|
|
340
|
+
return c || i;
|
|
329
341
|
});
|
|
330
342
|
t && e.markers && (e.markers = e.markers.filter((s) => {
|
|
331
|
-
const [
|
|
332
|
-
return (
|
|
343
|
+
const [i, c] = s.cm.split(":");
|
|
344
|
+
return (c || i) === t;
|
|
333
345
|
}));
|
|
334
346
|
for (const s of ["assets", "layers"])
|
|
335
|
-
e[s] = e[s].filter((
|
|
336
|
-
const [
|
|
337
|
-
return
|
|
347
|
+
e[s] = e[s].filter((i) => {
|
|
348
|
+
const [c, l] = i.nm.split(":"), u = l || c;
|
|
349
|
+
return o.includes(u) ? u === t : !0;
|
|
338
350
|
});
|
|
339
|
-
const
|
|
340
|
-
e.ip = 0, e.op = e.op -
|
|
351
|
+
const n = e.ip;
|
|
352
|
+
e.ip = 0, e.op = e.op - n;
|
|
341
353
|
for (const s of e.markers || [])
|
|
342
|
-
s.tm = s.tm -
|
|
354
|
+
s.tm = s.tm - n;
|
|
343
355
|
for (const s of e.layers || [])
|
|
344
|
-
s.ip >=
|
|
356
|
+
s.ip >= n && (s.ip = s.ip - n, s.st = s.st - n, s.op = s.op - n);
|
|
345
357
|
}
|
|
346
|
-
function
|
|
347
|
-
const t =
|
|
358
|
+
function _(e, f, r) {
|
|
359
|
+
const t = C(r);
|
|
348
360
|
if (!t)
|
|
349
361
|
return;
|
|
350
|
-
const
|
|
362
|
+
const o = {
|
|
351
363
|
1: "light",
|
|
352
364
|
2: "regular",
|
|
353
365
|
3: "bold"
|
|
354
366
|
};
|
|
355
|
-
for (const
|
|
356
|
-
e[
|
|
357
|
-
const [
|
|
358
|
-
return !(
|
|
367
|
+
for (const n of ["assets", "layers"])
|
|
368
|
+
e[n] = e[n].filter((s) => {
|
|
369
|
+
const [i, c] = s.nm.split(":");
|
|
370
|
+
return !(c && t && i != o[t]);
|
|
359
371
|
});
|
|
360
|
-
for (const
|
|
361
|
-
|
|
372
|
+
for (const n of f)
|
|
373
|
+
n.name === "stroke" || n.name;
|
|
362
374
|
}
|
|
363
|
-
function
|
|
364
|
-
const t =
|
|
365
|
-
return f.stroke &&
|
|
375
|
+
function D(e, f, r) {
|
|
376
|
+
const t = S(e), o = j(e);
|
|
377
|
+
return f.stroke && q(o, t, f.stroke), f.colors && B(o, t, f.colors), f.state && L(o, t, f.state), (r === "partial" || r === "full") && f.stroke && _(o, t, f.stroke), r === "full" && f.state && M(o, t, f.state), o;
|
|
366
378
|
}
|
|
367
|
-
|
|
379
|
+
const R = ["default"];
|
|
380
|
+
function G(e) {
|
|
368
381
|
return !e || !e.markers || !Array.isArray(e.markers) ? [] : e.markers.map((f) => {
|
|
369
|
-
const
|
|
370
|
-
return {
|
|
382
|
+
const r = f.cm.split(":"), t = {
|
|
371
383
|
time: f.tm,
|
|
372
384
|
duration: f.dr,
|
|
373
|
-
name:
|
|
374
|
-
default:
|
|
385
|
+
name: "",
|
|
386
|
+
default: !1,
|
|
387
|
+
params: []
|
|
375
388
|
};
|
|
389
|
+
for (; R.includes(r[0]); ) {
|
|
390
|
+
switch (r[0]) {
|
|
391
|
+
case "default":
|
|
392
|
+
t.default = !0;
|
|
393
|
+
break;
|
|
394
|
+
default:
|
|
395
|
+
throw new Error(`Unsupported state flag: ${r[0]}`);
|
|
396
|
+
}
|
|
397
|
+
r.shift();
|
|
398
|
+
}
|
|
399
|
+
return t.name = r[0], t.params = r.slice(1, r.length), t;
|
|
376
400
|
});
|
|
377
401
|
}
|
|
378
402
|
export {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
403
|
+
D as customizeIcon,
|
|
404
|
+
j as deepClone,
|
|
405
|
+
S as extractLottieProperties,
|
|
406
|
+
F as get,
|
|
407
|
+
z as has,
|
|
408
|
+
P as hexToRgb,
|
|
409
|
+
y as hexToTupleColor,
|
|
410
|
+
H as isNil,
|
|
387
411
|
m as isObjectLike,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
412
|
+
h as parseColor,
|
|
413
|
+
U as parseColors,
|
|
414
|
+
$ as parseState,
|
|
415
|
+
C as parseStroke,
|
|
416
|
+
G as readStates,
|
|
417
|
+
v as remapColors,
|
|
393
418
|
W as resetLottieProperties,
|
|
394
|
-
|
|
419
|
+
E as rgbToHex,
|
|
395
420
|
a as set,
|
|
396
|
-
|
|
421
|
+
T as tupleColorToHex,
|
|
397
422
|
x as updateLottieProperties
|
|
398
423
|
};
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type LottieData = any;
|
|
|
5
5
|
/**
|
|
6
6
|
* AnimationItem from `@lordicon/internal`.
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
8
|
+
export type LottieAnimationInstance = any;
|
|
9
9
|
/**
|
|
10
10
|
* Supported property types.
|
|
11
11
|
*/
|
|
@@ -26,11 +26,11 @@ export type Stroke = 1 | 2 | 3 | 'light' | 'regular' | 'bold';
|
|
|
26
26
|
/**
|
|
27
27
|
* Type for RGB color in Lottie format.
|
|
28
28
|
*/
|
|
29
|
-
export type
|
|
29
|
+
export type RgbTuple = [number, number, number];
|
|
30
30
|
/**
|
|
31
31
|
* Interface for colors parameters.
|
|
32
32
|
*/
|
|
33
|
-
export interface
|
|
33
|
+
export interface RgbColor {
|
|
34
34
|
r: number;
|
|
35
35
|
g: number;
|
|
36
36
|
b: number;
|
|
@@ -46,7 +46,7 @@ export interface RGBColor {
|
|
|
46
46
|
* }
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
|
-
export interface
|
|
49
|
+
export interface ColorMap {
|
|
50
50
|
[key: string]: string;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
@@ -70,7 +70,7 @@ export interface IconProperties {
|
|
|
70
70
|
/**
|
|
71
71
|
* Colors.
|
|
72
72
|
*/
|
|
73
|
-
colors?:
|
|
73
|
+
colors?: ColorMap;
|
|
74
74
|
/**
|
|
75
75
|
* Stroke.
|
|
76
76
|
*/
|
|
@@ -83,5 +83,6 @@ export interface IconState {
|
|
|
83
83
|
name: string;
|
|
84
84
|
time: number;
|
|
85
85
|
duration: number;
|
|
86
|
+
params: string[];
|
|
86
87
|
default?: boolean;
|
|
87
88
|
}
|
package/dist/lottie.d.ts
CHANGED
|
@@ -1,47 +1,55 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorMap, LottieAnimationInstance, LottieData, LottieProperty, RgbColor, RgbTuple } from './interfaces';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param value
|
|
5
|
-
* @returns Hexadecimal string
|
|
3
|
+
* Converts an RGB color object to a hexadecimal color string.
|
|
4
|
+
* @param value Color object with r, g, b properties.
|
|
5
|
+
* @returns Hexadecimal color string (e.g., "#ff0000").
|
|
6
6
|
*/
|
|
7
|
-
export declare function rgbToHex(value:
|
|
7
|
+
export declare function rgbToHex(value: RgbColor): string;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param hex
|
|
11
|
-
* @returns
|
|
9
|
+
* Converts a hexadecimal color string to an RGB color object.
|
|
10
|
+
* @param hex Hexadecimal color string (with or without "#").
|
|
11
|
+
* @returns RgbColor object with r, g, b properties.
|
|
12
12
|
*/
|
|
13
|
-
export declare function hexToRgb(hex: string):
|
|
13
|
+
export declare function hexToRgb(hex: string): RgbColor;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @param hex
|
|
17
|
-
* @returns
|
|
15
|
+
* Converts a hexadecimal color string to an RGB tuple in the 0-1 range.
|
|
16
|
+
* @param hex Hexadecimal color string.
|
|
17
|
+
* @returns RgbTuple with values normalized to 0-1.
|
|
18
18
|
*/
|
|
19
|
-
export declare function hexToTupleColor(hex: string):
|
|
19
|
+
export declare function hexToTupleColor(hex: string): RgbTuple;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param value
|
|
23
|
-
* @returns Hexadecimal string
|
|
21
|
+
* Converts an RGB tuple (0-1 range) to a hexadecimal color string.
|
|
22
|
+
* @param value RgbTuple with values in the 0-1 range.
|
|
23
|
+
* @returns Hexadecimal color string.
|
|
24
24
|
*/
|
|
25
|
-
export declare function tupleColorToHex(value:
|
|
25
|
+
export declare function tupleColorToHex(value: RgbTuple): string;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @param data
|
|
29
|
-
* @param options
|
|
30
|
-
* @returns Array of LottieProperty objects.
|
|
27
|
+
* Extracts all supported customizable properties from Lottie data.
|
|
28
|
+
* @param data Lottie animation data.
|
|
29
|
+
* @param options Extraction options (e.g., lottieInstance: boolean).
|
|
30
|
+
* @returns Array of LottieProperty objects describing customizable properties.
|
|
31
31
|
*/
|
|
32
32
|
export declare function extractLottieProperties(data: LottieData, { lottieInstance }?: {
|
|
33
33
|
lottieInstance?: boolean;
|
|
34
34
|
}): LottieProperty[];
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @param data Lottie data or animation to reset.
|
|
36
|
+
* Resets Lottie data or animation instance to default values for the given properties.
|
|
37
|
+
* @param data Lottie data or animation instance to reset.
|
|
38
38
|
* @param properties Array of properties to reset.
|
|
39
39
|
*/
|
|
40
|
-
export declare function resetLottieProperties(data: LottieData |
|
|
40
|
+
export declare function resetLottieProperties(data: LottieData | LottieAnimationInstance, properties: LottieProperty[]): void;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Updates Lottie data or animation instance with a new value for the given properties.
|
|
43
|
+
* Handles color, point, and other property types accordingly.
|
|
44
|
+
* @param data Lottie data or animation instance to update.
|
|
44
45
|
* @param properties Array of properties to update.
|
|
45
|
-
* @param value New value to set.
|
|
46
|
+
* @param value New value to set for each property.
|
|
46
47
|
*/
|
|
47
|
-
export declare function updateLottieProperties(data: LottieData |
|
|
48
|
+
export declare function updateLottieProperties(data: LottieData | LottieAnimationInstance, properties: LottieProperty[], value: any): void;
|
|
49
|
+
/**
|
|
50
|
+
* Remaps colors in Lottie data according to the provided color map.
|
|
51
|
+
* @param data Lottie data to remap colors in.
|
|
52
|
+
* @param colors Color map where keys are original colors in hex format and values are new colors in hex format.
|
|
53
|
+
* @returns Lottie data with colors remapped according to the provided color map.
|
|
54
|
+
*/
|
|
55
|
+
export declare function remapColors(data: LottieData, colors: ColorMap): LottieData;
|
package/dist/parsers.d.ts
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColorMap } from './interfaces.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Returns a hexadecimal color string for a given color name or hex code.
|
|
4
4
|
*
|
|
5
5
|
* Example:
|
|
6
6
|
* ```js
|
|
7
|
-
* parseColor('red'); // #ff0000
|
|
7
|
+
* parseColor('red'); // "#ff0000"
|
|
8
|
+
* parseColor('#0f0'); // "#00ff00"
|
|
8
9
|
* ```
|
|
9
10
|
*
|
|
10
|
-
* @param colorName Color name.
|
|
11
|
-
* @returns Hexadecimal color string.
|
|
11
|
+
* @param colorName Color name (e.g., "red") or hex string (e.g., "#ff0000" or "#0f0").
|
|
12
|
+
* @returns Hexadecimal color string in the format "#rrggbb".
|
|
12
13
|
*/
|
|
13
14
|
export declare function parseColor(colorName: string): string;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Parses a colors attribute string into a ColorMap object.
|
|
16
17
|
*
|
|
17
18
|
* Example:
|
|
18
19
|
* ```js
|
|
19
|
-
* parseColors('primary:red,secondary:#00ff00');
|
|
20
|
+
* parseColors('primary:red,secondary:#00ff00');
|
|
21
|
+
* // Returns: { primary: '#ff0000', secondary: '#00ff00' }
|
|
20
22
|
* ```
|
|
21
23
|
*
|
|
22
|
-
* @param colors Colors
|
|
23
|
-
* @returns Object
|
|
24
|
+
* @param colors Colors defined as a comma-separated string (e.g., "primary:red,secondary:#00ff00").
|
|
25
|
+
* @returns Object mapping color names to hex strings, or undefined if input is invalid.
|
|
24
26
|
*/
|
|
25
|
-
export declare function parseColors(colors: string):
|
|
27
|
+
export declare function parseColors(colors: string): ColorMap | undefined;
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
29
|
+
* Parses a stroke attribute value to a supported numeric range.
|
|
30
|
+
*
|
|
31
|
+
* @param value Stroke value as a string or number ("light", 1, "1", "regular", 2, "2", "bold", 3, "3").
|
|
32
|
+
* @returns Stroke value as 1, 2, or 3, or undefined if not valid.
|
|
30
33
|
*/
|
|
31
34
|
export declare function parseStroke(value: string | number): (1 | 2 | 3 | undefined);
|
|
32
35
|
/**
|
|
@@ -22,10 +22,12 @@ export declare function isObjectLike(value: any): value is object;
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function has<T>(object: T, path: string | string[]): boolean;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Retrieves the value at the given path from the object.
|
|
26
|
+
* Returns defaultValue if the path does not exist.
|
|
26
27
|
* @param object Object to get value from.
|
|
27
|
-
* @param path
|
|
28
|
-
* @param defaultValue
|
|
28
|
+
* @param path Property path as a dot-separated string or array of keys.
|
|
29
|
+
* @param defaultValue Value to return if the path does not exist.
|
|
30
|
+
* @returns Value at the given path or defaultValue.
|
|
29
31
|
*/
|
|
30
32
|
export declare function get<T>(object: T, path: string | string[], defaultValue?: any): any;
|
|
31
33
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lordicon/utils-lottie",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"author": "Marcin Baszczewski <marcin@baszczewski.pl> (https://www.baszczewski.pl/)",
|
|
5
5
|
"homepage": "https://lordicon.com/",
|
|
6
6
|
"repository": "https://github.com/lordicondev/utils-lottie",
|