@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.
@@ -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 $(e) {
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 S(e, { lottieInstance: f } = {}) {
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 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)
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 c;
246
- f ? c = `renderer.elements.${o}.effectsManager.effectElements.${s}.effectElements.0.p.v` : c = `layers.${o}.ef.${s}.ef.0.v.k`;
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: c,
254
- value: i,
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 = S(e).filter((o) => o.type === "color");
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, i] of Object.entries(f))
274
- n === s && a(e, o.path, y(i));
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 i of n[s])
301
- s == t ? i.k = 100 : i.k = 0;
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((c) => c.name === "stroke")[0], i = p(e, "effect('stroke')('Menu')");
304
- for (const c of i) {
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(c.k) && Array.isArray(c.k))
307
- for (const u of c.k)
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
- c.k = c.k * l;
311
- c.x = c.x.replace(n, `$bm_div(value, ${t})`);
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 B(e, f, r) {
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 L(e, f, r) {
327
- const t = $(r);
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 [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);
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 = $(r);
341
+ const t = S(r);
336
342
  if (!t)
337
343
  return;
338
344
  const o = (e.markers || []).map((s) => {
339
- const [i, c] = s.cm.split(":");
340
- return c || i;
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 [i, c] = s.cm.split(":");
344
- return (c || i) === t;
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((i) => {
348
- const [c, l] = i.nm.split(":"), u = l || c;
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 [i, c] = s.nm.split(":");
370
- return !(c && t && i != o[t]);
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 = 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;
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
- S as extractLottieProperties,
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
- $ as parseState,
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": "0.9.6",
4
- "author": "Marcin Baszczewski <marcin@baszczewski.pl> (https://www.baszczewski.pl/)",
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.2.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",