@cuemath/leap 3.1.2-j3 → 3.1.2
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/assets/illustrations/illustrations.js +2 -1
- package/dist/assets/illustrations/illustrations.js.map +1 -1
- package/dist/assets/line-icons/icons/check.js +3 -3
- package/dist/assets/line-icons/icons/check.js.map +1 -1
- package/dist/assets/line-icons/icons/puzzle-icon.js +51 -0
- package/dist/assets/line-icons/icons/puzzle-icon.js.map +1 -0
- package/dist/assets/line-icons/icons/share.js +48 -0
- package/dist/assets/line-icons/icons/share.js.map +1 -0
- package/dist/assets/line-icons/icons/tile.js +54 -0
- package/dist/assets/line-icons/icons/tile.js.map +1 -0
- package/dist/features/auth/account-selector/account-selector.js +36 -56
- package/dist/features/auth/account-selector/account-selector.js.map +1 -1
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout-styles.js +12 -0
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout-styles.js.map +1 -0
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout.js +9 -8
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout.js.map +1 -1
- package/dist/features/auth/comps/auth-static-panel/auth-static-panel.js +1 -1
- package/dist/features/auth/comps/auth-static-panel/auth-static-panel.js.map +1 -1
- package/dist/features/auth/forgot-password/forgot-password-styled.js +3 -15
- package/dist/features/auth/forgot-password/forgot-password-styled.js.map +1 -1
- package/dist/features/auth/forgot-password/otp-form/otp-form.js +29 -29
- package/dist/features/auth/forgot-password/otp-form/otp-form.js.map +1 -1
- package/dist/features/auth/forgot-password/reset-password-form/reset-password-form.js +18 -14
- package/dist/features/auth/forgot-password/reset-password-form/reset-password-form.js.map +1 -1
- package/dist/features/auth/forgot-password/user-identifier-form/user-identifier-form.js +24 -23
- package/dist/features/auth/forgot-password/user-identifier-form/user-identifier-form.js.map +1 -1
- package/dist/features/auth/login/identifier-otp-form/identifier-otp-form-styled.js +2 -4
- package/dist/features/auth/login/identifier-otp-form/identifier-otp-form-styled.js.map +1 -1
- package/dist/features/auth/login/identifier-otp-form/identifier-otp-form.js +75 -85
- package/dist/features/auth/login/identifier-otp-form/identifier-otp-form.js.map +1 -1
- package/dist/features/auth/login/social-account-not-found/social-account-not-found.js +21 -27
- package/dist/features/auth/login/social-account-not-found/social-account-not-found.js.map +1 -1
- package/dist/features/auth/login/social-login-methods/social-login-methods.js +34 -43
- package/dist/features/auth/login/social-login-methods/social-login-methods.js.map +1 -1
- package/dist/features/auth/login/username-password-form/username-password-form.js +21 -22
- package/dist/features/auth/login/username-password-form/username-password-form.js.map +1 -1
- package/dist/features/auth/user-list/user-item/user-item.js +24 -25
- package/dist/features/auth/user-list/user-item/user-item.js.map +1 -1
- package/dist/features/auth/user-list/user-list.js +51 -60
- package/dist/features/auth/user-list/user-list.js.map +1 -1
- package/dist/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.js +74 -74
- package/dist/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.js.map +1 -1
- package/dist/features/cue-canvas/bottombar/homework-controls.js +73 -0
- package/dist/features/cue-canvas/bottombar/homework-controls.js.map +1 -0
- package/dist/features/cue-canvas/cue-canvas-context.js +8 -5
- package/dist/features/cue-canvas/cue-canvas-context.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-core.js +84 -74
- package/dist/features/cue-canvas/cue-canvas-core.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-helpers.js +31 -25
- package/dist/features/cue-canvas/cue-canvas-helpers.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-provider.js +14 -12
- package/dist/features/cue-canvas/cue-canvas-provider.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas.js +66 -59
- package/dist/features/cue-canvas/cue-canvas.js.map +1 -1
- package/dist/features/cue-canvas/cue-cavas-styled.js +45 -42
- package/dist/features/cue-canvas/cue-cavas-styled.js.map +1 -1
- package/dist/features/cue-canvas/hooks/use-canvas-sync-broker.js +61 -54
- package/dist/features/cue-canvas/hooks/use-canvas-sync-broker.js.map +1 -1
- package/dist/features/cue-canvas/hooks/use-config-updater.js +12 -0
- package/dist/features/cue-canvas/hooks/use-config-updater.js.map +1 -0
- package/dist/features/cue-canvas/hooks/use-cue-canvas-actions.js +18 -14
- package/dist/features/cue-canvas/hooks/use-cue-canvas-actions.js.map +1 -1
- package/dist/features/cue-canvas/hooks/use-upload-helper.js +23 -0
- package/dist/features/cue-canvas/hooks/use-upload-helper.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/homework/helper.js +20 -0
- package/dist/features/cue-canvas/sidebar/homework/helper.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/homework/homework-menu.js +33 -0
- package/dist/features/cue-canvas/sidebar/homework/homework-menu.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/homework/homework-request.js +68 -0
- package/dist/features/cue-canvas/sidebar/homework/homework-request.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/homework/homework-styled.js +25 -0
- package/dist/features/cue-canvas/sidebar/homework/homework-styled.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/homework/homework.js +39 -0
- package/dist/features/cue-canvas/sidebar/homework/homework.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/api/get-puzzles.js +13 -0
- package/dist/features/cue-canvas/sidebar/puzzles/api/get-puzzles.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/filter-selection-menu.js +60 -0
- package/dist/features/cue-canvas/sidebar/puzzles/filter-selection-menu.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/filters-section.js +44 -0
- package/dist/features/cue-canvas/sidebar/puzzles/filters-section.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/filters.js +107 -0
- package/dist/features/cue-canvas/sidebar/puzzles/filters.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/hooks/use-fetch-cue-canvas-activity.js +42 -0
- package/dist/features/cue-canvas/sidebar/puzzles/hooks/use-fetch-cue-canvas-activity.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/launch-puzzle.js +84 -0
- package/dist/features/cue-canvas/sidebar/puzzles/launch-puzzle.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/puzzle-menu-header.js +36 -0
- package/dist/features/cue-canvas/sidebar/puzzles/puzzle-menu-header.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/puzzle-menu.js +133 -0
- package/dist/features/cue-canvas/sidebar/puzzles/puzzle-menu.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/puzzles-styled.js +96 -0
- package/dist/features/cue-canvas/sidebar/puzzles/puzzles-styled.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/puzzles.js +29 -0
- package/dist/features/cue-canvas/sidebar/puzzles/puzzles.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/puzzles/utils.js +120 -0
- package/dist/features/cue-canvas/sidebar/puzzles/utils.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/sidebar-styled.js +32 -0
- package/dist/features/cue-canvas/sidebar/sidebar-styled.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/sidebar.js +29 -0
- package/dist/features/cue-canvas/sidebar/sidebar.js.map +1 -0
- package/dist/features/cue-canvas/sidebar/tiles/tile.js +16 -0
- package/dist/features/cue-canvas/sidebar/tiles/tile.js.map +1 -0
- package/dist/features/cue-canvas/toolbar/grid-menu.js +13 -13
- package/dist/features/cue-canvas/toolbar/grid-menu.js.map +1 -1
- package/dist/features/cue-canvas/toolbar/tool.js +22 -20
- package/dist/features/cue-canvas/toolbar/tool.js.map +1 -1
- package/dist/features/homework/styles.js +5 -4
- package/dist/features/homework/styles.js.map +1 -1
- package/dist/features/hooks/use-debounce.js +16 -0
- package/dist/features/hooks/use-debounce.js.map +1 -0
- package/dist/features/milestone/create/comps/add-custom-chapter/course-catalog.js +38 -36
- package/dist/features/milestone/create/comps/add-custom-chapter/course-catalog.js.map +1 -1
- package/dist/features/milestone/create/comps/add-custom-chapter/hooks/use-catalog-helpers.js +24 -22
- package/dist/features/milestone/create/comps/add-custom-chapter/hooks/use-catalog-helpers.js.map +1 -1
- package/dist/features/milestone/create/comps/chapters-selection-step/chapter-selection-step-v2/chapter-category/chapter-category-container.js +23 -22
- package/dist/features/milestone/create/comps/chapters-selection-step/chapter-selection-step-v2/chapter-category/chapter-category-container.js.map +1 -1
- package/dist/features/milestone/create/comps/chapters-selection-step/utils.js +49 -47
- package/dist/features/milestone/create/comps/chapters-selection-step/utils.js.map +1 -1
- package/dist/features/milestone/create/comps/class-details-step/class-details-step.js +94 -87
- package/dist/features/milestone/create/comps/class-details-step/class-details-step.js.map +1 -1
- package/dist/features/milestone/create/comps/class-details-step/class-details-utils.js +13 -12
- package/dist/features/milestone/create/comps/class-details-step/class-details-utils.js.map +1 -1
- package/dist/features/milestone/create/comps/test-type-step/test-type-step.js +23 -21
- package/dist/features/milestone/create/comps/test-type-step/test-type-step.js.map +1 -1
- package/dist/features/milestone/create/milestone-create-helpers.js +165 -162
- package/dist/features/milestone/create/milestone-create-helpers.js.map +1 -1
- package/dist/features/trial-session/comps/pricing/india-pricing/index.js +96 -0
- package/dist/features/trial-session/comps/pricing/india-pricing/index.js.map +1 -0
- package/dist/features/trial-session/comps/pricing/india-pricing/india-pricing-styled.js +59 -0
- package/dist/features/trial-session/comps/pricing/india-pricing/india-pricing-styled.js.map +1 -0
- package/dist/features/trial-session/comps/pricing/pricing.js +36 -35
- package/dist/features/trial-session/comps/pricing/pricing.js.map +1 -1
- package/dist/features/ui/buttons/button/button-styled.js +29 -29
- package/dist/features/ui/buttons/button/button-styled.js.map +1 -1
- package/dist/features/ui/stepper/stepper.js +7 -7
- package/dist/features/worksheet/worksheet/hooks/use-s3-helper.js +22 -19
- package/dist/features/worksheet/worksheet/hooks/use-s3-helper.js.map +1 -1
- package/dist/index.d.ts +54 -24
- package/dist/index.js +202 -202
- package/dist/static/ellipse-clip.dfb25608.svg +1 -0
- package/package.json +1 -1
- package/dist/features/auth/account-selector/account-selector-styled.js +0 -9
- package/dist/features/auth/account-selector/account-selector-styled.js.map +0 -1
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout-styled.js +0 -21
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout-styled.js.map +0 -1
- package/dist/features/auth/login/login-styled.js +0 -13
- package/dist/features/auth/login/login-styled.js.map +0 -1
- package/dist/features/auth/login/social-login-methods/social-login-methods-styled.js +0 -9
- package/dist/features/auth/login/social-login-methods/social-login-methods-styled.js.map +0 -1
- package/dist/features/hooks/use-device-type.js +0 -25
- package/dist/features/hooks/use-device-type.js.map +0 -1
- package/dist/features/utils/media.js +0 -16
- package/dist/features/utils/media.js.map +0 -1
- package/dist/static/cuemath-app-qr-code.7205ee79.svg +0 -1
@@ -1,118 +1,118 @@
|
|
1
|
-
import { useCallback as
|
1
|
+
import { useCallback as a, useRef as C, useEffect as T } from "react";
|
2
2
|
import { CircleSoundKeyMapper as A, SWIPE_SOUND_ORDER as E } from "./constants.js";
|
3
|
-
import { CircleSoundKey as
|
4
|
-
let
|
5
|
-
const
|
6
|
-
[
|
7
|
-
[
|
8
|
-
[
|
9
|
-
[
|
10
|
-
[
|
11
|
-
[
|
12
|
-
[
|
13
|
-
[
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[
|
17
|
-
[
|
18
|
-
[
|
19
|
-
[
|
20
|
-
[
|
21
|
-
[
|
22
|
-
[
|
23
|
-
[
|
24
|
-
[
|
25
|
-
[
|
26
|
-
[
|
27
|
-
[
|
28
|
-
[
|
29
|
-
},
|
30
|
-
const
|
31
|
-
if (!
|
32
|
-
const l = new Audio(A[
|
33
|
-
|
3
|
+
import { CircleSoundKey as e } from "./use-circle-sounds-enums.js";
|
4
|
+
let I = 0;
|
5
|
+
const r = {
|
6
|
+
[e.BACKGROUND]: null,
|
7
|
+
[e.BACKGROUND_RUSHHOUR]: null,
|
8
|
+
[e.TUTORIAL]: null,
|
9
|
+
[e.SWIPE_01]: null,
|
10
|
+
[e.SWIPE_02]: null,
|
11
|
+
[e.SWIPE_03]: null,
|
12
|
+
[e.SWIPE_04]: null,
|
13
|
+
[e.SWIPE_DOWN]: null,
|
14
|
+
[e.TOGGLE]: null,
|
15
|
+
[e.POINTS_AWARDED]: null,
|
16
|
+
[e.POINTS_ADDED]: null,
|
17
|
+
[e.GAME_CARD_CLICK]: null,
|
18
|
+
[e.CLOCK_IN]: null,
|
19
|
+
[e.CLOCK_OUT]: null,
|
20
|
+
[e.ACCURACY_IN]: null,
|
21
|
+
[e.ACCURACY_OUT]: null,
|
22
|
+
[e.STREAK_IN]: null,
|
23
|
+
[e.STREAK_OUT]: null,
|
24
|
+
[e.ACCURACY_INTRO]: null,
|
25
|
+
[e.ACCURACY_TARGET]: null,
|
26
|
+
[e.TIME_INTRO]: null,
|
27
|
+
[e.TIME_TARGET]: null,
|
28
|
+
[e.METER_FILL]: null
|
29
|
+
}, f = {}, D = () => {
|
30
|
+
const c = a((n) => {
|
31
|
+
if (!r[n]) {
|
32
|
+
const l = new Audio(A[n]);
|
33
|
+
r[n] = l;
|
34
34
|
}
|
35
|
-
}, []),
|
36
|
-
document.visibilityState === "hidden" ? Object.keys(
|
37
|
-
const l =
|
38
|
-
l && !l.paused && (l.pause(),
|
39
|
-
}) : document.visibilityState === "visible" && (
|
40
|
-
const l =
|
35
|
+
}, []), v = C(/* @__PURE__ */ new Set()), o = C({}), p = a(() => {
|
36
|
+
document.visibilityState === "hidden" ? Object.keys(r).forEach((n) => {
|
37
|
+
const l = r[n];
|
38
|
+
l && !l.paused && (l.pause(), v.current.add(n));
|
39
|
+
}) : document.visibilityState === "visible" && (v.current.forEach((n) => {
|
40
|
+
const l = r[n];
|
41
41
|
l == null || l.play();
|
42
|
-
}),
|
42
|
+
}), v.current.clear());
|
43
43
|
}, []);
|
44
44
|
T(() => {
|
45
|
-
document.addEventListener("visibilitychange",
|
46
|
-
const
|
45
|
+
document.addEventListener("visibilitychange", p);
|
46
|
+
const n = o.current;
|
47
47
|
return () => {
|
48
|
-
document.removeEventListener("visibilitychange",
|
49
|
-
for (const l of Object.values(
|
48
|
+
document.removeEventListener("visibilitychange", p);
|
49
|
+
for (const l of Object.values(n))
|
50
50
|
l != null && clearInterval(l);
|
51
51
|
};
|
52
|
-
}, [
|
53
|
-
const S =
|
52
|
+
}, [p]);
|
53
|
+
const S = a(() => {
|
54
54
|
var l;
|
55
55
|
E.forEach((u) => {
|
56
|
-
|
56
|
+
c(u);
|
57
57
|
});
|
58
|
-
const
|
59
|
-
|
60
|
-
}, [
|
58
|
+
const n = E[I] || e.SWIPE_01;
|
59
|
+
I < E.length - 1 ? I++ : I = 0, (l = r[n]) == null || l.play();
|
60
|
+
}, [c]), m = a(() => {
|
61
61
|
var l;
|
62
|
-
return
|
63
|
-
}, [
|
64
|
-
(
|
65
|
-
|
66
|
-
const t =
|
62
|
+
return c(e.TOGGLE), (l = r[e.TOGGLE]) == null ? void 0 : l.play();
|
63
|
+
}, [c]), _ = a(
|
64
|
+
(n, l = !0, u = !1) => {
|
65
|
+
c(n);
|
66
|
+
const t = r[n];
|
67
67
|
if (!t) return;
|
68
|
-
if (!t.paused && t.currentTime > 0 && !t.ended)
|
68
|
+
if (o.current[n] && clearInterval(o.current[n]), !t.paused && t.currentTime > 0 && !t.ended)
|
69
69
|
return t;
|
70
70
|
if (t.loop = u, l) {
|
71
71
|
t.volume = 1;
|
72
|
-
const
|
73
|
-
|
72
|
+
const d = t.play();
|
73
|
+
f[n] = d;
|
74
74
|
return;
|
75
75
|
}
|
76
76
|
t.volume = 0;
|
77
|
-
const
|
78
|
-
|
77
|
+
const s = t.play();
|
78
|
+
f[n] = s;
|
79
79
|
const i = setInterval(() => {
|
80
80
|
if (!t) {
|
81
81
|
clearInterval(i);
|
82
82
|
return;
|
83
83
|
}
|
84
|
-
const
|
85
|
-
|
84
|
+
const d = t.volume || 0;
|
85
|
+
d < 1 ? t.volume = Math.min(d + 0.1, 1) : clearInterval(i);
|
86
86
|
}, 100);
|
87
|
-
return
|
87
|
+
return o.current[n] = i, t;
|
88
88
|
},
|
89
|
-
[
|
90
|
-
), R =
|
89
|
+
[c]
|
90
|
+
), R = a((n, l = !0) => {
|
91
91
|
var t;
|
92
|
-
const u =
|
93
|
-
|
92
|
+
const u = r[n];
|
93
|
+
f[n] !== void 0 && ((t = f[n]) == null || t.then(() => {
|
94
94
|
if (!u) return;
|
95
|
-
if (l) {
|
95
|
+
if (o.current[n] && clearInterval(o.current[n]), l) {
|
96
96
|
u.pause();
|
97
97
|
return;
|
98
98
|
}
|
99
|
-
const
|
99
|
+
const s = setInterval(() => {
|
100
100
|
if (!u) {
|
101
|
-
clearInterval(
|
101
|
+
clearInterval(s);
|
102
102
|
return;
|
103
103
|
}
|
104
104
|
const i = u.volume || 0;
|
105
|
-
i - 0.1 <= 0 ? (u.volume = 0, u.pause(), clearInterval(
|
105
|
+
i - 0.1 <= 0 ? (u.volume = 0, u.pause(), clearInterval(s)) : u.volume = i - 0.1;
|
106
106
|
}, 100);
|
107
|
-
|
108
|
-
}).catch((
|
109
|
-
console.log("sound not playing",
|
107
|
+
o.current[n] = s;
|
108
|
+
}).catch((s) => {
|
109
|
+
console.log("sound not playing", s);
|
110
110
|
}));
|
111
111
|
}, []);
|
112
112
|
return { playSwipSound: S, play: _, stop: R, playButtonSound: m };
|
113
113
|
};
|
114
114
|
export {
|
115
|
-
|
115
|
+
r as soundMapper,
|
116
116
|
D as useCircleSounds
|
117
117
|
};
|
118
118
|
//# sourceMappingURL=use-circle-sounds.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-circle-sounds.js","sources":["../../../../../src/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.ts"],"sourcesContent":["import type { TimeoutMap } from './use-circle-sound-types';\n\nimport { useCallback, useEffect, useRef } from 'react';\n\nimport { CircleSoundKeyMapper, SWIPE_SOUND_ORDER } from './constants';\nimport { CircleSoundKey } from './use-circle-sounds-enums';\n\nlet swipeSoundIndex = 0;\n\nexport const soundMapper: Record<keyof typeof CircleSoundKeyMapper, null | HTMLAudioElement> = {\n [CircleSoundKey.BACKGROUND]: null,\n [CircleSoundKey.BACKGROUND_RUSHHOUR]: null,\n [CircleSoundKey.TUTORIAL]: null,\n [CircleSoundKey.SWIPE_01]: null,\n [CircleSoundKey.SWIPE_02]: null,\n [CircleSoundKey.SWIPE_03]: null,\n [CircleSoundKey.SWIPE_04]: null,\n [CircleSoundKey.SWIPE_DOWN]: null,\n [CircleSoundKey.TOGGLE]: null,\n [CircleSoundKey.POINTS_AWARDED]: null,\n [CircleSoundKey.POINTS_ADDED]: null,\n [CircleSoundKey.GAME_CARD_CLICK]: null,\n [CircleSoundKey.CLOCK_IN]: null,\n [CircleSoundKey.CLOCK_OUT]: null,\n [CircleSoundKey.ACCURACY_IN]: null,\n [CircleSoundKey.ACCURACY_OUT]: null,\n [CircleSoundKey.STREAK_IN]: null,\n [CircleSoundKey.STREAK_OUT]: null,\n [CircleSoundKey.ACCURACY_INTRO]: null,\n [CircleSoundKey.ACCURACY_TARGET]: null,\n [CircleSoundKey.TIME_INTRO]: null,\n [CircleSoundKey.TIME_TARGET]: null,\n [CircleSoundKey.METER_FILL]: null,\n};\n\nconst soundInstancePromise: Partial<Record<keyof typeof CircleSoundKeyMapper, Promise<void>>> = {};\n\nexport const useCircleSounds = () => {\n const loadSound = useCallback((key: CircleSoundKey) => {\n if (!soundMapper[key]) {\n const loadedSound = new Audio(CircleSoundKeyMapper[key]);\n\n soundMapper[key] = loadedSound;\n }\n }, []);\n\n const pausedSoundsRef = useRef<Set<CircleSoundKey>>(new Set());\n const timeoutRefs = useRef<TimeoutMap>({});\n\n const handleVisibilityChange = useCallback(() => {\n if (document.visibilityState === 'hidden') {\n (Object.keys(soundMapper) as CircleSoundKey[]).forEach(key => {\n const sound = soundMapper[key];\n\n if (sound && !sound.paused) {\n sound.pause();\n pausedSoundsRef.current.add(key);\n }\n });\n } else if (document.visibilityState === 'visible') {\n pausedSoundsRef.current.forEach(key => {\n const sound = soundMapper[key];\n\n sound?.play();\n });\n pausedSoundsRef.current.clear();\n }\n }, []);\n\n useEffect(() => {\n document.addEventListener('visibilitychange', handleVisibilityChange);\n const timeouts = timeoutRefs.current;\n\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange);\n for (const id of Object.values(timeouts)) {\n if (id != null) clearInterval(id);\n }\n };\n }, [handleVisibilityChange]);\n\n const playSwipSound = useCallback(() => {\n SWIPE_SOUND_ORDER.forEach(key => {\n loadSound(key);\n });\n\n const key = SWIPE_SOUND_ORDER[swipeSoundIndex] || CircleSoundKey.SWIPE_01;\n\n if (swipeSoundIndex < SWIPE_SOUND_ORDER.length - 1) {\n swipeSoundIndex++;\n } else {\n swipeSoundIndex = 0;\n }\n soundMapper[key]?.play();\n }, [loadSound]);\n\n const playButtonSound = useCallback(() => {\n loadSound(CircleSoundKey.TOGGLE);\n const sound = soundMapper[CircleSoundKey.TOGGLE]?.play();\n\n return sound;\n }, [loadSound]);\n\n const play = useCallback(\n (key: CircleSoundKey, immediately: boolean = true, loop = false) => {\n loadSound(key);\n const soundInstance = soundMapper[key];\n\n if (!soundInstance) return;\n\n if (!soundInstance.paused && soundInstance.currentTime > 0 && !soundInstance.ended) {\n return soundInstance;\n }\n\n soundInstance.loop = loop;\n if (immediately) {\n soundInstance.volume = 1;\n const promise = soundInstance.play();\n\n soundInstancePromise[key] = promise;\n\n return;\n }\n\n soundInstance.volume = 0;\n const promise = soundInstance.play();\n\n soundInstancePromise[key] = promise;\n\n const intervalId = setInterval(() => {\n if (!soundInstance) {\n clearInterval(intervalId);\n\n return;\n }\n\n const vol = soundInstance.volume || 0;\n\n if (vol < 1) {\n soundInstance.volume = Math.min(vol + 0.1, 1);\n } else {\n clearInterval(intervalId);\n }\n }, 100);\n\n timeoutRefs.current[key] = intervalId;\n\n return soundInstance;\n },\n [loadSound],\n );\n\n const stop = useCallback((key: CircleSoundKey, immediately: boolean = true) => {\n const soundInstance = soundMapper[key];\n\n if (soundInstancePromise[key] !== undefined) {\n soundInstancePromise[key]\n ?.then(() => {\n if (!soundInstance) return;\n\n if (immediately) {\n soundInstance.pause();\n\n return;\n }\n\n const intervalId = setInterval(() => {\n if (!soundInstance) {\n clearInterval(intervalId);\n\n return;\n }\n\n const vol = soundInstance.volume || 0;\n\n if (vol - 0.1 <= 0) {\n soundInstance.volume = 0;\n soundInstance.pause();\n clearInterval(intervalId);\n } else {\n soundInstance.volume = vol - 0.1;\n }\n }, 100);\n\n timeoutRefs.current[key] = intervalId;\n })\n .catch(err => {\n // eslint-disable-next-line no-console\n console.log('sound not playing', err);\n });\n }\n }, []);\n\n return { playSwipSound, play, stop, playButtonSound };\n};\n"],"names":["swipeSoundIndex","soundMapper","CircleSoundKey","soundInstancePromise","useCircleSounds","loadSound","useCallback","key","loadedSound","CircleSoundKeyMapper","pausedSoundsRef","useRef","timeoutRefs","handleVisibilityChange","sound","useEffect","timeouts","id","playSwipSound","SWIPE_SOUND_ORDER","_a","playButtonSound","play","immediately","loop","soundInstance","promise","intervalId","vol","stop","err"],"mappings":";;;AAOA,IAAIA,IAAkB;AAEf,MAAMC,IAAkF;AAAA,EAC7F,CAACC,EAAe,UAAU,GAAG;AAAA,EAC7B,CAACA,EAAe,mBAAmB,GAAG;AAAA,EACtC,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,UAAU,GAAG;AAAA,EAC7B,CAACA,EAAe,MAAM,GAAG;AAAA,EACzB,CAACA,EAAe,cAAc,GAAG;AAAA,EACjC,CAACA,EAAe,YAAY,GAAG;AAAA,EAC/B,CAACA,EAAe,eAAe,GAAG;AAAA,EAClC,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,SAAS,GAAG;AAAA,EAC5B,CAACA,EAAe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BAAWI,KAAM,OAAO,OAAOD,CAAQ;AACjC,QAAAC,KAAM,QAAM,cAAcA,CAAE;AAAA,IAClC;AAAA,EACF,GACC,CAACJ,CAAsB,CAAC;AAErB,QAAAK,IAAgBZ,EAAY,MAAM;;AACpB,IAAAa,EAAA,QAAQ,CAAAZ,MAAO;AAC/B,MAAAF,EAAUE,CAAG;AAAA,IAAA,CACd;AAED,UAAMA,IAAMY,EAAkBnB,CAAe,KAAKE,EAAe;AAE7D,IAAAF,IAAkBmB,EAAkB,SAAS,IAC/CnB,MAEkBA,IAAA,IAERoB,IAAAnB,EAAAM,CAAG,MAAH,QAAAa,EAAM;AAAA,EAAK,GACtB,CAACf,CAAS,CAAC,GAERgB,IAAkBf,EAAY,MAAM;;AACxC,WAAAD,EAAUH,EAAe,MAAM,IACjBkB,IAAAnB,EAAYC,EAAe,MAAM,MAAjC,gBAAAkB,EAAoC;AAAA,EAE3C,GACN,CAACf,CAAS,CAAC,GAERiB,IAAOhB;AAAA,IACX,CAACC,GAAqBgB,IAAuB,IAAMC,IAAO,OAAU;AAClE,MAAAnB,EAAUE,CAAG;AACP,YAAAkB,IAAgBxB,EAAYM,CAAG;AAErC,UAAI,CAACkB,EAAe;
|
1
|
+
{"version":3,"file":"use-circle-sounds.js","sources":["../../../../../src/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.ts"],"sourcesContent":["import type { TimeoutMap } from './use-circle-sound-types';\n\nimport { useCallback, useEffect, useRef } from 'react';\n\nimport { CircleSoundKeyMapper, SWIPE_SOUND_ORDER } from './constants';\nimport { CircleSoundKey } from './use-circle-sounds-enums';\n\nlet swipeSoundIndex = 0;\n\nexport const soundMapper: Record<keyof typeof CircleSoundKeyMapper, null | HTMLAudioElement> = {\n [CircleSoundKey.BACKGROUND]: null,\n [CircleSoundKey.BACKGROUND_RUSHHOUR]: null,\n [CircleSoundKey.TUTORIAL]: null,\n [CircleSoundKey.SWIPE_01]: null,\n [CircleSoundKey.SWIPE_02]: null,\n [CircleSoundKey.SWIPE_03]: null,\n [CircleSoundKey.SWIPE_04]: null,\n [CircleSoundKey.SWIPE_DOWN]: null,\n [CircleSoundKey.TOGGLE]: null,\n [CircleSoundKey.POINTS_AWARDED]: null,\n [CircleSoundKey.POINTS_ADDED]: null,\n [CircleSoundKey.GAME_CARD_CLICK]: null,\n [CircleSoundKey.CLOCK_IN]: null,\n [CircleSoundKey.CLOCK_OUT]: null,\n [CircleSoundKey.ACCURACY_IN]: null,\n [CircleSoundKey.ACCURACY_OUT]: null,\n [CircleSoundKey.STREAK_IN]: null,\n [CircleSoundKey.STREAK_OUT]: null,\n [CircleSoundKey.ACCURACY_INTRO]: null,\n [CircleSoundKey.ACCURACY_TARGET]: null,\n [CircleSoundKey.TIME_INTRO]: null,\n [CircleSoundKey.TIME_TARGET]: null,\n [CircleSoundKey.METER_FILL]: null,\n};\n\nconst soundInstancePromise: Partial<Record<keyof typeof CircleSoundKeyMapper, Promise<void>>> = {};\n\nexport const useCircleSounds = () => {\n const loadSound = useCallback((key: CircleSoundKey) => {\n if (!soundMapper[key]) {\n const loadedSound = new Audio(CircleSoundKeyMapper[key]);\n\n soundMapper[key] = loadedSound;\n }\n }, []);\n\n const pausedSoundsRef = useRef<Set<CircleSoundKey>>(new Set());\n const timeoutRefs = useRef<TimeoutMap>({});\n\n const handleVisibilityChange = useCallback(() => {\n if (document.visibilityState === 'hidden') {\n (Object.keys(soundMapper) as CircleSoundKey[]).forEach(key => {\n const sound = soundMapper[key];\n\n if (sound && !sound.paused) {\n sound.pause();\n pausedSoundsRef.current.add(key);\n }\n });\n } else if (document.visibilityState === 'visible') {\n pausedSoundsRef.current.forEach(key => {\n const sound = soundMapper[key];\n\n sound?.play();\n });\n pausedSoundsRef.current.clear();\n }\n }, []);\n\n useEffect(() => {\n document.addEventListener('visibilitychange', handleVisibilityChange);\n const timeouts = timeoutRefs.current;\n\n return () => {\n document.removeEventListener('visibilitychange', handleVisibilityChange);\n for (const id of Object.values(timeouts)) {\n if (id != null) clearInterval(id);\n }\n };\n }, [handleVisibilityChange]);\n\n const playSwipSound = useCallback(() => {\n SWIPE_SOUND_ORDER.forEach(key => {\n loadSound(key);\n });\n\n const key = SWIPE_SOUND_ORDER[swipeSoundIndex] || CircleSoundKey.SWIPE_01;\n\n if (swipeSoundIndex < SWIPE_SOUND_ORDER.length - 1) {\n swipeSoundIndex++;\n } else {\n swipeSoundIndex = 0;\n }\n soundMapper[key]?.play();\n }, [loadSound]);\n\n const playButtonSound = useCallback(() => {\n loadSound(CircleSoundKey.TOGGLE);\n const sound = soundMapper[CircleSoundKey.TOGGLE]?.play();\n\n return sound;\n }, [loadSound]);\n\n const play = useCallback(\n (key: CircleSoundKey, immediately: boolean = true, loop = false) => {\n loadSound(key);\n const soundInstance = soundMapper[key];\n\n if (!soundInstance) return;\n\n if (timeoutRefs.current[key]) {\n clearInterval(timeoutRefs.current[key]);\n }\n\n if (!soundInstance.paused && soundInstance.currentTime > 0 && !soundInstance.ended) {\n return soundInstance;\n }\n\n soundInstance.loop = loop;\n if (immediately) {\n soundInstance.volume = 1;\n const promise = soundInstance.play();\n\n soundInstancePromise[key] = promise;\n\n return;\n }\n\n soundInstance.volume = 0;\n const promise = soundInstance.play();\n\n soundInstancePromise[key] = promise;\n\n const intervalId = setInterval(() => {\n if (!soundInstance) {\n clearInterval(intervalId);\n\n return;\n }\n\n const vol = soundInstance.volume || 0;\n\n if (vol < 1) {\n soundInstance.volume = Math.min(vol + 0.1, 1);\n } else {\n clearInterval(intervalId);\n }\n }, 100);\n\n timeoutRefs.current[key] = intervalId;\n\n return soundInstance;\n },\n [loadSound],\n );\n\n const stop = useCallback((key: CircleSoundKey, immediately: boolean = true) => {\n const soundInstance = soundMapper[key];\n\n if (soundInstancePromise[key] !== undefined) {\n soundInstancePromise[key]\n ?.then(() => {\n if (!soundInstance) return;\n\n if (timeoutRefs.current[key]) {\n clearInterval(timeoutRefs.current[key]);\n }\n\n if (immediately) {\n soundInstance.pause();\n\n return;\n }\n\n const intervalId = setInterval(() => {\n if (!soundInstance) {\n clearInterval(intervalId);\n\n return;\n }\n\n const vol = soundInstance.volume || 0;\n\n if (vol - 0.1 <= 0) {\n soundInstance.volume = 0;\n soundInstance.pause();\n clearInterval(intervalId);\n } else {\n soundInstance.volume = vol - 0.1;\n }\n }, 100);\n\n timeoutRefs.current[key] = intervalId;\n })\n .catch(err => {\n // eslint-disable-next-line no-console\n console.log('sound not playing', err);\n });\n }\n }, []);\n\n return { playSwipSound, play, stop, playButtonSound };\n};\n"],"names":["swipeSoundIndex","soundMapper","CircleSoundKey","soundInstancePromise","useCircleSounds","loadSound","useCallback","key","loadedSound","CircleSoundKeyMapper","pausedSoundsRef","useRef","timeoutRefs","handleVisibilityChange","sound","useEffect","timeouts","id","playSwipSound","SWIPE_SOUND_ORDER","_a","playButtonSound","play","immediately","loop","soundInstance","promise","intervalId","vol","stop","err"],"mappings":";;;AAOA,IAAIA,IAAkB;AAEf,MAAMC,IAAkF;AAAA,EAC7F,CAACC,EAAe,UAAU,GAAG;AAAA,EAC7B,CAACA,EAAe,mBAAmB,GAAG;AAAA,EACtC,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,UAAU,GAAG;AAAA,EAC7B,CAACA,EAAe,MAAM,GAAG;AAAA,EACzB,CAACA,EAAe,cAAc,GAAG;AAAA,EACjC,CAACA,EAAe,YAAY,GAAG;AAAA,EAC/B,CAACA,EAAe,eAAe,GAAG;AAAA,EAClC,CAACA,EAAe,QAAQ,GAAG;AAAA,EAC3B,CAACA,EAAe,SAAS,GAAG;AAAA,EAC5B,CAACA,EAAe,WAAW,GAAG;AAAA,EAC9B,CAACA,EAAe,YAAY,GAAG;AAAA,EAC/B,CAACA,EAAe,SAAS,G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K,CAAC,IAE5C,cAAcD,CAAU;AAAA,SAEzB,GAAG;AAEM,aAAAf,EAAA,QAAQL,CAAG,IAAIoB,GAEpBF;AAAA,IACT;AAAA,IACA,CAACpB,CAAS;AAAA,EAAA,GAGNwB,IAAOvB,EAAY,CAACC,GAAqBgB,IAAuB,OAAS;;AACvE,UAAAE,IAAgBxB,EAAYM,CAAG;AAEjC,IAAAJ,EAAqBI,CAAG,MAAM,YACXa,IAAAjB,EAAAI,CAAG,MAAH,QAAAa,EACjB,KAAK,MAAM;AACX,UAAI,CAACK,EAAe;AAMpB,UAJIb,EAAY,QAAQL,CAAG,KACX,cAAAK,EAAY,QAAQL,CAAG,CAAC,GAGpCgB,GAAa;AACf,QAAAE,EAAc,MAAM;AAEpB;AAAA,MACF;AAEM,YAAAE,IAAa,YAAY,MAAM;AACnC,YAAI,CAACF,GAAe;AAClB,wBAAcE,CAAU;AAExB;AAAA,QACF;AAEM,cAAAC,IAAMH,EAAc,UAAU;AAEhC,QAAAG,IAAM,OAAO,KACfH,EAAc,SAAS,GACvBA,EAAc,MAAM,GACpB,cAAcE,CAAU,KAExBF,EAAc,SAASG,IAAM;AAAA,SAE9B,GAAG;AAEM,MAAAhB,EAAA,QAAQL,CAAG,IAAIoB;AAAA,IAAA,GAE5B,MAAM,CAAOG,MAAA;AAEJ,cAAA,IAAI,qBAAqBA,CAAG;AAAA,IAAA;AAAA,EAG5C,GAAG,CAAE,CAAA;AAEL,SAAO,EAAE,eAAAZ,GAAe,MAAAI,GAAM,MAAAO,GAAM,iBAAAR,EAAgB;AACtD;"}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { jsx as n, jsxs as g } from "react/jsx-runtime";
|
2
|
+
import { memo as b, useState as w, useCallback as i } from "react";
|
3
|
+
import k from "../../../assets/line-icons/icons/check.js";
|
4
|
+
import y from "../../../assets/line-icons/icons/share.js";
|
5
|
+
import f from "../../ui/buttons/button/button.js";
|
6
|
+
import p from "../../ui/layout/flex-view.js";
|
7
|
+
import I from "../../ui/separator/separator.js";
|
8
|
+
import B from "../../ui/text/text.js";
|
9
|
+
import { dataURIToBlob as x } from "../cue-canvas-helpers.js";
|
10
|
+
import { useCueCanvasActions as A } from "../hooks/use-cue-canvas-actions.js";
|
11
|
+
const S = (h) => {
|
12
|
+
const { width: c, onSendImageToChat: t, onMarkAsResolved: s } = h, { homeworkId: o, activeInstance: r, setHomeworkId: l } = A(), [m, u] = w(!1), a = i(() => {
|
13
|
+
r == null || r.clearCanvas(), l(void 0), u(!1);
|
14
|
+
}, [r, l]), d = i(async () => {
|
15
|
+
if (!r) return;
|
16
|
+
const e = await (r == null ? void 0 : r.getCanvasAsImage());
|
17
|
+
return e ? [x(e)] : void 0;
|
18
|
+
}, [r]), $ = i(async () => {
|
19
|
+
const e = await d();
|
20
|
+
!o || !t || !e || t == null || t(o, e, a);
|
21
|
+
}, [d, o, t, a]), C = i(() => {
|
22
|
+
o && (u(!0), s == null || s(o, a));
|
23
|
+
}, [o, s, a]);
|
24
|
+
return o ? m ? /* @__PURE__ */ n(
|
25
|
+
p,
|
26
|
+
{
|
27
|
+
$gapX: 1,
|
28
|
+
$gutterX: 0.5,
|
29
|
+
$alignItems: "center",
|
30
|
+
$justifyContent: "center",
|
31
|
+
$width: c,
|
32
|
+
$background: "YELLOW_1",
|
33
|
+
children: /* @__PURE__ */ n(B, { $renderAs: "body3", $color: "BLACK", children: "Resolving...." })
|
34
|
+
}
|
35
|
+
) : /* @__PURE__ */ g(
|
36
|
+
p,
|
37
|
+
{
|
38
|
+
$flexDirection: "row",
|
39
|
+
$gapX: 1,
|
40
|
+
$gutterX: 0.5,
|
41
|
+
$alignItems: "center",
|
42
|
+
$justifyContent: "center",
|
43
|
+
$width: c,
|
44
|
+
$background: "YELLOW_1",
|
45
|
+
children: [
|
46
|
+
/* @__PURE__ */ n(
|
47
|
+
f,
|
48
|
+
{
|
49
|
+
label: "Mark as reolved",
|
50
|
+
onClick: C,
|
51
|
+
renderAs: "primary",
|
52
|
+
Icon: k,
|
53
|
+
busy: m
|
54
|
+
}
|
55
|
+
),
|
56
|
+
/* @__PURE__ */ n(I, { width: 16 }),
|
57
|
+
/* @__PURE__ */ n(
|
58
|
+
f,
|
59
|
+
{
|
60
|
+
label: "Send CueBoard image to chat",
|
61
|
+
onClick: $,
|
62
|
+
renderAs: "primary",
|
63
|
+
Icon: y
|
64
|
+
}
|
65
|
+
)
|
66
|
+
]
|
67
|
+
}
|
68
|
+
) : null;
|
69
|
+
}, _ = b(S);
|
70
|
+
export {
|
71
|
+
_ as default
|
72
|
+
};
|
73
|
+
//# sourceMappingURL=homework-controls.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"homework-controls.js","sources":["../../../../src/features/cue-canvas/bottombar/homework-controls.tsx"],"sourcesContent":["import type { IHomeWorkControllerProps } from './bottombar-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useState } from 'react';\n\nimport CheckIcon from '../../../assets/line-icons/icons/check';\nimport ShareIcon from '../../../assets/line-icons/icons/share';\nimport Button from '../../ui/buttons/button/button';\nimport FlexView from '../../ui/layout/flex-view';\nimport Separator from '../../ui/separator/separator';\nimport Text from '../../ui/text/text';\nimport { dataURIToBlob } from '../cue-canvas-helpers';\nimport { useCueCanvasActions } from '../hooks/use-cue-canvas-actions';\n\nconst HomeworkController: FC<IHomeWorkControllerProps> = props => {\n const { width, onSendImageToChat, onMarkAsResolved } = props;\n const { homeworkId, activeInstance, setHomeworkId } = useCueCanvasActions();\n const [isBusy, setIsBusy] = useState(false);\n\n const onSuccess = useCallback(() => {\n activeInstance?.clearCanvas();\n setHomeworkId(undefined);\n setIsBusy(false);\n }, [activeInstance, setHomeworkId]);\n\n const getBoardSnapshot = useCallback(async () => {\n if (!activeInstance) return;\n\n const snapshot = await activeInstance?.getCanvasAsImage();\n\n if (!snapshot) {\n return;\n }\n\n const blobdata = dataURIToBlob(snapshot);\n\n return [blobdata];\n }, [activeInstance]);\n\n const handleSendImageToChat = useCallback(async () => {\n const snapshot = await getBoardSnapshot();\n\n if (!homeworkId || !onSendImageToChat || !snapshot) return;\n\n onSendImageToChat?.(homeworkId, snapshot, onSuccess);\n }, [getBoardSnapshot, homeworkId, onSendImageToChat, onSuccess]);\n\n const handleMarkAsResolved = useCallback(() => {\n if (!homeworkId) return;\n setIsBusy(true);\n onMarkAsResolved?.(homeworkId, onSuccess);\n }, [homeworkId, onMarkAsResolved, onSuccess]);\n\n if (!homeworkId) return null;\n\n if (isBusy) {\n return (\n <FlexView\n $gapX={1}\n $gutterX={0.5}\n $alignItems=\"center\"\n $justifyContent=\"center\"\n $width={width}\n $background=\"YELLOW_1\"\n >\n <Text $renderAs=\"body3\" $color=\"BLACK\">\n Resolving....\n </Text>\n </FlexView>\n );\n }\n\n return (\n <FlexView\n $flexDirection=\"row\"\n $gapX={1}\n $gutterX={0.5}\n $alignItems=\"center\"\n $justifyContent=\"center\"\n $width={width}\n $background=\"YELLOW_1\"\n >\n <Button\n label=\"Mark as reolved\"\n onClick={handleMarkAsResolved}\n renderAs={'primary'}\n Icon={CheckIcon}\n busy={isBusy}\n />\n <Separator width={16} />\n <Button\n label=\"Send CueBoard image to chat\"\n onClick={handleSendImageToChat}\n renderAs={'primary'}\n Icon={ShareIcon}\n />\n </FlexView>\n );\n};\n\nexport default memo(HomeworkController);\n"],"names":["HomeworkController","props","width","onSendImageToChat","onMarkAsResolved","homeworkId","activeInstance","setHomeworkId","useCueCanvasActions","isBusy","setIsBusy","useState","onSuccess","useCallback","getBoardSnapshot","snapshot","dataURIToBlob","handleSendImageToChat","handleMarkAsResolved","jsx","FlexView","Text","jsxs","Button","CheckIcon","Separator","ShareIcon","homeworkControls","memo"],"mappings":";;;;;;;;;;AAcA,MAAMA,IAAmD,CAASC,MAAA;AAChE,QAAM,EAAE,OAAAC,GAAO,mBAAAC,GAAmB,kBAAAC,EAAA,IAAqBH,GACjD,EAAE,YAAAI,GAAY,gBAAAC,GAAgB,eAAAC,MAAkBC,EAAoB,GACpE,CA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M;AAAA,YACN,SAASL;AAAA,YACT,UAAU;AAAA,YACV,MAAMM;AAAA,YACN,MAAMf;AAAA,UAAA;AAAA,QACR;AAAA,QACA,gBAAAU,EAACM,GAAU,EAAA,OAAO,GAAI,CAAA;AAAA,QACtB,gBAAAN;AAAA,UAACI;AAAA,UAAA;AAAA,YACC,OAAM;AAAA,YACN,SAASN;AAAA,YACT,UAAU;AAAA,YACV,MAAMS;AAAA,UAAA;AAAA,QACR;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IA1CoB;AA6C1B,GAEeC,IAAAC,EAAK5B,CAAkB;"}
|
@@ -1,17 +1,20 @@
|
|
1
|
-
import { createContext as
|
2
|
-
import { CANVAS_COLORS as
|
3
|
-
const
|
1
|
+
import { createContext as o } from "react";
|
2
|
+
import { CANVAS_COLORS as e } from "./constants/constants.js";
|
3
|
+
const v = o({
|
4
4
|
activeInstance: void 0,
|
5
5
|
setActiveInstance: () => {
|
6
6
|
},
|
7
7
|
activeTool: "pen",
|
8
8
|
setActiveTool: () => {
|
9
9
|
},
|
10
|
-
activeColor: Object.keys(
|
10
|
+
activeColor: Object.keys(e)[0],
|
11
11
|
setActiveColor: () => {
|
12
|
+
},
|
13
|
+
homeworkId: void 0,
|
14
|
+
setHomeworkId: () => {
|
12
15
|
}
|
13
16
|
});
|
14
17
|
export {
|
15
|
-
|
18
|
+
v as default
|
16
19
|
};
|
17
20
|
//# sourceMappingURL=cue-canvas-context.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cue-canvas-context.js","sources":["../../../src/features/cue-canvas/cue-canvas-context.tsx"],"sourcesContent":["import type { TPolyContextValue } from './types/context';\nimport type { TCueCanvasColors } from './types/cue-canvas';\n\nimport { createContext } from 'react';\n\nimport { CANVAS_COLORS } from './constants/constants';\n\nconst PolyContext = createContext<TPolyContextValue>({\n activeInstance: undefined,\n setActiveInstance: () => undefined,\n activeTool: 'pen',\n setActiveTool: () => undefined,\n activeColor: Object.keys(CANVAS_COLORS)[0] as TCueCanvasColors,\n setActiveColor: () => undefined,\n});\n\nexport default PolyContext;\n"],"names":["PolyContext","createContext","CANVAS_COLORS"],"mappings":";;AAOA,MAAMA,IAAcC,EAAiC;AAAA,EACnD,gBAAgB;AAAA,EAChB,mBAAmB,MAAM;AAAA;AAAA,EACzB,YAAY;AAAA,EACZ,eAAe,MAAM;AAAA;AAAA,EACrB,aAAa,OAAO,KAAKC,CAAa,EAAE,CAAC;AAAA,EACzC,gBAAgB,MAAM;AAAA;
|
1
|
+
{"version":3,"file":"cue-canvas-context.js","sources":["../../../src/features/cue-canvas/cue-canvas-context.tsx"],"sourcesContent":["import type { TPolyContextValue } from './types/context';\nimport type { TCueCanvasColors } from './types/cue-canvas';\n\nimport { createContext } from 'react';\n\nimport { CANVAS_COLORS } from './constants/constants';\n\nconst PolyContext = createContext<TPolyContextValue>({\n activeInstance: undefined,\n setActiveInstance: () => undefined,\n activeTool: 'pen',\n setActiveTool: () => undefined,\n activeColor: Object.keys(CANVAS_COLORS)[0] as TCueCanvasColors,\n setActiveColor: () => undefined,\n homeworkId: undefined,\n setHomeworkId: () => undefined,\n});\n\nexport default PolyContext;\n"],"names":["PolyContext","createContext","CANVAS_COLORS"],"mappings":";;AAOA,MAAMA,IAAcC,EAAiC;AAAA,EACnD,gBAAgB;AAAA,EAChB,mBAAmB,MAAM;AAAA;AAAA,EACzB,YAAY;AAAA,EACZ,eAAe,MAAM;AAAA;AAAA,EACrB,aAAa,OAAO,KAAKC,CAAa,EAAE,CAAC;AAAA,EACzC,gBAAgB,MAAM;AAAA;AAAA,EACtB,YAAY;AAAA,EACZ,eAAe,MAAM;AAAA;AACvB,CAAC;"}
|
@@ -1,20 +1,22 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var s = (
|
4
|
-
import v from "
|
5
|
-
import
|
6
|
-
|
1
|
+
var u = Object.defineProperty;
|
2
|
+
var g = (c, t, e) => t in c ? u(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
3
|
+
var s = (c, t, e) => g(c, typeof t != "symbol" ? t + "" : t, e);
|
4
|
+
import { captureMessage as v } from "@sentry/browser";
|
5
|
+
import f from "../../node_modules/lodash.debounce/index.js";
|
6
|
+
import { removeTileButton as y, removeMask as C, checkTextOrEquationTool as m, getReverseMap as T, getToolAndSubtool as w } from "./cue-canvas-helpers.js";
|
7
|
+
class E {
|
7
8
|
constructor({
|
8
9
|
onPublish: t,
|
9
10
|
onSubscribe: e,
|
10
11
|
onUpdateActiveTool: a,
|
11
|
-
onUpdateHeight:
|
12
|
+
onUpdateHeight: i,
|
12
13
|
uploadImageToS3: o,
|
13
|
-
height:
|
14
|
-
userId:
|
15
|
-
canvasId:
|
16
|
-
userType:
|
17
|
-
renderAs: p
|
14
|
+
height: n,
|
15
|
+
userId: h,
|
16
|
+
canvasId: r,
|
17
|
+
userType: l,
|
18
|
+
renderAs: p,
|
19
|
+
updateCanvasConfig: d
|
18
20
|
}) {
|
19
21
|
s(this, "polycanvas");
|
20
22
|
s(this, "publish");
|
@@ -28,22 +30,22 @@ class b {
|
|
28
30
|
s(this, "fileInput", null);
|
29
31
|
s(this, "debouncedViewportChange");
|
30
32
|
s(this, "uploadImageToS3");
|
31
|
-
s(this, "
|
33
|
+
s(this, "updateCanvasConfigChange");
|
34
|
+
s(this, "gridName");
|
35
|
+
s(this, "publishToChannel", (t) => {
|
32
36
|
this.publish && this.publish({
|
33
37
|
eventName: "cue_canvas_changed",
|
34
38
|
eventPayload: {
|
35
39
|
data: t,
|
36
40
|
height: this.height,
|
37
41
|
userId: this.userId,
|
38
|
-
responseId: this.canvasId
|
39
|
-
gridName: e,
|
40
|
-
dimension: a
|
42
|
+
responseId: this.canvasId
|
41
43
|
}
|
42
44
|
});
|
43
45
|
});
|
44
46
|
s(this, "onChange", (t) => {
|
45
47
|
const a = Object.fromEntries(t.entries());
|
46
|
-
|
48
|
+
m(a) && this.onUpdateActiveTool("move"), this.publishToChannel(a);
|
47
49
|
});
|
48
50
|
s(this, "undo", () => {
|
49
51
|
if (!this.polycanvas)
|
@@ -51,7 +53,7 @@ class b {
|
|
51
53
|
const t = this.polycanvas.undo();
|
52
54
|
if (!t)
|
53
55
|
return;
|
54
|
-
const e =
|
56
|
+
const e = T(t);
|
55
57
|
this.onChange(e);
|
56
58
|
});
|
57
59
|
s(this, "redo", () => {
|
@@ -73,6 +75,7 @@ class b {
|
|
73
75
|
const t = this.polycanvas.getViewport();
|
74
76
|
this.polycanvas.setViewport(t.x, t.y, t.zoom * 0.9);
|
75
77
|
});
|
78
|
+
s(this, "getCanvasAsImage", async () => this.polycanvas ? await this.polycanvas.image(3e3, 3e3, "png") : void 0);
|
76
79
|
s(this, "downloadCanvasAsImage", async () => {
|
77
80
|
if (!this.polycanvas) return;
|
78
81
|
const t = await this.polycanvas.image(3e3, 3e3, "png");
|
@@ -80,96 +83,103 @@ class b {
|
|
80
83
|
const e = document.createElement("a");
|
81
84
|
e.href = t, e.download = `canvas-drawing-${Date.now()}.png`, e.click();
|
82
85
|
});
|
83
|
-
s(this, "uploadFileToCanvas", async (t) => new Promise((e, a) => {
|
84
|
-
this.uploadImageToS3 ? e(this.uploadImageToS3(t)) : a(new Error("Upload function not provided"));
|
85
|
-
}));
|
86
86
|
s(this, "onViewPortChange", (t) => {
|
87
|
-
|
88
|
-
const e = t;
|
89
|
-
this.publishToChannel({}, void 0, e);
|
87
|
+
this.updateCanvasConfigChange && this.updateCanvasConfigChange({ dimesion: t });
|
90
88
|
});
|
91
89
|
s(this, "openFileUpload", () => {
|
92
|
-
this.fileInput || (this.fileInput = document.createElement("input"), this.fileInput.type = "file", this.fileInput.accept = "image/*", this.fileInput.style.display = "none", this.fileInput.onchange = this.
|
90
|
+
this.fileInput || (this.fileInput = document.createElement("input"), this.fileInput.type = "file", this.fileInput.accept = "image/*", this.fileInput.style.display = "none", this.fileInput.onchange = this.onSelectImage, document.body.appendChild(this.fileInput)), this.fileInput.click();
|
93
91
|
});
|
94
|
-
s(this, "addImageToCanvas",
|
95
|
-
|
96
|
-
const e =
|
97
|
-
if (!a || !this.polycanvas || !this.uploadImageToS3) return;
|
98
|
-
const n = await this.uploadImageToS3(a), o = this.polycanvas.getViewport(), i = {
|
92
|
+
s(this, "addImageToCanvas", (t) => {
|
93
|
+
if (!this.polycanvas) return;
|
94
|
+
const e = this.polycanvas.getViewport(), a = {
|
99
95
|
name: "image",
|
100
|
-
href:
|
101
|
-
x:
|
102
|
-
y:
|
103
|
-
|
104
|
-
|
96
|
+
href: t,
|
97
|
+
x: e.x + 24,
|
98
|
+
y: e.y + 24,
|
99
|
+
width: 500
|
100
|
+
}, i = this.polycanvas.add({
|
101
|
+
...a
|
105
102
|
});
|
106
103
|
this.publishToChannel({
|
107
|
-
[
|
108
|
-
})
|
104
|
+
[i]: [void 0, { ...a, status: "locked" }]
|
105
|
+
});
|
109
106
|
});
|
110
|
-
s(this, "
|
111
|
-
|
112
|
-
|
113
|
-
|
107
|
+
s(this, "onSelectImage", async (t) => {
|
108
|
+
var o;
|
109
|
+
const e = t.target, a = (o = e.files) == null ? void 0 : o[0];
|
110
|
+
if (!a || !this.polycanvas || !this.uploadImageToS3) return;
|
111
|
+
const i = await this.uploadImageToS3(a);
|
112
|
+
i !== "error" && (this.addImageToCanvas(i), e.value = "");
|
114
113
|
});
|
115
114
|
s(this, "updateCanvas", ({ data: t, userId: e }) => {
|
116
115
|
const a = this.userType === "TEACHER" || e === this.userId;
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
116
|
+
try {
|
117
|
+
Object.entries(t).forEach(([i, o]) => {
|
118
|
+
var n, h, r;
|
119
|
+
!o[0] && o[1] ? ("name" in o[1] && o[1].name === "image" && (o[1].status = this.userType === "STUDENT" ? "locked" : void 0), (n = this.polycanvas) == null || n.add({ ...o[1], cannotEdit: !a }, i)) : o[0] && !o[1] ? (h = this.polycanvas) == null || h.delete(i) : o[0] && o[1] && ((r = this.polycanvas) == null || r.update(i, { ...o[1] }));
|
120
|
+
});
|
121
|
+
} catch {
|
122
|
+
v("Error Updating Canvas", t);
|
123
|
+
}
|
121
124
|
});
|
122
125
|
s(this, "toggleTiles", (t) => {
|
123
126
|
var e;
|
124
127
|
(e = this.polycanvas) == null || e.toggleSidebar(t);
|
125
128
|
});
|
129
|
+
s(this, "setViewPort", ({ x: t, y: e, zoom: a }) => {
|
130
|
+
var i;
|
131
|
+
if (this.polycanvas) {
|
132
|
+
const o = (i = this.polycanvas) == null ? void 0 : i.getViewport();
|
133
|
+
if (o.x === t && o.y === e && o.zoom === a)
|
134
|
+
return;
|
135
|
+
this.polycanvas.setViewport(t, e, a);
|
136
|
+
}
|
137
|
+
});
|
126
138
|
s(this, "resetViewPort", () => {
|
127
139
|
this.polycanvas && this.polycanvas.resetViewport();
|
128
140
|
});
|
129
141
|
s(this, "changeGrid", (t) => {
|
130
|
-
this.polycanvas
|
142
|
+
!this.polycanvas || this.gridName === t || (this.polycanvas.setOptions({
|
131
143
|
grid: t
|
132
|
-
}), this.
|
144
|
+
}), this.gridName = t, this.updateCanvasConfigChange && this.updateCanvasConfigChange({ gridName: t }));
|
133
145
|
});
|
134
146
|
s(this, "lockSelectedTiles", () => {
|
135
|
-
var a,
|
136
|
-
const { tiles: t } = ((a = this.polycanvas) == null ? void 0 : a.serialize()) || {}, e = ((
|
147
|
+
var a, i;
|
148
|
+
const { tiles: t } = ((a = this.polycanvas) == null ? void 0 : a.serialize()) || {}, e = ((i = this.polycanvas) == null ? void 0 : i.getSelection()) || [];
|
137
149
|
if (e.length > 0 && t) {
|
138
150
|
const o = {};
|
139
|
-
e.forEach((
|
140
|
-
var
|
141
|
-
if (!((
|
142
|
-
const
|
143
|
-
(
|
151
|
+
e.forEach((n) => {
|
152
|
+
var r, l, p;
|
153
|
+
if (!((r = t[n]) != null && r.name)) return;
|
154
|
+
const h = { ...t[n], status: "locked" };
|
155
|
+
(l = this.polycanvas) == null || l.update(n, h), (p = t[n]) != null && p.name && (o[n] = [t[n], h]);
|
144
156
|
}), this.publishToChannel(o);
|
145
157
|
}
|
146
158
|
});
|
147
159
|
s(this, "unlockAllTiles", () => {
|
148
160
|
if (!this.polycanvas) return;
|
149
161
|
const { tiles: t } = this.polycanvas.serialize(), e = {};
|
150
|
-
t && Object.entries(t).length > 0 && (Object.entries(t).forEach(([a,
|
151
|
-
var
|
152
|
-
if (
|
153
|
-
const o = { ...
|
154
|
-
(
|
162
|
+
t && Object.entries(t).length > 0 && (Object.entries(t).forEach(([a, i]) => {
|
163
|
+
var n;
|
164
|
+
if (i.status !== "locked") return;
|
165
|
+
const o = { ...i, status: void 0 };
|
166
|
+
(n = this.polycanvas) == null || n.update(a, o), e[a] = [i, o];
|
155
167
|
}), this.publishToChannel(e));
|
156
168
|
});
|
157
169
|
s(this, "replaceCanvas", (t) => {
|
158
170
|
if (!this.polycanvas) return;
|
159
171
|
const { data: e, gridName: a } = t;
|
160
|
-
this.polycanvas.clear(), a && this.
|
161
|
-
|
162
|
-
}), Object.entries(e).forEach(([n, o]) => {
|
163
|
-
var i;
|
172
|
+
this.polycanvas.clear(), a && this.changeGrid(a), Object.entries(e).forEach(([i, o]) => {
|
173
|
+
var n;
|
164
174
|
if (!o[0] && o[1]) {
|
165
|
-
(
|
175
|
+
(n = this.polycanvas) == null || n.add({ ...o[1] }, i);
|
166
176
|
return;
|
167
177
|
}
|
168
|
-
}), this.publishToChannel(e
|
178
|
+
}), this.publishToChannel(e);
|
169
179
|
});
|
170
180
|
s(this, "setTool", (t) => {
|
171
181
|
if (this.polycanvas) {
|
172
|
-
const [e, a] =
|
182
|
+
const [e, a] = w(t);
|
173
183
|
switch (e) {
|
174
184
|
case "clearAll":
|
175
185
|
this.clearCanvas();
|
@@ -222,10 +232,10 @@ class b {
|
|
222
232
|
*/
|
223
233
|
s(this, "update", (t) => {
|
224
234
|
if (Array.isArray(t)) {
|
225
|
-
const e = t.map((i) => i.height).filter(Boolean), a = Math.max(...e)
|
226
|
-
this.
|
235
|
+
const e = t.map((i) => i.height).filter(Boolean), a = Math.max(...e);
|
236
|
+
a > this.height && this.updateHeight(a), t.forEach((i) => this.updateCanvas(i));
|
227
237
|
} else
|
228
|
-
|
238
|
+
t.height > this.height && this.updateHeight(t.height), this.updateCanvas(t);
|
229
239
|
});
|
230
240
|
s(this, "setColor", (t) => {
|
231
241
|
this.polycanvas && this.polycanvas.setColor(t);
|
@@ -237,9 +247,9 @@ class b {
|
|
237
247
|
s(this, "destroy", () => {
|
238
248
|
this.polycanvas && (this.polycanvas.off("change", this.onChange), this.polycanvas.destroy(), this.debouncedViewportChange.cancel(), this.renderAs === "whiteboard" && this.userType === "TEACHER" && this.polycanvas.off("viewport", this.debouncedViewportChange), this.polycanvas = void 0, this.fileInput && this.fileInput.parentNode && (this.fileInput.parentNode.removeChild(this.fileInput), this.fileInput = null));
|
239
249
|
});
|
240
|
-
this.onUpdateHeight =
|
250
|
+
this.onUpdateHeight = i, this.onUpdateActiveTool = a, this.height = n, this.uploadImageToS3 = o, this.userId = h, this.canvasId = r, this.publish = t, this.userType = l, this.renderAs = p, this.debouncedViewportChange = f(this.onViewPortChange, 300), this.updateCanvasConfigChange = d, e == null || e(this.canvasId, this.update);
|
241
251
|
}
|
242
|
-
async create({ canvasElementRef: t, canvasConfig: e, canvasSetting: a, initialData:
|
252
|
+
async create({ canvasElementRef: t, canvasConfig: e, canvasSetting: a, initialData: i }) {
|
243
253
|
if (!t.current)
|
244
254
|
throw new Error("PolyCanvas: Div Element Not found for canvas");
|
245
255
|
this.polycanvas = await window.Polypad.create(t.current, {
|
@@ -247,11 +257,11 @@ class b {
|
|
247
257
|
options: e
|
248
258
|
},
|
249
259
|
...a,
|
250
|
-
imageUpload: this.renderAs === "whiteboard" && this.userType === "TEACHER" ? this.
|
251
|
-
}), this.renderAs === "whiteboard" && this.userType === "TEACHER" && (this.polycanvas.toggleSidebar(!1),
|
260
|
+
imageUpload: this.renderAs === "whiteboard" && this.userType === "TEACHER" && this.uploadImageToS3 ? this.uploadImageToS3 : void 0
|
261
|
+
}), this.renderAs === "whiteboard" && this.userType === "TEACHER" && (this.polycanvas.toggleSidebar(!1), this.polycanvas.bindKeyboardEvents({}), y(t), this.polycanvas.on("viewport", this.debouncedViewportChange)), C(t), this.polycanvas.on("change", this.onChange), i && this.update(i);
|
252
262
|
}
|
253
263
|
}
|
254
264
|
export {
|
255
|
-
|
265
|
+
E as CueCanvasCore
|
256
266
|
};
|
257
267
|
//# sourceMappingURL=cue-canvas-core.js.map
|