@cuemath/leap 2.8.25-rj-14 → 2.8.25-rj-15
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,33 +1,41 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import
|
3
|
-
import { memo as R, useState as
|
4
|
-
import { CircularLoader as
|
5
|
-
import { useCircleSounds as
|
6
|
-
import { Carousel as
|
7
|
-
import { SegmentedGameCard as
|
8
|
-
import { GAME_LAUNCHER_ANALYTICS_EVENTS as
|
9
|
-
import { SleepyBoiLottyContainer as
|
10
|
-
import { useGameLauncherJourney as
|
11
|
-
import { ProjectType as
|
12
|
-
const
|
13
|
-
({
|
14
|
-
|
15
|
-
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
2
|
+
import h from "lottie-web";
|
3
|
+
import { memo as R, useState as S, useRef as G, useMemo as P, useEffect as x } from "react";
|
4
|
+
import { CircularLoader as M } from "../../ui/loader/circular-loader/circular-loader.js";
|
5
|
+
import { useCircleSounds as _ } from "../hooks/use-circle-sounds/use-circle-sounds.js";
|
6
|
+
import { Carousel as V } from "./comps/carousel/carousel.js";
|
7
|
+
import { SegmentedGameCard as t } from "./comps/segmented-game-card/segmented-game-card.js";
|
8
|
+
import { GAME_LAUNCHER_ANALYTICS_EVENTS as z } from "./game-launcher-analytics-events.js";
|
9
|
+
import { SleepyBoiLottyContainer as B } from "./game-launcher-styled.js";
|
10
|
+
import { useGameLauncherJourney as J } from "./use-game-launcher-journey/use-game-launcher-journey.js";
|
11
|
+
import { ProjectType as i } from "../games/web-view/enums/project-type-enum.js";
|
12
|
+
const Y = () => import("../../../assets/lotties/circle/sleepy-boi-lottie.json.js"), W = R(
|
13
|
+
({
|
14
|
+
onSegmentClick: o,
|
15
|
+
onJourneyComplete: g,
|
16
|
+
journeyId: n,
|
17
|
+
data: e,
|
18
|
+
isLoading: C,
|
19
|
+
error: b = !1,
|
20
|
+
defaultIndex: v = 0
|
21
|
+
}) => {
|
22
|
+
const [A, E] = S(v), m = G(null), { playSwipSound: u } = _(), {
|
23
|
+
gameRefs: a,
|
16
24
|
lessonRefs: f,
|
17
|
-
puzzleRefs:
|
18
|
-
startJourney:
|
19
|
-
carouselNextBtnRef:
|
20
|
-
isJourneyInProgress:
|
21
|
-
} =
|
22
|
-
setCarouselIndex:
|
23
|
-
onSegmentClick:
|
24
|
-
onJourneyComplete:
|
25
|
-
}),
|
25
|
+
puzzleRefs: p,
|
26
|
+
startJourney: c,
|
27
|
+
carouselNextBtnRef: y,
|
28
|
+
isJourneyInProgress: L
|
29
|
+
} = J({
|
30
|
+
setCarouselIndex: E,
|
31
|
+
onSegmentClick: o,
|
32
|
+
onJourneyComplete: g
|
33
|
+
}), I = P(() => {
|
26
34
|
let l = [];
|
27
35
|
return e && (e.lessons && (l = [
|
28
36
|
...l,
|
29
|
-
/* @__PURE__ */
|
30
|
-
|
37
|
+
/* @__PURE__ */ r(
|
38
|
+
t,
|
31
39
|
{
|
32
40
|
ref: f,
|
33
41
|
label: e.lessons.label,
|
@@ -38,16 +46,16 @@ const J = () => import("../../../assets/lotties/circle/sleepy-boi-lottie.json.js
|
|
38
46
|
card: s.cardLottie,
|
39
47
|
name: s.name,
|
40
48
|
isCompleted: s.status === "completed",
|
41
|
-
onPress: () => s.status === "completed" ? void 0 :
|
49
|
+
onPress: () => s.status === "completed" ? void 0 : o(s, i.LESSON)
|
42
50
|
}))
|
43
51
|
}
|
44
52
|
)
|
45
53
|
]), l = [
|
46
54
|
...l,
|
47
|
-
/* @__PURE__ */
|
48
|
-
|
55
|
+
/* @__PURE__ */ r(
|
56
|
+
t,
|
49
57
|
{
|
50
|
-
ref:
|
58
|
+
ref: a,
|
51
59
|
label: e.games.label,
|
52
60
|
value: e.games.data.filter((s) => s.isPlayed).length,
|
53
61
|
maxValue: e.games.data.length,
|
@@ -56,14 +64,14 @@ const J = () => import("../../../assets/lotties/circle/sleepy-boi-lottie.json.js
|
|
56
64
|
card: s.cardLottie,
|
57
65
|
name: s.name,
|
58
66
|
isCompleted: !1,
|
59
|
-
onPress: () =>
|
67
|
+
onPress: () => o(s, i.GAME)
|
60
68
|
}))
|
61
69
|
}
|
62
70
|
),
|
63
|
-
/* @__PURE__ */
|
64
|
-
|
71
|
+
/* @__PURE__ */ r(
|
72
|
+
t,
|
65
73
|
{
|
66
|
-
ref:
|
74
|
+
ref: p,
|
67
75
|
label: e.puzzles.label,
|
68
76
|
value: e.puzzles.data.filter((s) => s.solved).length,
|
69
77
|
maxValue: e.puzzles.data.length,
|
@@ -72,22 +80,22 @@ const J = () => import("../../../assets/lotties/circle/sleepy-boi-lottie.json.js
|
|
72
80
|
card: s.cardLottie,
|
73
81
|
name: s.name,
|
74
82
|
isCompleted: s.solved,
|
75
|
-
onPress: () =>
|
83
|
+
onPress: () => o(s, i.PUZZLE)
|
76
84
|
}))
|
77
85
|
}
|
78
86
|
)
|
79
87
|
]), l;
|
80
|
-
}, [e,
|
81
|
-
() => [/* @__PURE__ */
|
88
|
+
}, [e, a, f, o, p]), N = P(
|
89
|
+
() => [/* @__PURE__ */ r(B, { ref: m })],
|
82
90
|
[]
|
83
91
|
);
|
84
|
-
return
|
92
|
+
return x(() => {
|
85
93
|
let l = null;
|
86
94
|
return (async () => {
|
87
|
-
const
|
88
|
-
l =
|
89
|
-
container:
|
90
|
-
animationData:
|
95
|
+
const T = (await Y()).default;
|
96
|
+
l = h.loadAnimation({
|
97
|
+
container: m.current,
|
98
|
+
animationData: T,
|
91
99
|
autoplay: !0,
|
92
100
|
loop: !0,
|
93
101
|
renderer: "canvas"
|
@@ -95,33 +103,33 @@ const J = () => import("../../../assets/lotties/circle/sleepy-boi-lottie.json.js
|
|
95
103
|
})(), () => {
|
96
104
|
l == null || l.destroy();
|
97
105
|
};
|
98
|
-
}, []),
|
99
|
-
e != null && e.puzzles && n &&
|
100
|
-
}, [e == null ? void 0 : e.lessons, e == null ? void 0 : e.puzzles,
|
101
|
-
|
106
|
+
}, []), x(() => {
|
107
|
+
e != null && e.puzzles && n && L && c(e == null ? void 0 : e.puzzles, !!(e != null && e.lessons), n);
|
108
|
+
}, [e == null ? void 0 : e.lessons, e == null ? void 0 : e.puzzles, L, n, c]), C ? /* @__PURE__ */ r(M, {}) : b ? /* @__PURE__ */ r(
|
109
|
+
V,
|
102
110
|
{
|
103
|
-
ref:
|
104
|
-
items:
|
105
|
-
defaultIndex: v,
|
106
|
-
onNext: a,
|
107
|
-
onPrev: a,
|
111
|
+
ref: y,
|
112
|
+
items: N,
|
108
113
|
analyticsNext: {
|
109
|
-
analyticsLabel:
|
114
|
+
analyticsLabel: ""
|
110
115
|
},
|
111
116
|
analyticsPrev: {
|
112
|
-
analyticsLabel:
|
117
|
+
analyticsLabel: ""
|
113
118
|
}
|
114
119
|
}
|
115
|
-
) : /* @__PURE__ */
|
116
|
-
|
120
|
+
) : /* @__PURE__ */ r(
|
121
|
+
V,
|
117
122
|
{
|
118
|
-
ref:
|
119
|
-
items:
|
123
|
+
ref: y,
|
124
|
+
items: I,
|
125
|
+
defaultIndex: A,
|
126
|
+
onNext: u,
|
127
|
+
onPrev: u,
|
120
128
|
analyticsNext: {
|
121
|
-
analyticsLabel:
|
129
|
+
analyticsLabel: z.NEXT_ACTIVITY
|
122
130
|
},
|
123
131
|
analyticsPrev: {
|
124
|
-
analyticsLabel:
|
132
|
+
analyticsLabel: z.PREV_ACTIVITY
|
125
133
|
}
|
126
134
|
}
|
127
135
|
);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"game-launcher.js","sources":["../../../../src/features/circle-games/game-launcher/game-launcher.tsx"],"sourcesContent":["import type { IGameLauncherProps } from './game-launcher-types';\nimport type { AnimationItem } from 'lottie-web';\nimport type { FC, ReactNode } from 'react';\n\nimport Lottie from 'lottie-web';\nimport { memo, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { CircularLoader } from '../../ui/loader/circular-loader/circular-loader';\nimport { ProjectType } from '../games/web-view/enums';\nimport { useCircleSounds } from '../hooks/use-circle-sounds/use-circle-sounds';\nimport { Carousel } from './comps/carousel/carousel';\nimport { SegmentedGameCard } from './comps/segmented-game-card/segmented-game-card';\nimport { GAME_LAUNCHER_ANALYTICS_EVENTS } from './game-launcher-analytics-events';\nimport * as Styled from './game-launcher-styled';\nimport { useGameLauncherJourney } from './use-game-launcher-journey/use-game-launcher-journey';\n\nconst sleepyBoi = () => import('../../../assets/lotties/circle/sleepy-boi-lottie.json');\n\nexport const GameLauncher: FC<IGameLauncherProps> = memo(\n ({
|
1
|
+
{"version":3,"file":"game-launcher.js","sources":["../../../../src/features/circle-games/game-launcher/game-launcher.tsx"],"sourcesContent":["import type { IGameLauncherProps } from './game-launcher-types';\nimport type { AnimationItem } from 'lottie-web';\nimport type { FC, ReactNode } from 'react';\n\nimport Lottie from 'lottie-web';\nimport { memo, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { CircularLoader } from '../../ui/loader/circular-loader/circular-loader';\nimport { ProjectType } from '../games/web-view/enums';\nimport { useCircleSounds } from '../hooks/use-circle-sounds/use-circle-sounds';\nimport { Carousel } from './comps/carousel/carousel';\nimport { SegmentedGameCard } from './comps/segmented-game-card/segmented-game-card';\nimport { GAME_LAUNCHER_ANALYTICS_EVENTS } from './game-launcher-analytics-events';\nimport * as Styled from './game-launcher-styled';\nimport { useGameLauncherJourney } from './use-game-launcher-journey/use-game-launcher-journey';\n\nconst sleepyBoi = () => import('../../../assets/lotties/circle/sleepy-boi-lottie.json');\n\nexport const GameLauncher: FC<IGameLauncherProps> = memo(\n ({\n onSegmentClick,\n onJourneyComplete,\n journeyId,\n data,\n isLoading,\n error = false,\n defaultIndex = 0,\n }) => {\n const [currentIndex, setCurrentIndex] = useState(defaultIndex);\n\n const lottieContainerRef = useRef<HTMLDivElement>(null);\n const { playSwipSound } = useCircleSounds();\n\n const {\n gameRefs,\n lessonRefs,\n puzzleRefs,\n startJourney,\n carouselNextBtnRef,\n isJourneyInProgress,\n } = useGameLauncherJourney({\n setCarouselIndex: setCurrentIndex,\n onSegmentClick,\n onJourneyComplete,\n });\n\n const items = useMemo(() => {\n let itemTypes: ReactNode[] = [];\n\n if (data) {\n if (data.lessons) {\n itemTypes = [\n ...itemTypes,\n <SegmentedGameCard\n ref={lessonRefs}\n label={data.lessons.label}\n value={data.lessons.data.filter(lesson => lesson.status === 'completed').length}\n maxValue={data.lessons.data.length}\n initialValue={data.lessons.initialProgressValue}\n data={data?.lessons.data.map(lesson => ({\n card: lesson.cardLottie,\n name: lesson.name,\n isCompleted: lesson.status === 'completed',\n onPress: () =>\n lesson.status === 'completed'\n ? undefined\n : onSegmentClick(lesson, ProjectType.LESSON),\n }))}\n />,\n ];\n }\n\n itemTypes = [\n ...itemTypes,\n <SegmentedGameCard\n ref={gameRefs}\n label={data.games.label}\n value={data.games.data.filter(game => game.isPlayed).length}\n maxValue={data.games.data.length}\n initialValue={data.games.initialProgressValue}\n data={data.games.data.map(game => ({\n card: game.cardLottie,\n name: game.name,\n isCompleted: false,\n onPress: () => onSegmentClick(game, ProjectType.GAME),\n }))}\n />,\n <SegmentedGameCard\n ref={puzzleRefs}\n label={data.puzzles.label}\n value={data.puzzles.data.filter(puzzle => puzzle.solved).length}\n maxValue={data.puzzles.data.length}\n initialValue={data.puzzles.initialProgressValue}\n data={data.puzzles.data.map(puzzle => ({\n card: puzzle.cardLottie,\n name: puzzle.name,\n isCompleted: puzzle.solved,\n onPress: () => onSegmentClick(puzzle, ProjectType.PUZZLE),\n }))}\n />,\n ];\n }\n\n return itemTypes;\n }, [data, gameRefs, lessonRefs, onSegmentClick, puzzleRefs]);\n\n const sleepyBoiItem = useMemo(\n () => [<Styled.SleepyBoiLottyContainer ref={lottieContainerRef} />],\n [],\n );\n\n useEffect(() => {\n let animation: AnimationItem | null = null;\n const loadAnimation = async () => {\n const animationModule = await sleepyBoi();\n\n const animationData = animationModule.default;\n\n animation = Lottie.loadAnimation({\n container: lottieContainerRef.current as Element,\n animationData: animationData,\n autoplay: true,\n loop: true,\n renderer: 'canvas',\n });\n };\n\n loadAnimation();\n\n return () => {\n animation?.destroy();\n };\n }, []);\n\n // Start game launcher journey when the data for puzzles is available\n useEffect(() => {\n if (data?.puzzles && journeyId && isJourneyInProgress) {\n startJourney(data?.puzzles, !!data?.lessons, journeyId);\n }\n }, [data?.lessons, data?.puzzles, isJourneyInProgress, journeyId, startJourney]);\n\n if (isLoading) {\n return <CircularLoader />;\n }\n\n if (error) {\n return (\n <Carousel\n ref={carouselNextBtnRef}\n items={sleepyBoiItem}\n analyticsNext={{\n analyticsLabel: '',\n }}\n analyticsPrev={{\n analyticsLabel: '',\n }}\n />\n );\n }\n\n return (\n <Carousel\n ref={carouselNextBtnRef}\n items={items}\n defaultIndex={currentIndex}\n onNext={playSwipSound}\n onPrev={playSwipSound}\n analyticsNext={{\n analyticsLabel: GAME_LAUNCHER_ANALYTICS_EVENTS.NEXT_ACTIVITY,\n }}\n analyticsPrev={{\n analyticsLabel: GAME_LAUNCHER_ANALYTICS_EVENTS.PREV_ACTIVITY,\n }}\n />\n );\n },\n);\n"],"names":["sleepyBoi","GameLauncher","memo","onSegmentClick","onJourneyComplete","journeyId","data","isLoading","error","defaultIndex","currentIndex","setCurrentIndex","useState","lottieContainerRef","useRef","playSwipSound","useCircleSounds","gameRefs","lessonRefs","puzzleRefs","startJourney","carouselNextBtnRef","isJourneyInProgress","useGameLauncherJourney","items","useMemo","itemTypes","jsx","SegmentedGameCard","lesson","ProjectType","game","puzzle","sleepyBoiItem","Styled.SleepyBoiLottyContainer","useEffect","animation","animationData","Lottie","CircularLoader","Carousel","GAME_LAUNCHER_ANALYTICS_EVENTS"],"mappings":";;;;;;;;;;;AAgBA,MAAMA,IAAY,MAAM,OAAO,0DAAuD,GAEzEC,IAAuCC;AAAA,EAClD,CAAC;AAAA,IACC,gBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,cAAAC,IAAe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KAAA,QAAAA,EAAW;AAAA,MAAQ;AAAA,IAEvB,GAAG,CAAE,CAAA,GAGLD,EAAU,MAAM;AACV,MAAA7B,KAAA,QAAAA,EAAM,WAAWD,KAAaiB,KAChCF,EAAad,KAAA,gBAAAA,EAAM,SAAS,CAAC,EAACA,KAAA,QAAAA,EAAM,UAASD,CAAS;AAAA,IACxD,GACC,CAACC,KAAA,gBAAAA,EAAM,SAASA,KAAA,gBAAAA,EAAM,SAASgB,GAAqBjB,GAAWe,CAAY,CAAC,GAE3Eb,sBACMgC,GAAe,CAAA,CAAA,IAGrB/B,IAEA,gBAAAmB;AAAA,MAACa;AAAA,MAAA;AAAA,QACC,KAAKnB;AAAA,QACL,OAAOY;AAAA,QACP,eAAe;AAAA,UACb,gBAAgB;AAAA,QAClB;AAAA,QACA,eAAe;AAAA,UACb,gBAAgB;AAAA,QAClB;AAAA,MAAA;AAAA,IAAA,IAMJ,gBAAAN;AAAA,MAACa;AAAA,MAAA;AAAA,QACC,KAAKnB;AAAA,QACL,OAAAG;AAAA,QACA,cAAcd;AAAA,QACd,QAAQK;AAAA,QACR,QAAQA;AAAA,QACR,eAAe;AAAA,UACb,gBAAgB0B,EAA+B;AAAA,QACjD;AAAA,QACA,eAAe;AAAA,UACb,gBAAgBA,EAA+B;AAAA,QACjD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;"}
|
package/dist/index.d.ts
CHANGED
@@ -1087,6 +1087,7 @@ declare interface IGame extends IBaseProject<GameId> {
|
|
1087
1087
|
declare interface IGameLauncherProps {
|
1088
1088
|
onSegmentClick: (projectDetail: Game | Puzzle | Lesson, projectType: ProjectType) => void;
|
1089
1089
|
isLoading?: boolean;
|
1090
|
+
error?: boolean;
|
1090
1091
|
data: IProjects | null;
|
1091
1092
|
defaultIndex?: number;
|
1092
1093
|
journeyId?: TJourneyId;
|