@lordicon/utils-lottie 1.2.0 → 1.3.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 +1 -1
- package/dist/index.js +56 -52
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { customizeIcon } from './icon';
|
|
2
2
|
export * from './interfaces';
|
|
3
|
-
export { extractLottieProperties, hexToRgb, hexToTupleColor, remapColors, resetLottieProperties, rgbToHex, tupleColorToHex, updateLottieProperties } from './lottie';
|
|
3
|
+
export { extractLottieProperties, hexToRgb, hexToTupleColor, remapColors, removeExpressions, resetLottieProperties, rgbToHex, tupleColorToHex, updateLottieProperties } from './lottie';
|
|
4
4
|
export { parseColor, parseColors, parseState, parseStroke } from './parsers';
|
|
5
5
|
export { readStates } from './states';
|
|
6
6
|
export { deepClone, get, has, isNil, isObjectLike, set } from './utils';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const S = {
|
|
2
2
|
aliceblue: "#f0f8ff",
|
|
3
3
|
antiquewhite: "#faebd7",
|
|
4
4
|
aqua: "#00ffff",
|
|
@@ -142,15 +142,15 @@ const O = {
|
|
|
142
142
|
yellowgreen: "#9acd32"
|
|
143
143
|
};
|
|
144
144
|
function h(e) {
|
|
145
|
-
return e.startsWith("#") ? e.length === 4 ? `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}` : e :
|
|
145
|
+
return e.startsWith("#") ? e.length === 4 ? `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}` : e : S[e.toLowerCase()] || "#000000";
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function v(e) {
|
|
148
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) => {
|
|
149
149
|
const o = t[0];
|
|
150
150
|
return r[o.toLowerCase()] = h(t[1]), r;
|
|
151
151
|
}, {});
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function x(e) {
|
|
154
154
|
if (e === "light" || e === 1 || e === "1")
|
|
155
155
|
return 1;
|
|
156
156
|
if (e === "regular" || e === 2 || e === "2")
|
|
@@ -158,11 +158,11 @@ function C(e) {
|
|
|
158
158
|
if (e === "bold" || e === 3 || e === "3")
|
|
159
159
|
return 3;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function j(e) {
|
|
162
162
|
if (typeof e == "string")
|
|
163
163
|
return e;
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function $(e) {
|
|
166
166
|
return structuredClone(e);
|
|
167
167
|
}
|
|
168
168
|
function H(e) {
|
|
@@ -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 P(e) {
|
|
211
211
|
return "#" + k(e.r) + k(e.g) + k(e.b);
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function T(e) {
|
|
214
214
|
let f = parseInt(e[0] != "#" ? e : e.substring(1), 16);
|
|
215
215
|
return {
|
|
216
216
|
r: f >> 16 & 255,
|
|
@@ -218,28 +218,28 @@ function P(e) {
|
|
|
218
218
|
b: f & 255
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function w(e) {
|
|
222
222
|
const {
|
|
223
223
|
r: f,
|
|
224
224
|
g: r,
|
|
225
225
|
b: t
|
|
226
|
-
} =
|
|
226
|
+
} = T(e);
|
|
227
227
|
return [d(f), d(r), d(t)];
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function q(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 P(f);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function E(e, { lottieInstance: f } = {}) {
|
|
238
238
|
const r = [];
|
|
239
239
|
return !e || !e.layers || e.layers.forEach((t, o) => {
|
|
240
240
|
!t.nm || !t.ef || t.ef.forEach((n, s) => {
|
|
241
|
-
var b,
|
|
242
|
-
const c = (
|
|
241
|
+
var b, A, C;
|
|
242
|
+
const c = (C = (A = (b = n == null ? void 0 : n.ef) == null ? void 0 : b[0]) == null ? void 0 : A.v) == null ? void 0 : C.k;
|
|
243
243
|
if (c === void 0)
|
|
244
244
|
return;
|
|
245
245
|
let i;
|
|
@@ -261,22 +261,25 @@ function W(e, f) {
|
|
|
261
261
|
for (const r of f)
|
|
262
262
|
a(e, r.path, r.value);
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function O(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, w(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
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function D(e, f) {
|
|
269
269
|
if (Object.keys(f).length > 0) {
|
|
270
|
-
const t =
|
|
270
|
+
const t = E(e).filter((o) => o.type === "color");
|
|
271
271
|
for (const o of t) {
|
|
272
|
-
const n =
|
|
272
|
+
const n = q(o.value);
|
|
273
273
|
for (const [s, c] of Object.entries(f))
|
|
274
|
-
n === s && a(e, o.path,
|
|
274
|
+
n === s && a(e, o.path, w(c));
|
|
275
275
|
}
|
|
276
276
|
return e;
|
|
277
277
|
} else
|
|
278
278
|
return e;
|
|
279
279
|
}
|
|
280
|
+
function y(e) {
|
|
281
|
+
Array.isArray(e) ? e.forEach(y) : e && typeof e == "object" && ("x" in e && typeof e.x == "string" && delete e.x, Object.values(e).forEach(y));
|
|
282
|
+
}
|
|
280
283
|
function p(e, f) {
|
|
281
284
|
const r = [];
|
|
282
285
|
for (const t of Object.keys(e)) {
|
|
@@ -285,8 +288,8 @@ function p(e, f) {
|
|
|
285
288
|
}
|
|
286
289
|
return e.x && typeof e.x == "string" && e.x.includes(f) && r.push(e), r;
|
|
287
290
|
}
|
|
288
|
-
function
|
|
289
|
-
const t =
|
|
291
|
+
function L(e, f, r) {
|
|
292
|
+
const t = x(r);
|
|
290
293
|
if (!t)
|
|
291
294
|
return;
|
|
292
295
|
const o = f.map((n) => n.name);
|
|
@@ -312,19 +315,19 @@ function q(e, f, r) {
|
|
|
312
315
|
}
|
|
313
316
|
}
|
|
314
317
|
for (const n of f)
|
|
315
|
-
(n.name === "stroke" || n.name === "stroke-layers") &&
|
|
318
|
+
(n.name === "stroke" || n.name === "stroke-layers") && O(e, [n], t);
|
|
316
319
|
}
|
|
317
|
-
function
|
|
320
|
+
function B(e, f, r) {
|
|
318
321
|
for (const t of Object.keys(r)) {
|
|
319
322
|
const o = h(r[t]), n = p(e, `effect('${t}')('Color')`);
|
|
320
323
|
for (const s of n)
|
|
321
|
-
s.k = [...
|
|
324
|
+
s.k = [...w(o), 1];
|
|
322
325
|
for (const s of f)
|
|
323
|
-
s.name === t &&
|
|
326
|
+
s.name === t && O(e, [s], o);
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
|
-
function
|
|
327
|
-
const t =
|
|
329
|
+
function M(e, f, r) {
|
|
330
|
+
const t = j(r);
|
|
328
331
|
if (t)
|
|
329
332
|
for (const o of e.markers || []) {
|
|
330
333
|
const n = o.cm.split(":");
|
|
@@ -337,8 +340,8 @@ function B(e, f, r) {
|
|
|
337
340
|
].join(":"), e.ip = o.tm, e.op = o.tm + o.dr);
|
|
338
341
|
}
|
|
339
342
|
}
|
|
340
|
-
function
|
|
341
|
-
const t =
|
|
343
|
+
function _(e, f, r) {
|
|
344
|
+
const t = j(r);
|
|
342
345
|
if (!t)
|
|
343
346
|
return;
|
|
344
347
|
const o = (e.markers || []).map((s) => {
|
|
@@ -361,8 +364,8 @@ function M(e, f, r) {
|
|
|
361
364
|
for (const s of e.layers || [])
|
|
362
365
|
s.ip >= n && (s.ip = s.ip - n, s.st = s.st - n, s.op = s.op - n);
|
|
363
366
|
}
|
|
364
|
-
function
|
|
365
|
-
const t =
|
|
367
|
+
function R(e, f, r) {
|
|
368
|
+
const t = x(r);
|
|
366
369
|
if (!t)
|
|
367
370
|
return;
|
|
368
371
|
const o = {
|
|
@@ -378,12 +381,12 @@ function _(e, f, r) {
|
|
|
378
381
|
for (const n of f)
|
|
379
382
|
n.name === "stroke" || n.name;
|
|
380
383
|
}
|
|
381
|
-
function
|
|
382
|
-
const t =
|
|
383
|
-
return f.stroke &&
|
|
384
|
+
function G(e, f, r) {
|
|
385
|
+
const t = E(e), o = $(e);
|
|
386
|
+
return f.stroke && L(o, t, f.stroke), f.colors && B(o, t, f.colors), f.state && M(o, t, f.state), (r === "partial" || r === "full") && f.stroke && R(o, t, f.stroke), r === "full" && (f.state && _(o, t, f.state), y(o)), o;
|
|
384
387
|
}
|
|
385
|
-
const
|
|
386
|
-
function
|
|
388
|
+
const U = ["default"];
|
|
389
|
+
function K(e) {
|
|
387
390
|
return !e || !e.markers || !Array.isArray(e.markers) ? [] : e.markers.map((f) => {
|
|
388
391
|
const r = f.cm.split(":"), t = {
|
|
389
392
|
time: f.tm,
|
|
@@ -392,7 +395,7 @@ function G(e) {
|
|
|
392
395
|
default: !1,
|
|
393
396
|
params: []
|
|
394
397
|
};
|
|
395
|
-
for (;
|
|
398
|
+
for (; U.includes(r[0]); ) {
|
|
396
399
|
switch (r[0]) {
|
|
397
400
|
case "default":
|
|
398
401
|
t.default = !0;
|
|
@@ -406,24 +409,25 @@ function G(e) {
|
|
|
406
409
|
});
|
|
407
410
|
}
|
|
408
411
|
export {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
+
G as customizeIcon,
|
|
413
|
+
$ as deepClone,
|
|
414
|
+
E as extractLottieProperties,
|
|
412
415
|
F as get,
|
|
413
416
|
z as has,
|
|
414
|
-
|
|
415
|
-
|
|
417
|
+
T as hexToRgb,
|
|
418
|
+
w as hexToTupleColor,
|
|
416
419
|
H as isNil,
|
|
417
420
|
m as isObjectLike,
|
|
418
421
|
h as parseColor,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
v as parseColors,
|
|
423
|
+
j as parseState,
|
|
424
|
+
x as parseStroke,
|
|
425
|
+
K as readStates,
|
|
426
|
+
D as remapColors,
|
|
427
|
+
y as removeExpressions,
|
|
424
428
|
W as resetLottieProperties,
|
|
425
|
-
|
|
429
|
+
P as rgbToHex,
|
|
426
430
|
a as set,
|
|
427
|
-
|
|
428
|
-
|
|
431
|
+
q as tupleColorToHex,
|
|
432
|
+
O as updateLottieProperties
|
|
429
433
|
};
|