@cuemath/leap 3.2.23-mb → 3.2.24-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.
- package/dist/features/stickers/stickers-effects/stickers-cache.js +13 -0
- package/dist/features/stickers/stickers-effects/stickers-cache.js.map +1 -0
- package/dist/features/stickers/stickers-effects/stickers-effects.js +41 -30
- package/dist/features/stickers/stickers-effects/stickers-effects.js.map +1 -1
- package/dist/features/ui/lottie-animation/helper.js +6 -6
- package/dist/features/ui/lottie-animation/helper.js.map +1 -1
- package/package.json +1 -1
@@ -0,0 +1,13 @@
|
|
1
|
+
const o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
2
|
+
async function s(e) {
|
3
|
+
if (o.has(e))
|
4
|
+
return o.get(e);
|
5
|
+
if (n.has(e))
|
6
|
+
return n.get(e);
|
7
|
+
const r = fetch(e).then((t) => t.ok ? t.json() : null).then((t) => (t && o.set(e, t), n.delete(e), t)).catch((t) => (console.error("Lottie preload error:", t), n.delete(e), null));
|
8
|
+
return n.set(e, r), r;
|
9
|
+
}
|
10
|
+
export {
|
11
|
+
s as preloadLottieFile
|
12
|
+
};
|
13
|
+
//# 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":["const lottieCache = new Map<string, object>();\nconst lottiePromises = new Map<string, Promise<object | null>>();\n\nexport async function preloadLottieFile(url: string): Promise<object | 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(res => (res.ok ? res.json() : null))\n .then(data => {\n if (data) lottieCache.set(url, data);\n lottiePromises.delete(url);\n\n return data;\n })\n .catch(err => {\n // eslint-disable-next-line no-console\n console.error('Lottie preload error:', err);\n lottiePromises.delete(url);\n\n return null;\n });\n\n lottiePromises.set(url, fetchPromise);\n\n return fetchPromise;\n}\n"],"names":["lottieCache","lottiePromises","preloadLottieFile","url","fetchPromise","res","data","err"],"mappings":"AAAA,MAAMA,wBAAkB,OAClBC,wBAAqB;AAE3B,eAAsBC,EAAkBC,GAAqC;AACvE,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,CAAQE,MAAAA,EAAI,KAAKA,EAAI,KAAK,IAAI,IAAK,EACxC,KAAK,CAAQC,OACRA,KAAMN,EAAY,IAAIG,GAAKG,CAAI,GACnCL,EAAe,OAAOE,CAAG,GAElBG,EACR,EACA,MAAM,CAAOC,OAEJ,QAAA,MAAM,yBAAyBA,CAAG,GAC1CN,EAAe,OAAOE,CAAG,GAElB,KACR;AAEY,SAAAF,EAAA,IAAIE,GAAKC,CAAY,GAE7BA;AACT;"}
|
@@ -1,43 +1,54 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import { memo as
|
3
|
-
import
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
import { jsx as c, Fragment as E } from "react/jsx-runtime";
|
2
|
+
import { memo as u, useState as f, useEffect as h } from "react";
|
3
|
+
import F from "../../ui/lottie-animation/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: s }) => {
|
8
|
+
const [i, m] = f(), [n, e] = f(!1);
|
9
|
+
return h(() => {
|
10
|
+
let r = !0;
|
11
|
+
if (t)
|
12
|
+
return g(t).then((a) => {
|
13
|
+
r && (a ? m(a) : e(!0));
|
14
|
+
}).catch(() => {
|
15
|
+
r && e(!0);
|
16
|
+
}), () => {
|
17
|
+
r = !1;
|
18
|
+
};
|
19
|
+
}, [t]), !t || n || !i ? /* @__PURE__ */ c(E, { children: o }) : /* @__PURE__ */ c(F, { src: i, width: s, height: s, onError: () => e(!0) });
|
20
|
+
}), b = ({ stickers: t, effect: o, count: s, duration: i }) => {
|
21
|
+
const [m, n] = f([]);
|
22
|
+
return h(() => {
|
23
|
+
const e = z({
|
24
|
+
count: s,
|
25
|
+
effect: o,
|
15
26
|
stickers: t,
|
16
27
|
minSize: 32,
|
17
28
|
maxSize: 48
|
18
29
|
});
|
19
|
-
|
20
|
-
const
|
21
|
-
return () => clearTimeout(
|
22
|
-
}, [t,
|
23
|
-
const { id:
|
24
|
-
return /* @__PURE__ */
|
30
|
+
n(e);
|
31
|
+
const r = setTimeout(() => n([]), i);
|
32
|
+
return () => clearTimeout(r);
|
33
|
+
}, [t, o, s, i]), /* @__PURE__ */ c(L, { children: m.map((e, r) => {
|
34
|
+
const { id: a, sticker: k, lottie: p, x: S, y: d, size: l, fromX: x, fromY: D } = e;
|
35
|
+
return /* @__PURE__ */ c(
|
25
36
|
T,
|
26
37
|
{
|
27
|
-
effect:
|
38
|
+
effect: o,
|
28
39
|
duration: i,
|
29
|
-
fromX:
|
30
|
-
fromY:
|
31
|
-
x:
|
32
|
-
y:
|
33
|
-
size:
|
34
|
-
children: /* @__PURE__ */
|
40
|
+
fromX: x,
|
41
|
+
fromY: D,
|
42
|
+
x: S,
|
43
|
+
y: d,
|
44
|
+
size: l,
|
45
|
+
children: /* @__PURE__ */ c($, { url: p, sticker: k, size: l })
|
35
46
|
},
|
36
|
-
`${
|
47
|
+
`${a}-${r}`
|
37
48
|
);
|
38
49
|
}) });
|
39
|
-
},
|
50
|
+
}, W = u(b);
|
40
51
|
export {
|
41
|
-
|
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
|
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 { 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 [src, setSrc] = useState<string | object | undefined>();\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 setSrc(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 || !src) {\n return <>{sticker}</>;\n }\n\n return <LottieAnimation src={src} width={size} height={size} onError={() => setFailed(true)} />;\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","src","setSrc","useState","failed","setFailed","useEffect","isMounted","preloadLottieFile","result","jsx","LottieAnimation","StickersEffects","stickers","effect","count","duration","stickersData","setStickersData","stickerData","generateStickerData","timeout","S.Container","data","i","id","lottie","x","y","fromX","fromY","S.Sticker","stickersEffects"],"mappings":";;;;;;AASA,MAAMA,IAIDC,EAAK,CAAC,EAAE,KAAAC,GAAK,SAAAC,GAAS,MAAAC,QAAW;AACpC,QAAM,CAACC,GAAKC,CAAM,IAAIC,EAAsC,GACtD,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,EAAOO,CAAM,IAEbJ,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,IAGb,gBAAAW,EAACC,GAAgB,EAAA,KAAAV,GAAU,OAAOD,GAAM,QAAQA,GAAM,SAAS,MAAMK,EAAU,EAAI,EAAG,CAAA;AAC/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,CAACC,GAAoBC,MAAM;AACrC,UAAA,EAAE,IAAAC,GAAI,SAAA1B,GAAS,QAAA2B,GAAQ,GAAAC,GAAG,GAAAC,GAAG,MAAA5B,GAAM,OAAA6B,GAAO,OAAAC,EAAU,IAAAP;AAGxD,WAAA,gBAAAb;AAAA,MAACqB;AAAAA,MAAA;AAAA,QAEC,QAAAjB;AAAA,QACA,UAAAE;AAAA,QACA,OAAAa;AAAA,QACA,OAAAC;AAAA,QACA,GAAAH;AAAA,QACA,GAAAC;AAAA,QACA,MAAA5B;AAAA,QAEA,UAAC,gBAAAU,EAAAd,GAAA,EAAoB,KAAK8B,GAAQ,SAAA3B,GAAkB,MAAAC,GAAY;AAAA,MAAA;AAAA,MAT3D,GAAGyB,CAAE,IAAID,CAAC;AAAA,IAAA;AAAA,EAYpB,CAAA,EACH,CAAA;AAEJ,GAEeQ,IAAAnC,EAAKe,CAAe;"}
|
@@ -1,13 +1,13 @@
|
|
1
|
-
const
|
2
|
-
|
1
|
+
const r = async (e) => {
|
2
|
+
if (typeof e == "object") return e;
|
3
3
|
try {
|
4
|
-
|
4
|
+
const t = await fetch(e);
|
5
|
+
return t.ok ? await t.json() : null;
|
5
6
|
} catch (t) {
|
6
|
-
console.log("Error while fetching the
|
7
|
+
return console.log("Error while fetching the Lottie:", t), null;
|
7
8
|
}
|
8
|
-
return e;
|
9
9
|
};
|
10
10
|
export {
|
11
|
-
|
11
|
+
r as fetchLottie
|
12
12
|
};
|
13
13
|
//# sourceMappingURL=helper.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helper.js","sources":["../../../../src/features/ui/lottie-animation/helper.ts"],"sourcesContent":["
|
1
|
+
{"version":3,"file":"helper.js","sources":["../../../../src/features/ui/lottie-animation/helper.ts"],"sourcesContent":["export const fetchLottie = async (lottieSrc: string | object): Promise<object | null> => {\n if (typeof lottieSrc === 'object') return lottieSrc;\n\n try {\n const res = await fetch(lottieSrc);\n\n if (!res.ok) return null;\n\n return await res.json();\n } catch (err) {\n // eslint-disable-next-line no-console\n console.log('Error while fetching the Lottie:', err);\n\n return null;\n }\n};\n"],"names":["fetchLottie","lottieSrc","res","err"],"mappings":"AAAa,MAAAA,IAAc,OAAOC,MAAuD;AACnF,MAAA,OAAOA,KAAc,SAAiB,QAAAA;AAEtC,MAAA;AACI,UAAAC,IAAM,MAAM,MAAMD,CAAS;AAE7B,WAACC,EAAI,KAEF,MAAMA,EAAI,SAFG;AAAA,WAGbC,GAAK;AAEJ,mBAAA,IAAI,oCAAoCA,CAAG,GAE5C;AAAA,EACT;AACF;"}
|