@cuemath/leap 3.2.23-mb → 3.2.25-mb

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.
@@ -0,0 +1,19 @@
1
+ const o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
2
+ async function r(t) {
3
+ if (o.has(t))
4
+ return o.get(t);
5
+ if (n.has(t))
6
+ return n.get(t);
7
+ const i = fetch(t).then(async (e) => {
8
+ if (!e.ok) return null;
9
+ const a = t.endsWith(".lottie") ? await e.arrayBuffer() : await e.json();
10
+ return o.set(t, a), a;
11
+ }).catch((e) => (console.error("Lottie preload error:", e), null)).finally(() => {
12
+ n.delete(t);
13
+ });
14
+ return n.set(t, i), i;
15
+ }
16
+ export {
17
+ r as preloadLottieFile
18
+ };
19
+ //# sourceMappingURL=stickers-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stickers-cache.js","sources":["../../../../src/features/stickers/stickers-effects/stickers-cache.ts"],"sourcesContent":["import type { Data } from '@lottiefiles/dotlottie-web';\n\nconst lottieCache = new Map<string, Data>();\nconst lottiePromises = new Map<string, Promise<Data | null>>();\n\nexport async function preloadLottieFile(url: string): Promise<Data | null> {\n if (lottieCache.has(url)) {\n return lottieCache.get(url)!;\n }\n\n if (lottiePromises.has(url)) {\n return lottiePromises.get(url)!;\n }\n\n const fetchPromise = fetch(url)\n .then(async res => {\n if (!res.ok) return null;\n\n const isLottieFile = url.endsWith('.lottie');\n const data = isLottieFile ? await res.arrayBuffer() : await res.json();\n\n lottieCache.set(url, data);\n\n return data;\n })\n .catch(err => {\n // eslint-disable-next-line no-console\n console.error('Lottie preload error:', err);\n\n return null;\n })\n .finally(() => {\n lottiePromises.delete(url);\n });\n\n lottiePromises.set(url, fetchPromise);\n\n return fetchPromise;\n}\n"],"names":["lottieCache","lottiePromises","preloadLottieFile","url","fetchPromise","res","data","err"],"mappings":"AAEA,MAAMA,wBAAkB,OAClBC,wBAAqB;AAE3B,eAAsBC,EAAkBC,GAAmC;AACrE,MAAAH,EAAY,IAAIG,CAAG;AACd,WAAAH,EAAY,IAAIG,CAAG;AAGxB,MAAAF,EAAe,IAAIE,CAAG;AACjB,WAAAF,EAAe,IAAIE,CAAG;AAG/B,QAAMC,IAAe,MAAMD,CAAG,EAC3B,KAAK,OAAME,MAAO;AACb,QAAA,CAACA,EAAI,GAAW,QAAA;AAGd,UAAAC,IADeH,EAAI,SAAS,SAAS,IACf,MAAME,EAAI,gBAAgB,MAAMA,EAAI;AAEpD,WAAAL,EAAA,IAAIG,GAAKG,CAAI,GAElBA;AAAA,EAAA,CACR,EACA,MAAM,CAAOC,OAEJ,QAAA,MAAM,yBAAyBA,CAAG,GAEnC,KACR,EACA,QAAQ,MAAM;AACb,IAAAN,EAAe,OAAOE,CAAG;AAAA,EAAA,CAC1B;AAEY,SAAAF,EAAA,IAAIE,GAAKC,CAAY,GAE7BA;AACT;"}
@@ -1,43 +1,54 @@
1
- import { jsx as o, Fragment as D } from "react/jsx-runtime";
2
- import { memo as f, useState as l, useEffect as E } from "react";
3
- import g from "../../ui/lottie-animation/lottie-animation.js";
4
- import { generateStickerData as F } from "./stickers-effects-helper.js";
5
- import { Container as z, Sticker as T } from "./stickers-effects-styled.js";
6
- const $ = f(({ lottie: t, sticker: e, size: r }) => {
7
- const [i, s] = l(!1);
8
- return !t || i ? /* @__PURE__ */ o(D, { children: e }) : /* @__PURE__ */ o(g, { src: t, width: r, height: r, onError: () => s(!0) });
9
- }), b = ({ stickers: t, effect: e, count: r, duration: i }) => {
10
- const [s, a] = l([]);
11
- return E(() => {
12
- const c = F({
13
- count: r,
14
- effect: e,
1
+ import { jsx as s, Fragment as E } from "react/jsx-runtime";
2
+ import { memo as u, useState as f, useEffect as d } from "react";
3
+ import F from "../../ui/dot-lottie-animations/dot-lottie-animation.js";
4
+ import { preloadLottieFile as g } from "./stickers-cache.js";
5
+ import { generateStickerData as z } from "./stickers-effects-helper.js";
6
+ import { Container as L, Sticker as T } from "./stickers-effects-styled.js";
7
+ const $ = u(({ url: t, sticker: o, size: a }) => {
8
+ const [i, m] = f(), [n, e] = f(!1);
9
+ return d(() => {
10
+ let r = !0;
11
+ if (t)
12
+ return g(t).then((c) => {
13
+ r && (c ? m(c) : e(!0));
14
+ }).catch(() => {
15
+ r && e(!0);
16
+ }), () => {
17
+ r = !1;
18
+ };
19
+ }, [t]), !t || n || !i ? /* @__PURE__ */ s(E, { children: o }) : /* @__PURE__ */ s(F, { data: i, width: a, height: a, onError: () => e(!0) });
20
+ }), b = ({ stickers: t, effect: o, count: a, duration: i }) => {
21
+ const [m, n] = f([]);
22
+ return d(() => {
23
+ const e = z({
24
+ count: a,
25
+ effect: o,
15
26
  stickers: t,
16
27
  minSize: 32,
17
28
  maxSize: 48
18
29
  });
19
- a(c);
20
- const m = setTimeout(() => a([]), i);
21
- return () => clearTimeout(m);
22
- }, [t, e, r, i]), /* @__PURE__ */ o(z, { children: s.map((c, m) => {
23
- const { id: k, sticker: u, lottie: S, x: h, y: p, size: n, fromX: d, fromY: x } = c;
24
- return /* @__PURE__ */ o(
30
+ n(e);
31
+ const r = setTimeout(() => n([]), i);
32
+ return () => clearTimeout(r);
33
+ }, [t, o, a, i]), /* @__PURE__ */ s(L, { children: m.map((e, r) => {
34
+ const { id: c, sticker: h, lottie: k, x: p, y: S, size: l, fromX: D, fromY: x } = e;
35
+ return /* @__PURE__ */ s(
25
36
  T,
26
37
  {
27
- effect: e,
38
+ effect: o,
28
39
  duration: i,
29
- fromX: d,
40
+ fromX: D,
30
41
  fromY: x,
31
- x: h,
32
- y: p,
33
- size: n,
34
- children: /* @__PURE__ */ o($, { lottie: S, sticker: u, size: n })
42
+ x: p,
43
+ y: S,
44
+ size: l,
45
+ children: /* @__PURE__ */ s($, { url: k, sticker: h, size: l })
35
46
  },
36
- `${k}-${m}`
47
+ `${c}-${r}`
37
48
  );
38
49
  }) });
39
- }, L = f(b);
50
+ }, W = u(b);
40
51
  export {
41
- L as default
52
+ W as default
42
53
  };
43
54
  //# sourceMappingURL=stickers-effects.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stickers-effects.js","sources":["../../../../src/features/stickers/stickers-effects/stickers-effects.tsx"],"sourcesContent":["import type { TStickerData, IStickersProps } from './stickers-effects-types';\n\nimport React, { memo, useEffect, useState } from 'react';\n\nimport LottieAnimation from '../../ui/lottie-animation/lottie-animation';\nimport { generateStickerData } from './stickers-effects-helper';\nimport * as S from './stickers-effects-styled';\n\nconst StickerWithFallback: React.FC<{\n lottie?: string;\n sticker: string;\n size: number;\n}> = memo(({ lottie, sticker, size }) => {\n const [failed, setFailed] = useState(false);\n\n if (!lottie || failed) return <>{sticker}</>;\n\n return (\n <LottieAnimation src={lottie} width={size} height={size} onError={() => setFailed(true)} />\n );\n});\n\nconst StickersEffects: React.FC<IStickersProps> = ({ stickers, effect, count, duration }) => {\n const [stickersData, setStickersData] = useState<ReturnType<typeof generateStickerData>>([]);\n\n useEffect(() => {\n const stickerData = generateStickerData({\n count,\n effect,\n stickers,\n minSize: 32,\n maxSize: 48,\n });\n\n setStickersData(stickerData);\n\n const timeout = setTimeout(() => setStickersData([]), duration);\n\n return () => clearTimeout(timeout);\n }, [stickers, effect, count, duration]);\n\n return (\n <S.Container>\n {stickersData.map((data: TStickerData, i) => {\n const { id, sticker, lottie, x, y, size, fromX, fromY } = data;\n\n return (\n <S.Sticker\n key={`${id}-${i}`}\n effect={effect}\n duration={duration}\n fromX={fromX}\n fromY={fromY}\n x={x}\n y={y}\n size={size}\n >\n <StickerWithFallback lottie={lottie} sticker={sticker} size={size} />\n </S.Sticker>\n );\n })}\n </S.Container>\n );\n};\n\nexport default memo(StickersEffects);\n"],"names":["StickerWithFallback","memo","lottie","sticker","size","failed","setFailed","useState","jsx","LottieAnimation","StickersEffects","stickers","effect","count","duration","stickersData","setStickersData","useEffect","stickerData","generateStickerData","timeout","S.Container","data","i","id","x","y","fromX","fromY","S.Sticker","stickersEffects"],"mappings":";;;;;AAQA,MAAMA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AAAC,GAAY;AAAA,MAAA;AAAA,MAT9D,GAAGoB,CAAE,IAAID,CAAC;AAAA,IAAA;AAAA,EAYpB,CAAA,EACH,CAAA;AAEJ,GAEeO,IAAA7B,EAAKS,CAAe;"}
1
+ {"version":3,"file":"stickers-effects.js","sources":["../../../../src/features/stickers/stickers-effects/stickers-effects.tsx"],"sourcesContent":["import type { TStickerData, IStickersProps } from './stickers-effects-types';\nimport type { Data } from '@lottiefiles/dotlottie-web';\n\nimport React, { memo, useEffect, useState } from 'react';\n\nimport DotLottieAnimation from '../../ui/dot-lottie-animations/dot-lottie-animation';\nimport { preloadLottieFile } from './stickers-cache';\nimport { generateStickerData } from './stickers-effects-helper';\nimport * as S from './stickers-effects-styled';\n\nconst StickerWithFallback: React.FC<{\n url?: string;\n sticker: string;\n size: number;\n}> = memo(({ url, sticker, size }) => {\n const [data, setData] = useState<Data>();\n const [failed, setFailed] = useState(false);\n\n useEffect(() => {\n let isMounted = true;\n\n if (!url) return;\n\n preloadLottieFile(url)\n .then(result => {\n if (isMounted) {\n if (result) {\n setData(result);\n } else {\n setFailed(true);\n }\n }\n })\n .catch(() => {\n if (isMounted) setFailed(true);\n });\n\n return () => {\n isMounted = false;\n };\n }, [url]);\n\n if (!url || failed || !data) {\n return <>{sticker}</>;\n }\n\n return (\n <DotLottieAnimation data={data} width={size} height={size} onError={() => setFailed(true)} />\n );\n});\n\nconst StickersEffects: React.FC<IStickersProps> = ({ stickers, effect, count, duration }) => {\n const [stickersData, setStickersData] = useState<ReturnType<typeof generateStickerData>>([]);\n\n useEffect(() => {\n const stickerData = generateStickerData({\n count,\n effect,\n stickers,\n minSize: 32,\n maxSize: 48,\n });\n\n setStickersData(stickerData);\n\n const timeout = setTimeout(() => setStickersData([]), duration);\n\n return () => clearTimeout(timeout);\n }, [stickers, effect, count, duration]);\n\n return (\n <S.Container>\n {stickersData.map((data: TStickerData, i) => {\n const { id, sticker, lottie, x, y, size, fromX, fromY } = data;\n\n return (\n <S.Sticker\n key={`${id}-${i}`}\n effect={effect}\n duration={duration}\n fromX={fromX}\n fromY={fromY}\n x={x}\n y={y}\n size={size}\n >\n <StickerWithFallback url={lottie} sticker={sticker} size={size} />\n </S.Sticker>\n );\n })}\n </S.Container>\n );\n};\n\nexport default memo(StickersEffects);\n"],"names":["StickerWithFallback","memo","url","sticker","size","data","setData","useState","failed","setFailed","useEffect","isMounted","preloadLottieFile","result","jsx","DotLottieAnimation","StickersEffects","stickers","effect","count","duration","stickersData","setStickersData","stickerData","generateStickerData","timeout","S.Container","i","id","lottie","x","y","fromX","fromY","S.Sticker","stickersEffects"],"mappings":";;;;;;AAUA,MAAMA,IAIDC,EAAK,CAAC,EAAE,KAAAC,GAAK,SAAAC,GAAS,MAAAC,QAAW;AACpC,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAe,GACjC,CAACC,GAAQC,CAAS,IAAIF,EAAS,EAAK;AA0B1C,SAxBAG,EAAU,MAAM;AACd,QAAIC,IAAY;AAEhB,QAAKT;AAEa,aAAAU,EAAAV,CAAG,EAClB,KAAK,CAAUW,MAAA;AACd,QAAIF,MACEE,IACFP,EAAQO,CAAM,IAEdJ,EAAU,EAAI;AAAA,MAElB,CACD,EACA,MAAM,MAAM;AACP,QAAAE,OAAqB,EAAI;AAAA,MAAA,CAC9B,GAEI,MAAM;AACC,QAAAA,IAAA;AAAA,MAAA;AAAA,EACd,GACC,CAACT,CAAG,CAAC,GAEJ,CAACA,KAAOM,KAAU,CAACH,2BACX,UAAQF,EAAA,CAAA,IAIlB,gBAAAW,EAACC,GAAmB,EAAA,MAAAV,GAAY,OAAOD,GAAM,QAAQA,GAAM,SAAS,MAAMK,EAAU,EAAI,EAAG,CAAA;AAE/F,CAAC,GAEKO,IAA4C,CAAC,EAAE,UAAAC,GAAU,QAAAC,GAAQ,OAAAC,GAAO,UAAAC,QAAe;AAC3F,QAAM,CAACC,GAAcC,CAAe,IAAIf,EAAiD,CAAE,CAAA;AAE3F,SAAAG,EAAU,MAAM;AACd,UAAMa,IAAcC,EAAoB;AAAA,MACtC,OAAAL;AAAA,MACA,QAAAD;AAAA,MACA,UAAAD;AAAA,MACA,SAAS;AAAA,MACT,SAAS;AAAA,IAAA,CACV;AAED,IAAAK,EAAgBC,CAAW;AAE3B,UAAME,IAAU,WAAW,MAAMH,EAAgB,CAAE,CAAA,GAAGF,CAAQ;AAEvD,WAAA,MAAM,aAAaK,CAAO;AAAA,KAChC,CAACR,GAAUC,GAAQC,GAAOC,CAAQ,CAAC,GAGpC,gBAAAN,EAACY,GAAA,EACE,YAAa,IAAI,CAACrB,GAAoBsB,MAAM;AACrC,UAAA,EAAE,IAAAC,GAAI,SAAAzB,GAAS,QAAA0B,GAAQ,GAAAC,GAAG,GAAAC,GAAG,MAAA3B,GAAM,OAAA4B,GAAO,OAAAC,EAAU,IAAA5B;AAGxD,WAAA,gBAAAS;AAAA,MAACoB;AAAAA,MAAA;AAAA,QAEC,QAAAhB;AAAA,QACA,UAAAE;AAAA,QACA,OAAAY;AAAA,QACA,OAAAC;AAAA,QACA,GAAAH;AAAA,QACA,GAAAC;AAAA,QACA,MAAA3B;AAAA,QAEA,UAAC,gBAAAU,EAAAd,GAAA,EAAoB,KAAK6B,GAAQ,SAAA1B,GAAkB,MAAAC,GAAY;AAAA,MAAA;AAAA,MAT3D,GAAGwB,CAAE,IAAID,CAAC;AAAA,IAAA;AAAA,EAYpB,CAAA,EACH,CAAA;AAEJ,GAEeQ,IAAAlC,EAAKe,CAAe;"}
@@ -0,0 +1,9 @@
1
+ import p from "styled-components";
2
+ const a = p.canvas`
3
+ ${({ $renderWidth: o }) => typeof o == "number" ? `width: ${o}px;` : `width: ${o};`}
4
+ ${({ $renderHeight: o }) => typeof o == "number" ? `height: ${o}px;` : `height: ${o};`}
5
+ `;
6
+ export {
7
+ a as Canvas
8
+ };
9
+ //# sourceMappingURL=dot-lottie-animation-styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dot-lottie-animation-styled.js","sources":["../../../../src/features/ui/dot-lottie-animations/dot-lottie-animation-styled.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const Canvas = styled.canvas<{\n $renderWidth: string | number;\n $renderHeight: string | number;\n}>`\n ${({ $renderWidth }) =>\n typeof $renderWidth === 'number' ? `width: ${$renderWidth}px;` : `width: ${$renderWidth};`}\n ${({ $renderHeight }) =>\n typeof $renderHeight === 'number' ? `height: ${$renderHeight}px;` : `height: ${$renderHeight};`}\n`;\n"],"names":["Canvas","styled","$renderWidth","$renderHeight"],"mappings":";AAEO,MAAMA,IAASC,EAAO;AAAA,IAIzB,CAAC,EAAE,cAAAC,EAAa,MAChB,OAAOA,KAAiB,WAAW,UAAUA,CAAY,QAAQ,UAAUA,CAAY,GAAG;AAAA,IAC1F,CAAC,EAAE,eAAAC,EAAc,MACjB,OAAOA,KAAkB,WAAW,WAAWA,CAAa,QAAQ,WAAWA,CAAa,GAAG;AAAA;"}
@@ -0,0 +1,93 @@
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { DotLottieWorker as v } from "../../../node_modules/@lottiefiles/dotlottie-web/dist/index.js";
3
+ import { memo as w, forwardRef as x, useRef as p, useImperativeHandle as A, useEffect as h } from "react";
4
+ import R from "../layout/flex-view.js";
5
+ import { Canvas as $ } from "./dot-lottie-animation-styled.js";
6
+ const E = x(
7
+ (y, g) => {
8
+ const {
9
+ src: s,
10
+ data: f,
11
+ width: i = "100%",
12
+ height: a = "100%",
13
+ settings: l,
14
+ eventListeners: o,
15
+ onRender: u,
16
+ onError: c
17
+ } = y, m = p(null), t = p(null);
18
+ return A(
19
+ g,
20
+ () => ({
21
+ play: () => {
22
+ var e;
23
+ (e = t.current) == null || e.play();
24
+ },
25
+ pause: () => {
26
+ var e;
27
+ (e = t.current) == null || e.pause();
28
+ },
29
+ playSegments: (e) => {
30
+ var r, n;
31
+ (r = t.current) == null || r.setSegment(e[0], e[1]), (n = t.current) == null || n.play();
32
+ },
33
+ setFrame: (e) => {
34
+ var r;
35
+ (r = t.current) == null || r.setFrame(e);
36
+ }
37
+ }),
38
+ []
39
+ ), h(() => {
40
+ if (!m.current) return;
41
+ let e = !1;
42
+ return (() => {
43
+ try {
44
+ t.current = new v({
45
+ src: s,
46
+ data: f,
47
+ canvas: m.current,
48
+ autoplay: !0,
49
+ loop: !1,
50
+ renderConfig: {
51
+ autoResize: !0,
52
+ devicePixelRatio: window.devicePixelRatio,
53
+ freezeOnOffscreen: !0
54
+ },
55
+ ...l
56
+ }), requestAnimationFrame(() => {
57
+ e || u == null || u();
58
+ });
59
+ } catch (n) {
60
+ console.log(n), c == null || c();
61
+ }
62
+ })(), () => {
63
+ e = !0, t.current && (t.current.destroy(), t.current = null);
64
+ };
65
+ }, [s, l, u, c, f]), h(() => (o == null || o.forEach(
66
+ ({ name: e, callback: r }) => {
67
+ var n;
68
+ return (n = t.current) == null ? void 0 : n.addEventListener(e, r);
69
+ }
70
+ ), () => {
71
+ o == null || o.forEach(
72
+ ({ name: e, callback: r }) => {
73
+ var n;
74
+ return (n = t.current) == null ? void 0 : n.removeEventListener(e, r);
75
+ }
76
+ );
77
+ }), [o]), /* @__PURE__ */ d(R, { $width: i, $height: a, children: /* @__PURE__ */ d(
78
+ $,
79
+ {
80
+ ref: m,
81
+ $renderWidth: i,
82
+ $renderHeight: a,
83
+ width: typeof i == "number" ? i : void 0,
84
+ height: typeof a == "number" ? a : void 0
85
+ },
86
+ s
87
+ ) });
88
+ }
89
+ ), C = w(E);
90
+ export {
91
+ C as default
92
+ };
93
+ //# sourceMappingURL=dot-lottie-animation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dot-lottie-animation.js","sources":["../../../../src/features/ui/dot-lottie-animations/dot-lottie-animation.tsx"],"sourcesContent":["import type {\n AnimationSegment,\n IDotLottieAnimationProps,\n IDotLottieAnimationRef,\n} from './dot-lottie-types';\n\nimport { DotLottieWorker } from '@lottiefiles/dotlottie-web';\nimport { forwardRef, memo, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport FlexView from '../layout/flex-view';\nimport * as Styled from './dot-lottie-animation-styled';\n\nconst DotLottieAnimation = forwardRef<IDotLottieAnimationRef, IDotLottieAnimationProps>(\n (props, ref) => {\n const {\n src,\n data,\n width = '100%',\n height = '100%',\n settings,\n eventListeners,\n onRender,\n onError,\n } = props;\n\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const animationInstance = useRef<DotLottieWorker | null>(null);\n\n useImperativeHandle(\n ref,\n () => ({\n play: () => {\n animationInstance.current?.play();\n },\n pause: () => {\n animationInstance.current?.pause();\n },\n playSegments: (segments: AnimationSegment) => {\n animationInstance.current?.setSegment(segments[0], segments[1]);\n animationInstance.current?.play();\n },\n setFrame: (frame: number) => {\n animationInstance.current?.setFrame(frame);\n },\n }),\n [],\n );\n\n useEffect(() => {\n if (!canvasRef.current) return;\n\n let destroyed = false;\n\n const loadAnimation = () => {\n try {\n animationInstance.current = new DotLottieWorker({\n src,\n data,\n canvas: canvasRef.current!,\n autoplay: true,\n loop: false,\n renderConfig: {\n autoResize: true,\n devicePixelRatio: window.devicePixelRatio,\n freezeOnOffscreen: true,\n },\n ...settings,\n });\n\n requestAnimationFrame(() => {\n if (destroyed) return;\n onRender?.();\n });\n } catch (err) {\n // eslint-disable-next-line no-console\n console.log(err);\n onError?.();\n }\n };\n\n loadAnimation();\n\n return () => {\n destroyed = true;\n if (animationInstance.current) {\n animationInstance.current.destroy();\n animationInstance.current = null;\n }\n };\n }, [src, settings, onRender, onError, data]);\n\n useEffect(() => {\n eventListeners?.forEach(\n ({ name, callback }) => animationInstance.current?.addEventListener(name, callback),\n );\n\n return () => {\n eventListeners?.forEach(\n ({ name, callback }) => animationInstance.current?.removeEventListener(name, callback),\n );\n };\n }, [eventListeners]);\n\n const isNumW = typeof width === 'number';\n const isNumH = typeof height === 'number';\n\n return (\n <FlexView $width={width} $height={height}>\n <Styled.Canvas\n key={src}\n ref={canvasRef}\n $renderWidth={width}\n $renderHeight={height}\n width={isNumW ? width : undefined}\n height={isNumH ? height : undefined}\n />\n </FlexView>\n );\n },\n);\n\nexport default memo(DotLottieAnimation);\n"],"names":["DotLottieAnimation","forwardRef","props","ref","src","data","width","height","settings","eventListeners","onRender","onError","canvasRef","useRef","animationInstance","useImperativeHandle","_a","segments","_b","frame","useEffect","destroyed","DotLottieWorker","err","name","callback","jsx","FlexView","Styled.Canvas","DotLottieAnimation$1","memo"],"mappings":";;;;;AAYA,MAAMA,IAAqBC;AAAA,EACzB,CAACC,GAAOC,MAAQ;AACR,UAAA;AAAA,MACJ,KAAAC;AAAA,MACA,MAAAC;AAAA,MACA,OAAAC,IAAQ;AAAA,MACR,QAAAC,IAAS;AAAA,MACT,UAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,UAAAC;AAAA,MACA,SAAAC;AAAA,IACE,IAAAT,GAEEU,IAAYC,EAA0B,IAAI,GAC1CC,IAAoBD,EAA+B,IAAI;AAE7D,WAAAE;AAAA,MACEZ;AAAA,MACA,OAAO;AAAA,QACL,MAAM,MAAM;;AACV,WAAAa,IAAAF,EAAkB,YAAlB,QAAAE,EAA2B;AAAA,QAC7B;AAAA,QACA,OAAO,MAAM;;AACX,WAAAA,IAAAF,EAAkB,YAAlB,QAAAE,EAA2B;AAAA,QAC7B;AAAA,QACA,cAAc,CAACC,MAA+B;;AAC5C,WAAAD,IAAAF,EAAkB,YAAlB,QAAAE,EAA2B,WAAWC,EAAS,CAAC,GAAGA,EAAS,CAAC,KAC7DC,IAAAJ,EAAkB,YAAlB,QAAAI,EAA2B;AAAA,QAC7B;AAAA,QACA,UAAU,CAACC,MAAkB;;AACT,WAAAH,IAAAF,EAAA,YAAA,QAAAE,EAAS,SAASG;AAAA,QACtC;AAAA,MAAA;AAAA,MAEF,CAAC;AAAA,IAAA,GAGHC,EAAU,MAAM;AACV,UAAA,CAACR,EAAU,QAAS;AAExB,UAAIS,IAAY;AA6BF,cA3BQ,MAAM;AACtB,YAAA;AACgB,UAAAP,EAAA,UAAU,IAAIQ,EAAgB;AAAA,YAC9C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AA,EAEJ;AACF,GAEeyB,IAAAC,EAAK9B,CAAkB;"}
package/dist/index.d.ts CHANGED
@@ -2,10 +2,14 @@ import type { ButtonHTMLAttributes } from 'react';
2
2
  import type { Channel } from '@cuemath/cue-message-broker';
3
3
  import { ChannelStatus } from '@cuemath/cue-message-broker';
4
4
  import { ComponentType } from 'react';
5
+ import type { Config } from '@lottiefiles/dotlottie-web';
5
6
  import { Context } from 'react';
7
+ import type { Data } from '@lottiefiles/dotlottie-web';
6
8
  import type { DefaultTheme } from 'styled-components';
7
9
  import { DetailedHTMLProps } from 'react';
8
10
  import type { Dispatch } from 'react';
11
+ import type { EventListener as EventListener_2 } from '@lottiefiles/dotlottie-web';
12
+ import type { EventType } from '@lottiefiles/dotlottie-web';
9
13
  import { FC } from 'react';
10
14
  import type { FormEvent } from 'react';
11
15
  import { ForwardRefExoticComponent } from 'react';
@@ -74,6 +78,8 @@ export declare const AnimatedArc: React_2.FC<IAnimatedArcProps>;
74
78
 
75
79
  export declare const AnimatedAvatarMessage: NamedExoticComponent<IAnimatedAvatarMessageProps>;
76
80
 
81
+ declare type AnimationSegment = [number, number];
82
+
77
83
  export declare const AppLoader: FC<IAppLoaderProps>;
78
84
 
79
85
  export declare const ArcButton: NamedExoticComponent<IArcButtonProps & {
@@ -363,6 +369,8 @@ export declare const DesmosCalculator: FC<IDesmosCalculatorProps>;
363
369
 
364
370
  export declare const DigitalMeter: FC<IDigitalMeterProps>;
365
371
 
372
+ export declare const DotLottieAnimation: NamedExoticComponent<IDotLottieAnimationProps & RefAttributes<IDotLottieAnimationRef>>;
373
+
366
374
  export declare const DownIcon: React.FC<React.SVGProps<SVGSVGElement>>;
367
375
 
368
376
  export declare const DraftIcon: React.FC<React.SVGProps<SVGSVGElement>>;
@@ -1412,6 +1420,15 @@ declare interface IDigitalMeterProps {
1412
1420
  actAsTimer?: boolean;
1413
1421
  }
1414
1422
 
1423
+ declare type IDotLottieAnimationProps = XOR<WithSrc, WithData> & SharedProps;
1424
+
1425
+ declare interface IDotLottieAnimationRef {
1426
+ play: () => void;
1427
+ pause: () => void;
1428
+ playSegments: (segments: AnimationSegment) => void;
1429
+ setFrame: (frame: number) => void;
1430
+ }
1431
+
1415
1432
  declare interface IDrawerProps {
1416
1433
  isOpen: boolean;
1417
1434
  onClose?: () => void;
@@ -4524,6 +4541,8 @@ export declare const LOTTIE: {
4524
4541
  VIDEO: string;
4525
4542
  };
4526
4543
 
4544
+ declare type LottieSettings = Omit<Config, 'src' | 'canvas'>;
4545
+
4527
4546
  export declare const LPARChapter: FC<ILPARChapterProps>;
4528
4547
 
4529
4548
  export declare const LPARMilestoneChapter: FC<ILPARMilestoneChapter>;
@@ -4932,6 +4951,18 @@ export declare const SENTRY_IGNORED_ERRORS: Array<string | RegExp>;
4932
4951
 
4933
4952
  export declare const Separator: React_2.FC<ISeparatorProps>;
4934
4953
 
4954
+ declare type SharedProps = {
4955
+ width?: string | number;
4956
+ height?: string | number;
4957
+ settings?: Partial<LottieSettings>;
4958
+ eventListeners?: {
4959
+ name: EventType;
4960
+ callback: EventListener_2<EventType>;
4961
+ }[];
4962
+ onRender?: () => void;
4963
+ onError?: () => void;
4964
+ };
4965
+
4935
4966
  export declare const SHEET_ACTIONS: {
4936
4967
  readonly START: "START";
4937
4968
  readonly RESUME: "RESUME";
@@ -6486,6 +6517,18 @@ export declare enum WebViewEvent {
6486
6517
  */
6487
6518
  export declare const WHITELIST_EVENTS: Record<string, PLUGIN_NAME[]>;
6488
6519
 
6520
+ declare type WithData = {
6521
+ data: Data;
6522
+ };
6523
+
6524
+ declare type Without<T, K extends keyof any> = {
6525
+ [P in Exclude<keyof T, K>]?: never;
6526
+ };
6527
+
6528
+ declare type WithSrc = {
6529
+ src: string;
6530
+ };
6531
+
6489
6532
  export declare const Worksheet: NamedExoticComponent<IWorksheetContainerProps & RefAttributes<IWorksheetRef>>;
6490
6533
 
6491
6534
  export declare const WORKSHEET_ACTION_BAR_HEIGHT = 56;
@@ -6498,6 +6541,8 @@ export declare const WORKSHEET_TOP_NAVIGATION_HEIGHT = 48;
6498
6541
 
6499
6542
  export declare const WORKSHEET_V3_NODE_TYPES: TNodeTypeProps[];
6500
6543
 
6544
+ declare type XOR<T, U> = (T & Without<U, keyof T>) | (U & Without<T, keyof U>);
6545
+
6501
6546
  declare const ZINDEX: {
6502
6547
  readonly CHAPTER_CROWN_ICON: 4;
6503
6548
  readonly CHAPTER_PLUS_ICON: 2;