@cuemath/leap 2.8.62-rj-5 → 2.8.62-rj-7
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/circle-games/game-launcher/game-launcher.js +93 -102
- package/dist/features/circle-games/game-launcher/game-launcher.js.map +1 -1
- package/dist/features/journey/use-journey/journey-context-provider.js +63 -63
- package/dist/features/journey/use-journey/journey-context-provider.js.map +1 -1
- package/dist/features/ui/loader/circular-loader/circular-loader.js +6 -5
- package/dist/features/ui/loader/circular-loader/circular-loader.js.map +1 -1
- package/package.json +1 -1
@@ -1,70 +1,70 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import { memo as
|
3
|
-
import { LOTTIE as
|
1
|
+
import { jsx as m, jsxs as O, Fragment as v } from "react/jsx-runtime";
|
2
|
+
import { memo as x, useRef as D, useCallback as t, useMemo as N, useEffect as U } from "react";
|
3
|
+
import { LOTTIE as Y } from "../../../assets/lottie/lottie.js";
|
4
4
|
import { JOURNEY_ID_STUDENT as z } from "../../journey/journey-id/journey-id-student.js";
|
5
|
-
import { useJourney as
|
6
|
-
import { CircularLoader as
|
7
|
-
import
|
8
|
-
import { useCircleSounds as
|
9
|
-
import { CircleSoundKey as
|
10
|
-
import { GAME_LAUNCHER_SIZE as
|
11
|
-
import { Carousel as
|
12
|
-
import { GAME_LAUNCHER_ASSET_PADDING as
|
13
|
-
import { SegmentedGameCard as
|
14
|
-
import { TablesCard as
|
15
|
-
import { GAME_LAUNCHER_ANALYTICS_EVENTS as
|
5
|
+
import { useJourney as B } from "../../journey/use-journey/use-journey.js";
|
6
|
+
import { CircularLoader as K } from "../../ui/loader/circular-loader/circular-loader.js";
|
7
|
+
import H from "../../ui/lottie-animation/lottie-animation.js";
|
8
|
+
import { useCircleSounds as Z } from "../hooks/use-circle-sounds/use-circle-sounds.js";
|
9
|
+
import { CircleSoundKey as n } from "../hooks/use-circle-sounds/use-circle-sounds-enums.js";
|
10
|
+
import { GAME_LAUNCHER_SIZE as w } from "./comps/card-container/constants.js";
|
11
|
+
import { Carousel as F } from "./comps/carousel/carousel.js";
|
12
|
+
import { GAME_LAUNCHER_ASSET_PADDING as X } from "./comps/segmented-game-card/constants.js";
|
13
|
+
import { SegmentedGameCard as E } from "./comps/segmented-game-card/segmented-game-card.js";
|
14
|
+
import { TablesCard as j } from "./comps/tables-card/tables-card.js";
|
15
|
+
import { GAME_LAUNCHER_ANALYTICS_EVENTS as G } from "./game-launcher-analytics-events.js";
|
16
16
|
import { useGameLauncherJourney as q } from "./hooks/use-game-launcher-journey/use-game-launcher-journey.js";
|
17
|
-
import { useTableLauncherJourney as
|
18
|
-
import { ProjectType as
|
19
|
-
const
|
17
|
+
import { useTableLauncherJourney as Q } from "./hooks/use-table-launcher-journey/use-table-launcher-journey.js";
|
18
|
+
import { ProjectType as u } from "../games/web-view/enums/project-type-enum.js";
|
19
|
+
const V = w + X, Ce = x(
|
20
20
|
({
|
21
21
|
onSegmentClick: r,
|
22
|
-
journeyId:
|
23
|
-
isError:
|
22
|
+
journeyId: i,
|
23
|
+
isError: S,
|
24
24
|
data: e,
|
25
|
-
isLoading:
|
26
|
-
isTutorialOnboardingDone:
|
27
|
-
defaultIndex:
|
25
|
+
isLoading: f,
|
26
|
+
isTutorialOnboardingDone: C,
|
27
|
+
defaultIndex: J = 0
|
28
28
|
}) => {
|
29
|
-
const
|
29
|
+
const p = D(null), { isJourneyActive: _ } = B(), { playSwipSound: A, play: o } = Z(), c = t(
|
30
30
|
(l) => {
|
31
|
-
o(
|
31
|
+
o(n.GAME_CARD_CLICK), r(l, u.TABLE);
|
32
32
|
},
|
33
33
|
[r, o]
|
34
|
-
),
|
34
|
+
), L = t(
|
35
35
|
(l) => {
|
36
|
-
l.status !== "completed" && (o(
|
36
|
+
l.status !== "completed" && (o(n.GAME_CARD_CLICK), r(l, u.LESSON));
|
37
37
|
},
|
38
38
|
[r, o]
|
39
|
-
),
|
39
|
+
), T = t(
|
40
40
|
(l) => {
|
41
|
-
o(
|
41
|
+
o(n.GAME_CARD_CLICK), r(l, u.GAME);
|
42
42
|
},
|
43
43
|
[r, o]
|
44
|
-
),
|
44
|
+
), a = t(
|
45
45
|
(l) => {
|
46
|
-
o(
|
46
|
+
o(n.GAME_CARD_CLICK), r(l, u.PUZZLE);
|
47
47
|
},
|
48
48
|
[r, o]
|
49
49
|
), {
|
50
|
-
gameRefs:
|
51
|
-
lessonRefs:
|
52
|
-
puzzleRefs:
|
53
|
-
startJourney:
|
50
|
+
gameRefs: b,
|
51
|
+
lessonRefs: R,
|
52
|
+
puzzleRefs: I,
|
53
|
+
startJourney: y
|
54
54
|
} = q({
|
55
|
-
carouselRefs:
|
55
|
+
carouselRefs: p,
|
56
56
|
onSegmentClick: r
|
57
|
-
}), { startJourney: P, tableRef:
|
58
|
-
carouselRefs:
|
57
|
+
}), { startJourney: P, tableRef: h } = Q({
|
58
|
+
carouselRefs: p,
|
59
59
|
onTableSegmentClick: c
|
60
|
-
}),
|
60
|
+
}), M = N(() => {
|
61
61
|
let l = [];
|
62
62
|
return e && (e.lessons && (l = [
|
63
63
|
...l,
|
64
|
-
/* @__PURE__ */
|
65
|
-
|
64
|
+
/* @__PURE__ */ m(
|
65
|
+
E,
|
66
66
|
{
|
67
|
-
ref:
|
67
|
+
ref: R,
|
68
68
|
label: e.lessons.label,
|
69
69
|
value: e.lessons.data.filter((s) => s.status === "completed").length,
|
70
70
|
maxValue: e.lessons.data.length,
|
@@ -73,16 +73,16 @@ const S = Z + w, ce = g(
|
|
73
73
|
card: s.cardLottie,
|
74
74
|
name: s.name,
|
75
75
|
isCompleted: s.status === "completed",
|
76
|
-
onPress: () =>
|
76
|
+
onPress: () => L(s)
|
77
77
|
}))
|
78
78
|
}
|
79
79
|
)
|
80
80
|
]), l = [
|
81
81
|
...l,
|
82
|
-
/* @__PURE__ */
|
83
|
-
|
82
|
+
/* @__PURE__ */ m(
|
83
|
+
E,
|
84
84
|
{
|
85
|
-
ref:
|
85
|
+
ref: b,
|
86
86
|
label: e.games.label,
|
87
87
|
value: e.games.data.filter((s) => s.isPlayed).length,
|
88
88
|
maxValue: e.games.data.length,
|
@@ -91,14 +91,14 @@ const S = Z + w, ce = g(
|
|
91
91
|
card: s.cardLottie,
|
92
92
|
name: s.name,
|
93
93
|
isCompleted: !1,
|
94
|
-
onPress: () =>
|
94
|
+
onPress: () => T(s)
|
95
95
|
}))
|
96
96
|
}
|
97
97
|
),
|
98
|
-
/* @__PURE__ */
|
99
|
-
|
98
|
+
/* @__PURE__ */ m(
|
99
|
+
E,
|
100
100
|
{
|
101
|
-
ref:
|
101
|
+
ref: I,
|
102
102
|
label: e.puzzles.label,
|
103
103
|
value: e.puzzles.data.filter((s) => s.solved).length,
|
104
104
|
maxValue: e.puzzles.data.length,
|
@@ -107,16 +107,16 @@ const S = Z + w, ce = g(
|
|
107
107
|
card: s.cardLottie,
|
108
108
|
name: s.name,
|
109
109
|
isCompleted: s.solved,
|
110
|
-
onPress: () =>
|
110
|
+
onPress: () => a(s)
|
111
111
|
}))
|
112
112
|
}
|
113
113
|
)
|
114
114
|
], e.tables && (l = [
|
115
115
|
...l,
|
116
|
-
/* @__PURE__ */
|
117
|
-
|
116
|
+
/* @__PURE__ */ m(
|
117
|
+
j,
|
118
118
|
{
|
119
|
-
ref:
|
119
|
+
ref: h,
|
120
120
|
label: e.tables.label,
|
121
121
|
data: e.tables.data,
|
122
122
|
onPress: c,
|
@@ -126,74 +126,65 @@ const S = Z + w, ce = g(
|
|
126
126
|
])), l;
|
127
127
|
}, [
|
128
128
|
e,
|
129
|
-
T,
|
130
|
-
R,
|
131
|
-
y,
|
132
|
-
_,
|
133
|
-
A,
|
134
129
|
b,
|
135
|
-
|
130
|
+
I,
|
131
|
+
R,
|
132
|
+
L,
|
133
|
+
T,
|
134
|
+
a,
|
135
|
+
h,
|
136
136
|
c
|
137
|
-
]),
|
137
|
+
]), g = N(
|
138
138
|
() => [
|
139
|
-
/* @__PURE__ */
|
140
|
-
|
139
|
+
/* @__PURE__ */ m(
|
140
|
+
H,
|
141
141
|
{
|
142
|
-
src:
|
143
|
-
width:
|
144
|
-
height:
|
142
|
+
src: Y.SLEEPY_BOI,
|
143
|
+
width: V,
|
144
|
+
height: V
|
145
145
|
}
|
146
146
|
)
|
147
147
|
],
|
148
148
|
[]
|
149
149
|
);
|
150
|
-
return
|
151
|
-
if (!(
|
152
|
-
if (e != null && e.puzzles &&
|
153
|
-
|
150
|
+
return U(() => {
|
151
|
+
if (!(f || !e || _)) {
|
152
|
+
if (e != null && e.puzzles && i === z.CIRCLE_ACTIVITIES_INTRO_JOURNEY) {
|
153
|
+
y(e == null ? void 0 : e.puzzles, !!(e != null && e.lessons), i);
|
154
154
|
return;
|
155
155
|
}
|
156
|
-
e != null && e.tables &&
|
156
|
+
e != null && e.tables && i === z.CIRCLE_TABLES_INTRO_JOURNEY && P(e == null ? void 0 : e.tables, C);
|
157
157
|
}
|
158
158
|
}, [
|
159
159
|
e,
|
160
|
+
_,
|
161
|
+
f,
|
160
162
|
C,
|
161
|
-
|
162
|
-
|
163
|
-
m,
|
164
|
-
I,
|
163
|
+
i,
|
164
|
+
y,
|
165
165
|
P
|
166
|
-
]),
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
ref: t,
|
182
|
-
items: v,
|
183
|
-
defaultIndex: M,
|
184
|
-
onNext: L,
|
185
|
-
onPrev: L,
|
186
|
-
analyticsNext: {
|
187
|
-
analyticsLabel: V.NEXT_ACTIVITY
|
188
|
-
},
|
189
|
-
analyticsPrev: {
|
190
|
-
analyticsLabel: V.PREV_ACTIVITY
|
166
|
+
]), /* @__PURE__ */ O(v, { children: [
|
167
|
+
/* @__PURE__ */ m(
|
168
|
+
F,
|
169
|
+
{
|
170
|
+
ref: p,
|
171
|
+
items: S ? g : M,
|
172
|
+
defaultIndex: J,
|
173
|
+
onNext: A,
|
174
|
+
onPrev: A,
|
175
|
+
analyticsNext: {
|
176
|
+
analyticsLabel: G.NEXT_ACTIVITY
|
177
|
+
},
|
178
|
+
analyticsPrev: {
|
179
|
+
analyticsLabel: G.PREV_ACTIVITY
|
180
|
+
}
|
191
181
|
}
|
192
|
-
|
193
|
-
|
182
|
+
),
|
183
|
+
f && /* @__PURE__ */ m(K, {})
|
184
|
+
] });
|
194
185
|
}
|
195
186
|
);
|
196
187
|
export {
|
197
|
-
|
188
|
+
Ce as GameLauncher
|
198
189
|
};
|
199
190
|
//# sourceMappingURL=game-launcher.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"game-launcher.js","sources":["../../../../src/features/circle-games/game-launcher/game-launcher.tsx"],"sourcesContent":["import type { ICarouselRefs } from './comps/carousel/carousel-types';\nimport type { ITableDetails } from './comps/tables-card/tables-card-types';\nimport type {\n Game,\n Lesson,\n Puzzle,\n} from './dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IGameLauncherProps } from './game-launcher-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { memo, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { LOTTIE } from '../../../assets/lottie/lottie';\nimport { JOURNEY_ID_STUDENT } from '../../journey/journey-id/journey-id-student';\nimport { useJourney } from '../../journey/use-journey/use-journey';\nimport { CircularLoader } from '../../ui/loader/circular-loader/circular-loader';\nimport LottieAnimation from '../../ui/lottie-animation/lottie-animation';\nimport { ProjectType } from '../games/web-view/enums';\nimport { useCircleSounds } from '../hooks/use-circle-sounds/use-circle-sounds';\nimport { CircleSoundKey } from '../hooks/use-circle-sounds/use-circle-sounds-enums';\nimport { GAME_LAUNCHER_SIZE } from './comps/card-container/constants';\nimport { Carousel } from './comps/carousel/carousel';\nimport { GAME_LAUNCHER_ASSET_PADDING } from './comps/segmented-game-card/constants';\nimport { SegmentedGameCard } from './comps/segmented-game-card/segmented-game-card';\nimport { TablesCard } from './comps/tables-card/tables-card';\nimport { GAME_LAUNCHER_ANALYTICS_EVENTS } from './game-launcher-analytics-events';\nimport { useGameLauncherJourney } from './hooks/use-game-launcher-journey/use-game-launcher-journey';\nimport { useTableLauncherJourney } from './hooks/use-table-launcher-journey/use-table-launcher-journey';\n\nconst sleepyBoiDimension = GAME_LAUNCHER_SIZE + GAME_LAUNCHER_ASSET_PADDING;\n\nexport const GameLauncher: FC<IGameLauncherProps> = memo(\n ({\n onSegmentClick,\n journeyId,\n isError,\n data,\n isLoading,\n isTutorialOnboardingDone,\n defaultIndex = 0,\n }) => {\n const carouselRefs = useRef<ICarouselRefs>(null);\n\n const { isJourneyActive } = useJourney();\n\n const { playSwipSound, play } = useCircleSounds();\n\n const onTableSegmentClick = useCallback(\n (table: ITableDetails) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(table, ProjectType.TABLE);\n },\n [onSegmentClick, play],\n );\n\n const handleLessonSegmentClick = useCallback(\n (lesson: Lesson) => {\n if (lesson.status !== 'completed') {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(lesson, ProjectType.LESSON);\n }\n },\n [onSegmentClick, play],\n );\n\n const handleGameSegmentClick = useCallback(\n (game: Game) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(game, ProjectType.GAME);\n },\n [onSegmentClick, play],\n );\n\n const handlePuzzleSegmentClick = useCallback(\n (puzzle: Puzzle) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(puzzle, ProjectType.PUZZLE);\n },\n [onSegmentClick, play],\n );\n\n const {\n gameRefs,\n lessonRefs,\n puzzleRefs,\n startJourney: startLessonPuzzleGamesJourney,\n } = useGameLauncherJourney({\n carouselRefs,\n onSegmentClick,\n });\n\n const { startJourney: startTablesJourney, tableRef } = useTableLauncherJourney({\n carouselRefs,\n onTableSegmentClick,\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: () => handleLessonSegmentClick(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: () => handleGameSegmentClick(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: () => handlePuzzleSegmentClick(puzzle),\n }))}\n />,\n ];\n\n if (data.tables) {\n itemTypes = [\n ...itemTypes,\n <TablesCard\n ref={tableRef}\n label={data.tables.label}\n data={data.tables.data}\n onPress={onTableSegmentClick}\n openModesOfTable={data.tables.openModesOfTable}\n />,\n ];\n }\n }\n\n return itemTypes;\n }, [\n data,\n gameRefs,\n puzzleRefs,\n lessonRefs,\n handleLessonSegmentClick,\n handleGameSegmentClick,\n handlePuzzleSegmentClick,\n tableRef,\n onTableSegmentClick,\n ]);\n\n const sleepyBoiItem = useMemo(\n () => [\n <LottieAnimation\n src={LOTTIE.SLEEPY_BOI}\n width={sleepyBoiDimension}\n height={sleepyBoiDimension}\n />,\n ],\n [],\n );\n\n // Start game launcher journey only when isLoading has become false and data is available\n useEffect(() => {\n if (isLoading || !data || isJourneyActive) {\n return;\n }\n\n if (data?.puzzles && journeyId === JOURNEY_ID_STUDENT.CIRCLE_ACTIVITIES_INTRO_JOURNEY) {\n startLessonPuzzleGamesJourney(data?.puzzles, !!data?.lessons, journeyId);\n\n return; // CIRCLE_ACTIVITIES_INTRO_JOURNEY has higher priority\n }\n\n if (data?.tables && journeyId === JOURNEY_ID_STUDENT.CIRCLE_TABLES_INTRO_JOURNEY) {\n startTablesJourney(data?.tables, isTutorialOnboardingDone);\n }\n }, [\n data,\n isJourneyActive,\n isLoading,\n isTutorialOnboardingDone,\n journeyId,\n startLessonPuzzleGamesJourney,\n startTablesJourney,\n ]);\n\n if (isLoading) {\n return <CircularLoader />;\n }\n\n if (isError) {\n return (\n <Carousel\n ref={carouselRefs}\n items={sleepyBoiItem}\n analyticsNext={{\n analyticsLabel: '',\n }}\n analyticsPrev={{\n analyticsLabel: '',\n }}\n />\n );\n }\n\n return (\n <Carousel\n ref={carouselRefs}\n items={items}\n defaultIndex={defaultIndex}\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":["sleepyBoiDimension","GAME_LAUNCHER_SIZE","GAME_LAUNCHER_ASSET_PADDING","GameLauncher","memo","onSegmentClick","journeyId","isError","data","isLoading","isTutorialOnboardingDone","defaultIndex","carouselRefs","useRef","isJourneyActive","useJourney","playSwipSound","play","useCircleSounds","onTableSegmentClick","useCallback","table","CircleSoundKey","ProjectType","handleLessonSegmentClick","lesson","handleGameSegmentClick","game","handlePuzzleSegmentClick","puzzle","gameRefs","lessonRefs","puzzleRefs","startLessonPuzzleGamesJourney","useGameLauncherJourney","startTablesJourney","tableRef","useTableLauncherJourney","items","useMemo","itemTypes","jsx","SegmentedGameCard","TablesCard","sleepyBoiItem","LottieAnimation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,WAAWF,MAAc0C,EAAmB,iCAAiC;AACrF,UAAAf,EAA8BzB,KAAA,gBAAAA,EAAM,SAAS,CAAC,EAACA,KAAA,QAAAA,EAAM,UAASF,CAAS;AAEvE;AAAA,QACF;AAEA,QAAIE,KAAA,QAAAA,EAAM,UAAUF,MAAc0C,EAAmB,+BAChCb,EAAA3B,KAAA,gBAAAA,EAAM,QAAQE,CAAwB;AAAA;AAAA,IAC3D,GACC;AAAA,MACDF;AAAA,MACAM;AAAA,MACAL;AAAA,MACAC;AAAA,MACAJ;AAAA,MACA2B;AAAA,MACAE;AAAA,IAAA,CACD,GAEG1B,sBACMwC,GAAe,CAAA,CAAA,IAGrB1C,IAEA,gBAAAkC;AAAA,MAACS;AAAA,MAAA;AAAA,QACC,KAAKtC;AAAA,QACL,OAAOgC;AAAA,QACP,eAAe;AAAA,UACb,gBAAgB;AAAA,QAClB;AAAA,QACA,eAAe;AAAA,UACb,gBAAgB;AAAA,QAClB;AAAA,MAAA;AAAA,IAAA,IAMJ,gBAAAH;AAAA,MAACS;AAAA,MAAA;AAAA,QACC,KAAKtC;AAAA,QACL,OAAA0B;AAAA,QACA,cAAA3B;AAAA,QACA,QAAQK;AAAA,QACR,QAAQA;AAAA,QACR,eAAe;AAAA,UACb,gBAAgBmC,EAA+B;AAAA,QACjD;AAAA,QACA,eAAe;AAAA,UACb,gBAAgBA,EAA+B;AAAA,QACjD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;"}
|
1
|
+
{"version":3,"file":"game-launcher.js","sources":["../../../../src/features/circle-games/game-launcher/game-launcher.tsx"],"sourcesContent":["import type { ICarouselRefs } from './comps/carousel/carousel-types';\nimport type { ITableDetails } from './comps/tables-card/tables-card-types';\nimport type {\n Game,\n Lesson,\n Puzzle,\n} from './dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IGameLauncherProps } from './game-launcher-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { memo, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { LOTTIE } from '../../../assets/lottie/lottie';\nimport { JOURNEY_ID_STUDENT } from '../../journey/journey-id/journey-id-student';\nimport { useJourney } from '../../journey/use-journey/use-journey';\nimport { CircularLoader } from '../../ui/loader/circular-loader/circular-loader';\nimport LottieAnimation from '../../ui/lottie-animation/lottie-animation';\nimport { ProjectType } from '../games/web-view/enums';\nimport { useCircleSounds } from '../hooks/use-circle-sounds/use-circle-sounds';\nimport { CircleSoundKey } from '../hooks/use-circle-sounds/use-circle-sounds-enums';\nimport { GAME_LAUNCHER_SIZE } from './comps/card-container/constants';\nimport { Carousel } from './comps/carousel/carousel';\nimport { GAME_LAUNCHER_ASSET_PADDING } from './comps/segmented-game-card/constants';\nimport { SegmentedGameCard } from './comps/segmented-game-card/segmented-game-card';\nimport { TablesCard } from './comps/tables-card/tables-card';\nimport { GAME_LAUNCHER_ANALYTICS_EVENTS } from './game-launcher-analytics-events';\nimport { useGameLauncherJourney } from './hooks/use-game-launcher-journey/use-game-launcher-journey';\nimport { useTableLauncherJourney } from './hooks/use-table-launcher-journey/use-table-launcher-journey';\n\nconst sleepyBoiDimension = GAME_LAUNCHER_SIZE + GAME_LAUNCHER_ASSET_PADDING;\n\nexport const GameLauncher: FC<IGameLauncherProps> = memo(\n ({\n onSegmentClick,\n journeyId,\n isError,\n data,\n isLoading,\n isTutorialOnboardingDone,\n defaultIndex = 0,\n }) => {\n const carouselRefs = useRef<ICarouselRefs>(null);\n\n const { isJourneyActive } = useJourney();\n\n const { playSwipSound, play } = useCircleSounds();\n\n const onTableSegmentClick = useCallback(\n (table: ITableDetails) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(table, ProjectType.TABLE);\n },\n [onSegmentClick, play],\n );\n\n const handleLessonSegmentClick = useCallback(\n (lesson: Lesson) => {\n if (lesson.status !== 'completed') {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(lesson, ProjectType.LESSON);\n }\n },\n [onSegmentClick, play],\n );\n\n const handleGameSegmentClick = useCallback(\n (game: Game) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(game, ProjectType.GAME);\n },\n [onSegmentClick, play],\n );\n\n const handlePuzzleSegmentClick = useCallback(\n (puzzle: Puzzle) => {\n play(CircleSoundKey.GAME_CARD_CLICK);\n onSegmentClick(puzzle, ProjectType.PUZZLE);\n },\n [onSegmentClick, play],\n );\n\n const {\n gameRefs,\n lessonRefs,\n puzzleRefs,\n startJourney: startLessonPuzzleGamesJourney,\n } = useGameLauncherJourney({\n carouselRefs,\n onSegmentClick,\n });\n\n const { startJourney: startTablesJourney, tableRef } = useTableLauncherJourney({\n carouselRefs,\n onTableSegmentClick,\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: () => handleLessonSegmentClick(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: () => handleGameSegmentClick(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: () => handlePuzzleSegmentClick(puzzle),\n }))}\n />,\n ];\n\n if (data.tables) {\n itemTypes = [\n ...itemTypes,\n <TablesCard\n ref={tableRef}\n label={data.tables.label}\n data={data.tables.data}\n onPress={onTableSegmentClick}\n openModesOfTable={data.tables.openModesOfTable}\n />,\n ];\n }\n }\n\n return itemTypes;\n }, [\n data,\n gameRefs,\n puzzleRefs,\n lessonRefs,\n handleLessonSegmentClick,\n handleGameSegmentClick,\n handlePuzzleSegmentClick,\n tableRef,\n onTableSegmentClick,\n ]);\n\n const sleepyBoiItem = useMemo(\n () => [\n <LottieAnimation\n src={LOTTIE.SLEEPY_BOI}\n width={sleepyBoiDimension}\n height={sleepyBoiDimension}\n />,\n ],\n [],\n );\n\n // Start game launcher journey only when isLoading has become false and data is available\n useEffect(() => {\n if (isLoading || !data || isJourneyActive) {\n return;\n }\n\n if (data?.puzzles && journeyId === JOURNEY_ID_STUDENT.CIRCLE_ACTIVITIES_INTRO_JOURNEY) {\n startLessonPuzzleGamesJourney(data?.puzzles, !!data?.lessons, journeyId);\n\n return; // CIRCLE_ACTIVITIES_INTRO_JOURNEY has higher priority\n }\n\n if (data?.tables && journeyId === JOURNEY_ID_STUDENT.CIRCLE_TABLES_INTRO_JOURNEY) {\n startTablesJourney(data?.tables, isTutorialOnboardingDone);\n }\n }, [\n data,\n isJourneyActive,\n isLoading,\n isTutorialOnboardingDone,\n journeyId,\n startLessonPuzzleGamesJourney,\n startTablesJourney,\n ]);\n\n return (\n <>\n <Carousel\n ref={carouselRefs}\n items={isError ? sleepyBoiItem : items}\n defaultIndex={defaultIndex}\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 {isLoading && <CircularLoader />}\n </>\n );\n },\n);\n"],"names":["sleepyBoiDimension","GAME_LAUNCHER_SIZE","GAME_LAUNCHER_ASSET_PADDING","GameLauncher","memo","onSegmentClick","journeyId","isError","data","isLoading","isTutorialOnboardingDone","defaultIndex","carouselRefs","useRef","isJourneyActive","useJourney","playSwipSound","play","useCircleSounds","onTableSegmentClick","useCallback","table","CircleSoundKey","ProjectType","handleLessonSegmentClick","lesson","handleGameSegmentClick","game","handlePuzzleSegmentClick","puzzle","gameRefs","lessonRefs","puzzleRefs","startLessonPuzzleGamesJourney","useGameLauncherJourney","startTablesJourney","tableRef","useTableLauncherJourney","items","useMemo","itemTypes","jsx","SegmentedGameCard","TablesCard","sleepyBoiItem","LottieAnimation","LOTTIE","useEffect","JOURNEY_ID_STUDENT","jsxs","Fragment","Carousel","GAME_LAUNCHER_ANALYTICS_EVENTS","CircularLoader"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAMA,IAAqBC,IAAqBC,GAEnCC,KAAuCC;AAAA,EAClD,CAAC;AAAA,IACC,gBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,EAAA,MACX;AACE,UAAAC,IAAeC,EAAsB,IAAI,GAEzC,EAAE,iBAAAC,MAAoBC,KAEtB,EAAE,eAAAC,GAAe,MAAAC,EAAK,IAAIC,EAAgB,GAE1CC,IAAsBC;AAAA,MAC1B,CAACC,MAAyB;AACxB,QAAAJ,EAAKK,EAAe,eAAe,GACpBjB,EAAAgB,GAAOE,EAAY,KAAK;AAAA,MACzC;AAAA,MACA,CAAClB,GAAgBY,CAAI;AAAA,IAAA,GAGjBO,IAA2BJ;AAAA,MAC/B,CAACK,MAAmB;AACd,QAAAA,EAAO,WAAW,gBACpBR,EAAKK,EAAe,eAAe,GACpBjB,EAAAoB,GAAQF,EAAY,MAAM;AAAA,MAE7C;AAAA,MACA,CAAClB,GAAgBY,CAAI;AAAA,IAAA,GAGjBS,IAAyBN;AAAA,MAC7B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
2
|
-
import { createContext as
|
3
|
-
import { Coachmark as
|
4
|
-
import { usePostUserJourney as
|
5
|
-
import { Overlay as
|
6
|
-
const
|
7
|
-
const [
|
8
|
-
data:
|
1
|
+
import { jsxs as U, jsx as w } from "react/jsx-runtime";
|
2
|
+
import { createContext as b, useState as h, useRef as k, useCallback as l, useMemo as q, useEffect as R } from "react";
|
3
|
+
import { Coachmark as L } from "../comps/coachmark/coachmark.js";
|
4
|
+
import { usePostUserJourney as N, useGetUserJourney as M } from "../user-journey-api/user-journey-api.js";
|
5
|
+
import { Overlay as z } from "./journey-styled.js";
|
6
|
+
const G = b(null), K = ({ children: T, appId: u, userId: n }) => {
|
7
|
+
const [p, v] = h([]), [s, c] = h([]), [J, x] = h(!1), a = k(-1), r = k(), d = k([]), { post: g } = N(), {
|
8
|
+
data: f = null,
|
9
9
|
get: _,
|
10
|
-
isProcessing:
|
11
|
-
} =
|
12
|
-
(e,
|
13
|
-
if (
|
10
|
+
isProcessing: D
|
11
|
+
} = M(), $ = l(
|
12
|
+
(e, t) => {
|
13
|
+
if (s.length > 0) {
|
14
14
|
console.error(
|
15
15
|
`setJourney: Other Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
16
16
|
);
|
17
17
|
return;
|
18
18
|
}
|
19
|
-
|
19
|
+
x(!0), r.current = e, a.current = -1, c([...t]);
|
20
20
|
},
|
21
|
-
[
|
22
|
-
),
|
23
|
-
|
21
|
+
[s.length]
|
22
|
+
), m = l(() => {
|
23
|
+
d.current.forEach((e) => {
|
24
24
|
clearTimeout(e);
|
25
|
-
}),
|
26
|
-
}, []),
|
25
|
+
}), d.current = [], r.current = void 0, a.current = -1, c([]), x(!1);
|
26
|
+
}, []), A = l(
|
27
27
|
(e) => {
|
28
|
-
v((
|
28
|
+
v((t) => [...t, e]), g({
|
29
29
|
app_id: u,
|
30
|
-
user_id:
|
30
|
+
user_id: n,
|
31
31
|
journey_id: e,
|
32
32
|
journey_status: "COMPLETED"
|
33
|
-
}),
|
33
|
+
}), m();
|
34
34
|
},
|
35
|
-
[u,
|
36
|
-
),
|
35
|
+
[u, m, g, n]
|
36
|
+
), P = l((e, t) => {
|
37
37
|
if (!r.current || e !== r.current) {
|
38
38
|
console.error(
|
39
39
|
r.current ? `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}` : "addCoachmark was called before setJourney and Journey ID is undefined"
|
40
40
|
);
|
41
41
|
return;
|
42
42
|
}
|
43
|
-
console.log(`addCoachmark: Journey ID: ${e}`), c((
|
44
|
-
}, []),
|
45
|
-
(e,
|
43
|
+
console.log(`addCoachmark: Journey ID: ${e}`), c((y) => [...y, t]);
|
44
|
+
}, []), E = l(
|
45
|
+
(e, t = !1, y = 0) => {
|
46
46
|
if (!r.current || e !== r.current) {
|
47
47
|
console.error(
|
48
48
|
r.current ? "nextCoachmark was called before setJourney" : `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
49
49
|
);
|
50
50
|
return;
|
51
51
|
}
|
52
|
-
|
53
|
-
const
|
54
|
-
clearTimeout(
|
55
|
-
const
|
52
|
+
y !== 0 && c((o) => o.map((i) => ({ ...i, isActive: !1 })));
|
53
|
+
const j = setTimeout(() => {
|
54
|
+
clearTimeout(j);
|
55
|
+
const o = a.current + 1;
|
56
56
|
c((i) => {
|
57
|
-
if (
|
57
|
+
if (o >= i.length || i.length === 0)
|
58
58
|
return r.current = void 0, a.current = -1, [];
|
59
|
-
a.current =
|
60
|
-
const
|
61
|
-
return
|
59
|
+
a.current = o;
|
60
|
+
const C = [...i];
|
61
|
+
return C[o].isActive = !0, o > 0 && (C[o - 1].isActive = t), C;
|
62
62
|
});
|
63
|
-
},
|
64
|
-
|
63
|
+
}, y);
|
64
|
+
d.current.push(j);
|
65
65
|
},
|
66
66
|
[]
|
67
|
-
),
|
67
|
+
), O = q(
|
68
68
|
() => ({
|
69
|
-
nextCoachmark:
|
70
|
-
setJourney:
|
71
|
-
addCoachmark:
|
72
|
-
clearJourney:
|
73
|
-
endJourney:
|
74
|
-
coachmarks:
|
75
|
-
userCompletedJourneyIds:
|
76
|
-
isJourneyActive:
|
69
|
+
nextCoachmark: E,
|
70
|
+
setJourney: $,
|
71
|
+
addCoachmark: P,
|
72
|
+
clearJourney: m,
|
73
|
+
endJourney: A,
|
74
|
+
coachmarks: s,
|
75
|
+
userCompletedJourneyIds: p,
|
76
|
+
isJourneyActive: J
|
77
77
|
}),
|
78
78
|
[
|
79
|
-
|
80
|
-
|
81
|
-
w,
|
82
|
-
y,
|
79
|
+
E,
|
80
|
+
$,
|
83
81
|
P,
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
m,
|
83
|
+
A,
|
84
|
+
s,
|
85
|
+
p,
|
86
|
+
J
|
87
87
|
]
|
88
88
|
);
|
89
|
-
return
|
90
|
-
u &&
|
89
|
+
return R(() => {
|
90
|
+
u && n && _(n, {
|
91
91
|
app_id: u,
|
92
|
-
user_id:
|
92
|
+
user_id: n,
|
93
93
|
journey_status: "COMPLETED"
|
94
94
|
});
|
95
|
-
}, [u, _,
|
96
|
-
if (
|
97
|
-
const e =
|
95
|
+
}, [u, _, n]), R(() => {
|
96
|
+
if (f) {
|
97
|
+
const e = f.map((t) => t.journey_id);
|
98
98
|
v(e);
|
99
99
|
}
|
100
|
-
}, [
|
101
|
-
|
102
|
-
|
100
|
+
}, [f]), /* @__PURE__ */ U(G.Provider, { value: O, children: [
|
101
|
+
J && !D && /* @__PURE__ */ w(z, { children: s.map((e, t) => /* @__PURE__ */ w(L, { coachmark: e }, `coachmark-${t}`)) }),
|
102
|
+
T
|
103
103
|
] });
|
104
104
|
};
|
105
105
|
export {
|
106
|
-
|
107
|
-
|
106
|
+
G as JourneyContext,
|
107
|
+
K as JourneyProvider
|
108
108
|
};
|
109
109
|
//# sourceMappingURL=journey-context-provider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n} from './journey-context-types';\nimport type { FC } from 'react';\n\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<IJourneyProviderProps> = ({ children, appId, userId }) => {\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[]>([]);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const {\n data: userCompletedJourneys = null,\n get: getJourneyProgress,\n isProcessing,\n } = useGetUserJourney();\n\n const showCoachmarks =\n appId === '' // Otherwise coachmark stories wont work\n ? coachmarkList.length > 0\n : userCompletedJourneys && !isProcessing && coachmarkList.length > 0;\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n console.log(`setJourney: Journey ID: ${id}`);\n\n setIsJourneyActive(true);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n setUserCompletedJourneyIds(prev => [...prev, journeyId]);\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n clearJourney();\n },\n [appId, clearJourney, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n console.log(`addCoachmark: Journey ID: ${id}`);\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n console.log(nextCoachmark);\n\n if (delayInMs !== 0) {\n // If delay is not 0, we will hide all them coachmarks and reveal only after the delay\n setCoachmarkList(prevList => {\n return prevList.map((item: ICoachmarkProps) => {\n return { ...item, isActive: false };\n });\n });\n }\n\n const timer = setTimeout(() => {\n clearTimeout(timer);\n const currIndex = currentIndex.current + 1;\n\n setCoachmarkList(prevList => {\n // Finish onboarding\n if (currIndex >= prevList.length || prevList.length === 0) {\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n\n return [];\n }\n\n currentIndex.current = currIndex;\n const updatedCoachmarkList = [...prevList];\n\n (updatedCoachmarkList[currIndex] as ICoachmarkProps).isActive = true;\n\n if (currIndex > 0) {\n (updatedCoachmarkList[currIndex - 1] as ICoachmarkProps).isActive = keepPrevActive;\n }\n\n return updatedCoachmarkList;\n });\n }, delayInMs);\n\n timerRefs.current.push(timer);\n },\n [],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {showCoachmarks && (\n <S.Overlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","userCompletedJourneyIds","setUserCompletedJourneyIds","useState","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","isProcessing","useGetUserJourney","showCoachmarks","setJourney","useCallback","id","coachmarks","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","S.Overlay","index","jsx","Coachmark"],"mappings":";;;;;AAea,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,Q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AG/DK;AAAA,QAAA,CACR;AAAA,SACAJ,CAAS;AAEF,MAAArB,EAAA,QAAQ,KAAKa,CAAK;AAAA,IAC9B;AAAA,IACA,CAAC;AAAA,EAAA,GAGGa,IAAwCC;AAAA,IAC5C,OAAO;AAAA,MACL,eAAAR;AAAA,MACA,YAAAX;AAAA,MACA,cAAAS;AAAA,MACA,cAAAL;AAAA,MACA,YAAAE;AAAA,MACA,YAAYrB;AAAA,MACZ,yBAAAH;AAAA,MACA,iBAAAK;AAAA,IAAA;AAAA,IAEF;AAAA,MACEwB;AAAA,MACAX;AAAA,MACAS;AAAA,MACAL;AAAA,MACAE;AAAA,MACArB;AAAA,MACAH;AAAA,MACAK;AAAA,IACF;AAAA,EAAA;AAIF,SAAAiC,EAAU,MAAM;AACd,IAAIxC,KAASC,KACXe,EAAmBf,GAAQ;AAAA,MACzB,QAAQD;AAAA,MACR,SAASC;AAAA,MACT,gBAAgB;AAAA,IAAA,CACjB;AAAA,EAEF,GAAA,CAACD,GAAOgB,GAAoBf,CAAM,CAAC,GAGtCuC,EAAU,MAAM;AACd,QAAIzB,GAAuB;AACzB,YAAM0B,IAA2B1B,EAAsB,IAAI,CAAA2B,MAAWA,EAAQ,UAAU;AAExF,MAAAvC,EAA2BsC,CAAwB;AAAA,IACrD;AAAA,EAAA,GACC,CAAC1B,CAAqB,CAAC,GAGvB,gBAAA4B,EAAA/C,EAAe,UAAf,EAAwB,OAAO0C,GAC7B,UAAA;AAAA,IAAAnB,uBACEyB,GAAA,EACE,UAAAvC,EAAc,IAAI,CAACyB,GAAWe,MAC7B,gBAAAC,EAACC,KAAqC,WAAAjB,KAAtB,aAAae,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED9C;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
1
|
+
{"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n} from './journey-context-types';\nimport type { FC } from 'react';\n\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<IJourneyProviderProps> = ({ children, appId, userId }) => {\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[]>([]);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const {\n data: userCompletedJourneys = null,\n get: getJourneyProgress,\n isProcessing,\n } = useGetUserJourney();\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n setIsJourneyActive(true);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n setUserCompletedJourneyIds(prev => [...prev, journeyId]);\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n clearJourney();\n },\n [appId, clearJourney, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n console.log(`addCoachmark: Journey ID: ${id}`);\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n\n if (delayInMs !== 0) {\n // If delay is not 0, we will hide all them coachmarks and reveal only after the delay\n setCoachmarkList(prevList => {\n return prevList.map((item: ICoachmarkProps) => {\n return { ...item, isActive: false };\n });\n });\n }\n\n const timer = setTimeout(() => {\n clearTimeout(timer);\n const currIndex = currentIndex.current + 1;\n\n setCoachmarkList(prevList => {\n // Finish onboarding\n if (currIndex >= prevList.length || prevList.length === 0) {\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n\n return [];\n }\n\n currentIndex.current = currIndex;\n const updatedCoachmarkList = [...prevList];\n\n (updatedCoachmarkList[currIndex] as ICoachmarkProps).isActive = true;\n\n if (currIndex > 0) {\n (updatedCoachmarkList[currIndex - 1] as ICoachmarkProps).isActive = keepPrevActive;\n }\n\n return updatedCoachmarkList;\n });\n }, delayInMs);\n\n timerRefs.current.push(timer);\n },\n [],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {isJourneyActive && !isProcessing && (\n <S.Overlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","userCompletedJourneyIds","setUserCompletedJourneyIds","useState","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","isProcessing","useGetUserJourney","setJourney","useCallback","id","coachmarks","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","jsx","S.Overlay","index","Coachmark"],"mappings":";;;;;AAea,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAACC,GAAyBC,CAA0B,IAAIC,EAAuB,CAAE,CAAA,GACjF,CAACC,GAAeC,CAAgB,IAAIF,EAA4B,CAAE,CAAA,GAClE,CAACG,GAAiBC,CAAkB,IAAIJ,EAAS,EAAK,GACtDK,IAAeC,EAAO,EAAE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AAAA,IAAA;AAAA,IAEF;AAAA,MACEuB;AAAA,MACAX;AAAA,MACAS;AAAA,MACAL;AAAA,MACAE;AAAA,MACApB;AAAA,MACAH;AAAA,MACAK;AAAA,IACF;AAAA,EAAA;AAIF,SAAAgC,EAAU,MAAM;AACd,IAAIvC,KAASC,KACXe,EAAmBf,GAAQ;AAAA,MACzB,QAAQD;AAAA,MACR,SAASC;AAAA,MACT,gBAAgB;AAAA,IAAA,CACjB;AAAA,EAEF,GAAA,CAACD,GAAOgB,GAAoBf,CAAM,CAAC,GAGtCsC,EAAU,MAAM;AACd,QAAIxB,GAAuB;AACzB,YAAMyB,IAA2BzB,EAAsB,IAAI,CAAA0B,MAAWA,EAAQ,UAAU;AAExF,MAAAtC,EAA2BqC,CAAwB;AAAA,IACrD;AAAA,EAAA,GACC,CAACzB,CAAqB,CAAC,GAGvB,gBAAA2B,EAAA9C,EAAe,UAAf,EAAwB,OAAOyC,GAC7B,UAAA;AAAA,IAAA9B,KAAmB,CAACU,KACnB,gBAAA0B,EAACC,GAAA,EACE,YAAc,IAAI,CAACf,GAAWgB,wBAC5BC,GAAqC,EAAA,WAAAjB,EAAA,GAAtB,aAAagB,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED9C;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
2
|
-
import { LOTTIE as
|
2
|
+
import { LOTTIE as o } from "../../../../assets/lottie/lottie.js";
|
3
3
|
import i from "../../layout/flex-view.js";
|
4
|
-
import
|
5
|
-
const
|
4
|
+
import r from "../../lottie-animation/lottie-animation.js";
|
5
|
+
const s = () => /* @__PURE__ */ t(
|
6
6
|
i,
|
7
7
|
{
|
8
8
|
$width: "100%",
|
@@ -10,10 +10,11 @@ const h = () => /* @__PURE__ */ t(
|
|
10
10
|
$alignItems: "center",
|
11
11
|
$justifyContent: "center",
|
12
12
|
$background: "TRANSPARENT",
|
13
|
-
|
13
|
+
style: { zIndex: 9999, position: "absolute", background: "#000000" },
|
14
|
+
children: /* @__PURE__ */ t(r, { width: "50%", height: "50%", src: o.CIRCULAR_LOADER })
|
14
15
|
}
|
15
16
|
);
|
16
17
|
export {
|
17
|
-
|
18
|
+
s as CircularLoader
|
18
19
|
};
|
19
20
|
//# sourceMappingURL=circular-loader.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"circular-loader.js","sources":["../../../../../src/features/ui/loader/circular-loader/circular-loader.tsx"],"sourcesContent":["import { LOTTIE } from '../../../../assets/lottie/lottie';\nimport FlexView from '../../layout/flex-view';\nimport LottieAnimation from '../../lottie-animation/lottie-animation';\n\nexport const CircularLoader = () => (\n <FlexView\n $width=\"100%\"\n $height=\"100%\"\n $alignItems=\"center\"\n $justifyContent=\"center\"\n $background=\"TRANSPARENT\"\n >\n <LottieAnimation width=\"50%\" height=\"50%\" src={LOTTIE.CIRCULAR_LOADER} />\n </FlexView>\n);\n"],"names":["CircularLoader","jsx","FlexView","LottieAnimation","LOTTIE"],"mappings":";;;;AAIO,MAAMA,IAAiB,MAC5B,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,aAAY;AAAA,IACZ,iBAAgB;AAAA,IAChB,aAAY;AAAA,
|
1
|
+
{"version":3,"file":"circular-loader.js","sources":["../../../../../src/features/ui/loader/circular-loader/circular-loader.tsx"],"sourcesContent":["import { LOTTIE } from '../../../../assets/lottie/lottie';\nimport FlexView from '../../layout/flex-view';\nimport LottieAnimation from '../../lottie-animation/lottie-animation';\n\nexport const CircularLoader = () => (\n <FlexView\n $width=\"100%\"\n $height=\"100%\"\n $alignItems=\"center\"\n $justifyContent=\"center\"\n $background=\"TRANSPARENT\"\n style={{ zIndex: 9999, position: 'absolute', background: '#000000' }}\n >\n <LottieAnimation width=\"50%\" height=\"50%\" src={LOTTIE.CIRCULAR_LOADER} />\n </FlexView>\n);\n"],"names":["CircularLoader","jsx","FlexView","LottieAnimation","LOTTIE"],"mappings":";;;;AAIO,MAAMA,IAAiB,MAC5B,gBAAAC;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,aAAY;AAAA,IACZ,iBAAgB;AAAA,IAChB,aAAY;AAAA,IACZ,OAAO,EAAE,QAAQ,MAAM,UAAU,YAAY,YAAY,UAAU;AAAA,IAEnE,UAAA,gBAAAD,EAACE,KAAgB,OAAM,OAAM,QAAO,OAAM,KAAKC,EAAO,gBAAiB,CAAA;AAAA,EAAA;AACzE;"}
|