@lordicon/utils-lottie 0.9.6 → 1.2.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/{LICENSE → LICENSE.md} +2 -11
- package/dist/index.js +43 -37
- package/dist/lottie.d.ts +5 -0
- package/package.json +3 -3
package/{LICENSE → LICENSE.md}
RENAMED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
The MIT License
|
|
1
|
+
The MIT License (MIT)
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2025 Lordicon
|
|
4
4
|
|
|
5
|
-
====
|
|
6
|
-
|
|
7
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
9
7
|
in the Software without restriction, including without limitation the rights
|
|
@@ -20,11 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
20
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
20
|
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.
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -158,7 +158,7 @@ function C(e) {
|
|
|
158
158
|
if (e === "bold" || e === 3 || e === "3")
|
|
159
159
|
return 3;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function S(e) {
|
|
162
162
|
if (typeof e == "string")
|
|
163
163
|
return e;
|
|
164
164
|
}
|
|
@@ -234,24 +234,24 @@ function T(e) {
|
|
|
234
234
|
};
|
|
235
235
|
return E(f);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function $(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
241
|
var b, w, A;
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
242
|
+
const c = (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 (c === void 0)
|
|
244
244
|
return;
|
|
245
|
-
let
|
|
246
|
-
f ?
|
|
245
|
+
let i;
|
|
246
|
+
f ? i = `renderer.elements.${o}.effectsManager.effectElements.${s}.effectElements.0.p.v` : i = `layers.${o}.ef.${s}.ef.0.v.k`;
|
|
247
247
|
let l;
|
|
248
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
250
|
const u = n.nm.toLowerCase();
|
|
251
251
|
r.push({
|
|
252
252
|
name: u,
|
|
253
|
-
path:
|
|
254
|
-
value:
|
|
253
|
+
path: i,
|
|
254
|
+
value: c,
|
|
255
255
|
type: l
|
|
256
256
|
});
|
|
257
257
|
});
|
|
@@ -267,11 +267,11 @@ function x(e, f, r) {
|
|
|
267
267
|
}
|
|
268
268
|
function v(e, f) {
|
|
269
269
|
if (Object.keys(f).length > 0) {
|
|
270
|
-
const t =
|
|
270
|
+
const t = $(e).filter((o) => o.type === "color");
|
|
271
271
|
for (const o of t) {
|
|
272
272
|
const n = T(o.value);
|
|
273
|
-
for (const [s,
|
|
274
|
-
n === s && a(e, o.path, y(
|
|
273
|
+
for (const [s, c] of Object.entries(f))
|
|
274
|
+
n === s && a(e, o.path, y(c));
|
|
275
275
|
}
|
|
276
276
|
return e;
|
|
277
277
|
} else
|
|
@@ -297,24 +297,24 @@ function q(e, f, r) {
|
|
|
297
297
|
3: p(e, "effect('stroke-layers')('Menu') == 3")
|
|
298
298
|
};
|
|
299
299
|
for (const s of [1, 2, 3])
|
|
300
|
-
for (const
|
|
301
|
-
s == t ?
|
|
300
|
+
for (const c of n[s])
|
|
301
|
+
s == t ? c.k = 100 : c.k = 0;
|
|
302
302
|
} else if (o.includes("stroke")) {
|
|
303
|
-
const n = /\$bm_div\(value,[ ]{0,}([0-9]+)\)/gm, s = f.filter((
|
|
304
|
-
for (const
|
|
303
|
+
const n = /\$bm_div\(value,[ ]{0,}([0-9]+)\)/gm, s = f.filter((i) => i.name === "stroke")[0], c = p(e, "effect('stroke')('Menu')");
|
|
304
|
+
for (const i of c) {
|
|
305
305
|
const l = s && s.value ? t / s.value : t;
|
|
306
|
-
if (m(
|
|
307
|
-
for (const u of
|
|
306
|
+
if (m(i.k) && Array.isArray(i.k))
|
|
307
|
+
for (const u of i.k)
|
|
308
308
|
Array.isArray(u.s) && (u.s = u.s.map((b) => b * l));
|
|
309
309
|
else
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
i.k = i.k * l;
|
|
311
|
+
i.x = i.x.replace(n, `$bm_div(value, ${t})`);
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
for (const n of f)
|
|
315
315
|
(n.name === "stroke" || n.name === "stroke-layers") && x(e, [n], t);
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function L(e, f, r) {
|
|
318
318
|
for (const t of Object.keys(r)) {
|
|
319
319
|
const o = h(r[t]), n = p(e, `effect('${t}')('Color')`);
|
|
320
320
|
for (const s of n)
|
|
@@ -323,29 +323,35 @@ function B(e, f, r) {
|
|
|
323
323
|
s.name === t && x(e, [s], o);
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
function
|
|
327
|
-
const t =
|
|
326
|
+
function B(e, f, r) {
|
|
327
|
+
const t = S(r);
|
|
328
328
|
if (t)
|
|
329
329
|
for (const o of e.markers || []) {
|
|
330
|
-
const
|
|
331
|
-
|
|
330
|
+
const n = o.cm.split(":");
|
|
331
|
+
n[0] === "default" && n.shift();
|
|
332
|
+
const [s, ...c] = n;
|
|
333
|
+
o.cm = s, s === t && (o.cm = [
|
|
334
|
+
"default",
|
|
335
|
+
s,
|
|
336
|
+
...c
|
|
337
|
+
].join(":"), e.ip = o.tm, e.op = o.tm + o.dr);
|
|
332
338
|
}
|
|
333
339
|
}
|
|
334
340
|
function M(e, f, r) {
|
|
335
|
-
const t =
|
|
341
|
+
const t = S(r);
|
|
336
342
|
if (!t)
|
|
337
343
|
return;
|
|
338
344
|
const o = (e.markers || []).map((s) => {
|
|
339
|
-
const [
|
|
340
|
-
return
|
|
345
|
+
const [c, i] = s.cm.split(":");
|
|
346
|
+
return i || c;
|
|
341
347
|
});
|
|
342
348
|
t && e.markers && (e.markers = e.markers.filter((s) => {
|
|
343
|
-
const [
|
|
344
|
-
return (
|
|
349
|
+
const [c, i] = s.cm.split(":");
|
|
350
|
+
return (i || c) === t;
|
|
345
351
|
}));
|
|
346
352
|
for (const s of ["assets", "layers"])
|
|
347
|
-
e[s] = e[s].filter((
|
|
348
|
-
const [
|
|
353
|
+
e[s] = e[s].filter((c) => {
|
|
354
|
+
const [i, l] = c.nm.split(":"), u = l || i;
|
|
349
355
|
return o.includes(u) ? u === t : !0;
|
|
350
356
|
});
|
|
351
357
|
const n = e.ip;
|
|
@@ -366,15 +372,15 @@ function _(e, f, r) {
|
|
|
366
372
|
};
|
|
367
373
|
for (const n of ["assets", "layers"])
|
|
368
374
|
e[n] = e[n].filter((s) => {
|
|
369
|
-
const [
|
|
370
|
-
return !(
|
|
375
|
+
const [c, i] = s.nm.split(":");
|
|
376
|
+
return !(i && t && c != o[t]);
|
|
371
377
|
});
|
|
372
378
|
for (const n of f)
|
|
373
379
|
n.name === "stroke" || n.name;
|
|
374
380
|
}
|
|
375
381
|
function D(e, f, r) {
|
|
376
|
-
const t =
|
|
377
|
-
return f.stroke && q(o, t, f.stroke), f.colors &&
|
|
382
|
+
const t = $(e), o = j(e);
|
|
383
|
+
return f.stroke && q(o, t, f.stroke), f.colors && L(o, t, f.colors), f.state && B(o, t, f.state), (r === "partial" || r === "full") && f.stroke && _(o, t, f.stroke), r === "full" && f.state && M(o, t, f.state), o;
|
|
378
384
|
}
|
|
379
385
|
const R = ["default"];
|
|
380
386
|
function G(e) {
|
|
@@ -402,7 +408,7 @@ function G(e) {
|
|
|
402
408
|
export {
|
|
403
409
|
D as customizeIcon,
|
|
404
410
|
j as deepClone,
|
|
405
|
-
|
|
411
|
+
$ as extractLottieProperties,
|
|
406
412
|
F as get,
|
|
407
413
|
z as has,
|
|
408
414
|
P as hexToRgb,
|
|
@@ -411,7 +417,7 @@ export {
|
|
|
411
417
|
m as isObjectLike,
|
|
412
418
|
h as parseColor,
|
|
413
419
|
U as parseColors,
|
|
414
|
-
|
|
420
|
+
S as parseState,
|
|
415
421
|
C as parseStroke,
|
|
416
422
|
G as readStates,
|
|
417
423
|
v as remapColors,
|
package/dist/lottie.d.ts
CHANGED
|
@@ -53,3 +53,8 @@ export declare function updateLottieProperties(data: LottieData | LottieAnimatio
|
|
|
53
53
|
* @returns Lottie data with colors remapped according to the provided color map.
|
|
54
54
|
*/
|
|
55
55
|
export declare function remapColors(data: LottieData, colors: ColorMap): LottieData;
|
|
56
|
+
/**
|
|
57
|
+
* Recursively removes expressions from Lottie data by deleting "x" properties that contain expressions.
|
|
58
|
+
* @param data Lottie data to remove expressions from.
|
|
59
|
+
*/
|
|
60
|
+
export declare function removeExpressions(data: LottieData): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lordicon/utils-lottie",
|
|
3
|
-
"version": "
|
|
4
|
-
"author": "
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"author": "Lordicon <dev@lordicon.com>",
|
|
5
5
|
"homepage": "https://lordicon.com/",
|
|
6
6
|
"repository": "https://github.com/lordicondev/utils-lottie",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@lordicon/internal": "^0.
|
|
29
|
+
"@lordicon/internal": "^0.5.0",
|
|
30
30
|
"@types/node": "^22.9.0",
|
|
31
31
|
"typescript": "~5.6.2",
|
|
32
32
|
"vite": "^6.2.3",
|