@lordicon/utils-lottie 1.1.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 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 O = {
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 : O[e.toLowerCase()] || "#000000";
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 U(e) {
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 C(e) {
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 S(e) {
161
+ function j(e) {
162
162
  if (typeof e == "string")
163
163
  return e;
164
164
  }
165
- function j(e) {
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 E(e) {
210
+ function P(e) {
211
211
  return "#" + k(e.r) + k(e.g) + k(e.b);
212
212
  }
213
- function P(e) {
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 y(e) {
221
+ function w(e) {
222
222
  const {
223
223
  r: f,
224
224
  g: r,
225
225
  b: t
226
- } = P(e);
226
+ } = T(e);
227
227
  return [d(f), d(r), d(t)];
228
228
  }
229
- function T(e) {
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 E(f);
235
+ return P(f);
236
236
  }
237
- function $(e, { lottieInstance: f } = {}) {
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, w, A;
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;
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 x(e, f, r) {
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, 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);
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 v(e, f) {
268
+ function D(e, f) {
269
269
  if (Object.keys(f).length > 0) {
270
- const t = $(e).filter((o) => o.type === "color");
270
+ const t = E(e).filter((o) => o.type === "color");
271
271
  for (const o of t) {
272
- const n = T(o.value);
272
+ const n = q(o.value);
273
273
  for (const [s, c] of Object.entries(f))
274
- n === s && a(e, o.path, y(c));
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 q(e, f, r) {
289
- const t = C(r);
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") && x(e, [n], t);
318
+ (n.name === "stroke" || n.name === "stroke-layers") && O(e, [n], t);
316
319
  }
317
- function L(e, f, r) {
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 = [...y(o), 1];
324
+ s.k = [...w(o), 1];
322
325
  for (const s of f)
323
- s.name === t && x(e, [s], o);
326
+ s.name === t && O(e, [s], o);
324
327
  }
325
328
  }
326
- function B(e, f, r) {
327
- const t = S(r);
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 M(e, f, r) {
341
- const t = S(r);
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 _(e, f, r) {
365
- const t = C(r);
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 D(e, f, r) {
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;
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 R = ["default"];
386
- function G(e) {
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 (; R.includes(r[0]); ) {
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
- D as customizeIcon,
410
- j as deepClone,
411
- $ as extractLottieProperties,
412
+ G as customizeIcon,
413
+ $ as deepClone,
414
+ E as extractLottieProperties,
412
415
  F as get,
413
416
  z as has,
414
- P as hexToRgb,
415
- y as hexToTupleColor,
417
+ T as hexToRgb,
418
+ w as hexToTupleColor,
416
419
  H as isNil,
417
420
  m as isObjectLike,
418
421
  h as parseColor,
419
- U as parseColors,
420
- S as parseState,
421
- C as parseStroke,
422
- G as readStates,
423
- v as remapColors,
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
- E as rgbToHex,
429
+ P as rgbToHex,
426
430
  a as set,
427
- T as tupleColorToHex,
428
- x as updateLottieProperties
431
+ q as tupleColorToHex,
432
+ O as updateLottieProperties
429
433
  };
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@lordicon/utils-lottie",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "author": "Lordicon <dev@lordicon.com>",
5
5
  "homepage": "https://lordicon.com/",
6
6
  "repository": "https://github.com/lordicondev/utils-lottie",