@cuemath/leap 3.0.6 → 3.0.7-hg2
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,74 +1,79 @@
|
|
1
1
|
import { jsx as E } from "react/jsx-runtime";
|
2
2
|
import g from "lottie-web";
|
3
|
-
import { memo as
|
4
|
-
import
|
5
|
-
import { fetchLottie as
|
6
|
-
const
|
3
|
+
import { memo as b, forwardRef as A, useRef as m, useMemo as I, useImperativeHandle as x, useEffect as O } from "react";
|
4
|
+
import S from "../layout/flex-view.js";
|
5
|
+
import { fetchLottie as $ } from "./helper.js";
|
6
|
+
const k = A((L, h) => {
|
7
7
|
const {
|
8
8
|
src: l,
|
9
|
-
width:
|
10
|
-
height:
|
11
|
-
settings:
|
12
|
-
eventListener:
|
13
|
-
onRender:
|
9
|
+
width: w = "100%",
|
10
|
+
height: y = "100%",
|
11
|
+
settings: i,
|
12
|
+
eventListener: n,
|
13
|
+
onRender: a,
|
14
14
|
animateOnIntersect: s
|
15
|
-
} =
|
15
|
+
} = L, c = m(null), r = m(null), u = m(null), d = I(
|
16
16
|
() => ({
|
17
|
-
...
|
18
|
-
renderer: window.ReactNativeWebView ? "
|
17
|
+
...i,
|
18
|
+
renderer: window.ReactNativeWebView ? "canvas" : (i == null ? void 0 : i.renderer) ?? "svg"
|
19
19
|
}),
|
20
|
-
[
|
20
|
+
[i]
|
21
21
|
);
|
22
|
-
return
|
23
|
-
|
22
|
+
return x(
|
23
|
+
h,
|
24
24
|
() => ({
|
25
|
-
playSegments: (t,
|
26
|
-
var
|
27
|
-
return (
|
25
|
+
playSegments: (t, o) => {
|
26
|
+
var e;
|
27
|
+
return (e = r.current) == null ? void 0 : e.playSegments(t, o);
|
28
28
|
},
|
29
|
-
addEventListener: (t,
|
30
|
-
var
|
31
|
-
return (
|
29
|
+
addEventListener: (t, o) => {
|
30
|
+
var e;
|
31
|
+
return (e = r.current) == null ? void 0 : e.addEventListener(t, o);
|
32
32
|
},
|
33
|
-
removeEventListener: (t,
|
34
|
-
var
|
35
|
-
return (
|
33
|
+
removeEventListener: (t, o) => {
|
34
|
+
var e;
|
35
|
+
return (e = r.current) == null ? void 0 : e.removeEventListener(t, o);
|
36
36
|
},
|
37
37
|
play: () => {
|
38
38
|
var t;
|
39
|
-
return (t =
|
39
|
+
return (t = r.current) == null ? void 0 : t.play();
|
40
40
|
},
|
41
41
|
stop: () => {
|
42
42
|
var t;
|
43
|
-
return (t =
|
43
|
+
return (t = r.current) == null ? void 0 : t.stop();
|
44
44
|
}
|
45
45
|
}),
|
46
46
|
[]
|
47
|
-
),
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
}),
|
47
|
+
), O(() => {
|
48
|
+
let t = !1;
|
49
|
+
return (async () => {
|
50
|
+
try {
|
51
|
+
const e = await $(l);
|
52
|
+
requestAnimationFrame(() => {
|
53
|
+
!c.current || t || (r.current = g.loadAnimation({
|
54
|
+
container: c.current,
|
55
|
+
animationData: e,
|
56
|
+
loop: !0,
|
57
|
+
autoplay: !0,
|
58
|
+
...d
|
59
|
+
}), s && (u.current = new IntersectionObserver(
|
60
|
+
([f]) => {
|
61
|
+
var p, v;
|
62
|
+
f && f.isIntersecting ? (p = r.current) == null || p.play() : (v = r.current) == null || v.pause();
|
63
|
+
},
|
64
|
+
{ threshold: 0 }
|
65
|
+
), u.current.observe(c.current)), a == null || a(), n && r.current.addEventListener(n.name, n.callback));
|
66
|
+
});
|
67
|
+
} catch (e) {
|
68
|
+
console.error("Error loading Lottie animation:", e);
|
69
|
+
}
|
70
|
+
})(), () => {
|
71
|
+
var e;
|
72
|
+
t = !0, r.current && (n && r.current.removeEventListener(n.name, n.callback), s && ((e = u.current) == null || e.disconnect()), r.current.destroy());
|
73
|
+
};
|
74
|
+
}, [l, n, a, s, d]), /* @__PURE__ */ E(S, { ref: c, $width: w, $height: y });
|
75
|
+
}), D = b(k);
|
71
76
|
export {
|
72
|
-
|
77
|
+
D as default
|
73
78
|
};
|
74
79
|
//# sourceMappingURL=lottie-animation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lottie-animation.js","sources":["../../../../src/features/ui/lottie-animation/lottie-animation.tsx"],"sourcesContent":["import type { ILottieAnimationProps, ILottieAnimationRef } from './types';\nimport type { AnimationEventName, AnimationItem, AnimationSegment, RendererType } from 'lottie-web';\n\nimport lottie from 'lottie-web';\nimport { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\n\nimport FlexView from '../layout/flex-view';\nimport { fetchLottie } from './helper';\n\nconst LottieAnimation = forwardRef<ILottieAnimationRef, ILottieAnimationProps>((props, ref) => {\n const {\n src,\n width = '100%',\n height = '100%',\n settings,\n eventListener,\n onRender,\n animateOnIntersect,\n } = props;\n\n const container = useRef<HTMLDivElement>(null);\n const animationInstance = useRef<AnimationItem | null>(null);\n const intersectionObserver = useRef<IntersectionObserver | null>(null);\n const newSettings = useMemo(\n () => ({\n ...settings,\n renderer: (window.ReactNativeWebView ? '
|
1
|
+
{"version":3,"file":"lottie-animation.js","sources":["../../../../src/features/ui/lottie-animation/lottie-animation.tsx"],"sourcesContent":["import type { ILottieAnimationProps, ILottieAnimationRef } from './types';\nimport type { AnimationEventName, AnimationItem, AnimationSegment, RendererType } from 'lottie-web';\n\nimport lottie from 'lottie-web';\nimport { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\n\nimport FlexView from '../layout/flex-view';\nimport { fetchLottie } from './helper';\n\nconst LottieAnimation = forwardRef<ILottieAnimationRef, ILottieAnimationProps>((props, ref) => {\n const {\n src,\n width = '100%',\n height = '100%',\n settings,\n eventListener,\n onRender,\n animateOnIntersect,\n } = props;\n\n const container = useRef<HTMLDivElement>(null);\n const animationInstance = useRef<AnimationItem | null>(null);\n const intersectionObserver = useRef<IntersectionObserver | null>(null);\n const newSettings = useMemo(\n () => ({\n ...settings,\n renderer: (window.ReactNativeWebView ? 'canvas' : settings?.renderer ?? 'svg') as RendererType,\n }),\n [settings],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n playSegments: (segments: AnimationSegment, forceFlag?: boolean) =>\n animationInstance.current?.playSegments(segments, forceFlag),\n addEventListener: (eventName: string, callback: () => void) =>\n animationInstance.current?.addEventListener(eventName as AnimationEventName, callback),\n removeEventListener: (eventName: string, callback: () => void) =>\n animationInstance.current?.removeEventListener(eventName as AnimationEventName, callback),\n play: () => animationInstance.current?.play(),\n stop: () => animationInstance.current?.stop(),\n }),\n [],\n );\n\n useEffect(() => {\n let destroyed = false;\n \n const loadAnimation = async () => {\n try {\n const animationData = await fetchLottie(src);\n \n // Wait for layout\n requestAnimationFrame(() => {\n if (!container.current || destroyed) return;\n \n animationInstance.current = lottie.loadAnimation({\n container: container.current,\n animationData,\n loop: true,\n autoplay: true,\n ...newSettings,\n });\n \n if (animateOnIntersect) {\n intersectionObserver.current = new IntersectionObserver(\n ([entry]) => {\n if (entry && entry.isIntersecting) {\n animationInstance.current?.play();\n } else {\n animationInstance.current?.pause();\n }\n },\n { threshold: 0 },\n );\n \n intersectionObserver.current.observe(container.current);\n }\n \n onRender?.();\n \n if (eventListener) {\n animationInstance.current.addEventListener(eventListener.name, eventListener.callback);\n }\n });\n } catch (error) {\n console.error('Error loading Lottie animation:', error);\n }\n };\n \n loadAnimation();\n \n return () => {\n destroyed = true;\n if (animationInstance.current) {\n if (eventListener) {\n animationInstance.current.removeEventListener(eventListener.name, eventListener.callback);\n }\n \n if (animateOnIntersect) {\n intersectionObserver.current?.disconnect();\n }\n \n animationInstance.current.destroy();\n }\n };\n }, [src, eventListener, onRender, animateOnIntersect, newSettings]);\n\n return <FlexView ref={container} $width={width} $height={height} />;\n});\n\nexport default memo(LottieAnimation);\n"],"names":["LottieAnimation","forwardRef","props","ref","src","width","height","settings","eventListener","onRender","animateOnIntersect","container","useRef","animationInstance","intersectionObserver","newSettings","useMemo","useImperativeHandle","segments","forceFlag","_a","eventName","callback","useEffect","destroyed","animationData","fetchLottie","lottie","entry","_b","error","FlexView","LottieAnimation$1","memo"],"mappings":";;;;;AASA,MAAMA,IAAkBC,EAAuD,CAACC,GAAOC,MAAQ;AACvF,QAAA;AAAA,IACJ,KAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,QAAAC,IAAS;AAAA,IACT,UAAAC;AAAA,IACA,eAAAC;AAAA,IACA,UAAAC;AAAA,IACA,oBAAAC;AAAA,EACE,IAAAR,GAEES,IAAYC,EAAuB,IAAI,GACvCC,IAAoBD,EAA6B,IAAI,GACrDE,IAAuBF,EAAoC,IAAI,GAC/DG,IAAcC;AAAA,IAClB,OAAO;AAAA,MACL,GAAGT;AAAA,MACH,UAAW,OAAO,qBAAqB,YAAWA,KAAA,gBAAAA,EAAU,aAAY;AAAA,IAAA;AAAA,IAE1E,CAACA,CAAQ;AAAA,EAAA;AAGX,SAAAU;AAAA,IACEd;AAAA,IACA,OAAO;AAAA,MACL,cAAc,CAACe,GAA4BC,MACzC;;AAAA,gBAAAC,IAAAP,EAAkB,YAAlB,gBAAAO,EAA2B,aAAaF,GAAUC;AAAA;AAAA,MACpD,kBAAkB,CAACE,GAAmBC,MACpC;;AAAA,gBAAAF,IAAAP,EAAkB,YAAlB,gBAAAO,EAA2B,iBAAiBC,GAAiCC;AAAA;AAAA,MAC/E,qBAAqB,CAACD,GAAmBC,MACvC;;AAAA,gBAAAF,IAAAP,EAAkB,YAAlB,gBAAAO,EAA2B,oBAAoBC,GAAiCC;AAAA;AAAA,MAClF,MAAM,MAAM;;AAAA,gBAAAF,IAAAP,EAAkB,YAAlB,gBAAAO,EAA2B;AAAA;AAAA,MACvC,MAAM,MAAM;;AAAA,gBAAAA,IAAAP,EAAkB,YAAlB,gBAAAO,E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
|
1
1
|
{
|
2
2
|
"name": "@cuemath/leap",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.7-hg2",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -94,5 +94,5 @@
|
|
94
94
|
"vite-plugin-svgr": "3.2.0",
|
95
95
|
"vite-tsconfig-paths": "^4.2.2"
|
96
96
|
},
|
97
|
-
"packageManager": "yarn@
|
97
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
98
98
|
}
|