@cuemath/leap 3.1.5-beta-0.1 → 3.1.6-j1
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 +1 -2
- 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/features/analytics-events/platform-events-student.js +2 -4
- package/dist/features/analytics-events/platform-events-student.js.map +1 -1
- package/dist/features/auth/account-selector/account-selector-styled.js +9 -0
- package/dist/features/auth/account-selector/account-selector-styled.js.map +1 -0
- package/dist/features/auth/account-selector/account-selector.js +57 -33
- package/dist/features/auth/account-selector/account-selector.js.map +1 -1
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout-styled.js +21 -0
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout-styled.js.map +1 -0
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout.js +8 -9
- 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 +15 -3
- 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 +14 -18
- 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 +23 -24
- 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 +4 -2
- 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 +85 -75
- package/dist/features/auth/login/identifier-otp-form/identifier-otp-form.js.map +1 -1
- package/dist/features/auth/login/login-styled.js +13 -0
- package/dist/features/auth/login/login-styled.js.map +1 -0
- package/dist/features/auth/login/social-account-not-found/social-account-not-found.js +27 -21
- 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-styled.js +9 -0
- package/dist/features/auth/login/social-login-methods/social-login-methods-styled.js.map +1 -0
- package/dist/features/auth/login/social-login-methods/social-login-methods.js +43 -34
- 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 +22 -21
- 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 +33 -32
- package/dist/features/auth/user-list/user-item/user-item.js.map +1 -1
- package/dist/features/auth/user-list/user-list.js +60 -51
- 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/cue-canvas-context.js +5 -8
- package/dist/features/cue-canvas/cue-canvas-context.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-core.js +74 -84
- package/dist/features/cue-canvas/cue-canvas-core.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-helpers.js +25 -31
- package/dist/features/cue-canvas/cue-canvas-helpers.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-provider.js +12 -14
- package/dist/features/cue-canvas/cue-canvas-provider.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas.js +59 -66
- package/dist/features/cue-canvas/cue-canvas.js.map +1 -1
- package/dist/features/cue-canvas/cue-cavas-styled.js +42 -45
- package/dist/features/cue-canvas/cue-cavas-styled.js.map +1 -1
- package/dist/features/cue-canvas/hooks/use-canvas-sync-broker.js +54 -61
- package/dist/features/cue-canvas/hooks/use-canvas-sync-broker.js.map +1 -1
- package/dist/features/cue-canvas/hooks/use-cue-canvas-actions.js +14 -18
- package/dist/features/cue-canvas/hooks/use-cue-canvas-actions.js.map +1 -1
- 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 +20 -22
- package/dist/features/cue-canvas/toolbar/tool.js.map +1 -1
- package/dist/features/homework/hw-card-list/api/get-homeworks.js +1 -1
- package/dist/features/homework/hw-card-list/api/get-homeworks.js.map +1 -1
- package/dist/features/homework/hw-card-list/hw-card-list-view.js +112 -144
- package/dist/features/homework/hw-card-list/hw-card-list-view.js.map +1 -1
- package/dist/features/homework/styles.js +4 -5
- package/dist/features/homework/styles.js.map +1 -1
- package/dist/features/hooks/use-viewport.js +21 -0
- package/dist/features/hooks/use-viewport.js.map +1 -0
- package/dist/features/journey/hooks/use-home-page-journey/home-page-homeworks-mock.js +262 -199
- package/dist/features/journey/hooks/use-home-page-journey/home-page-homeworks-mock.js.map +1 -1
- package/dist/features/journey/hooks/use-home-page-journey/use-home-page-journey.js +15 -15
- package/dist/features/journey/hooks/use-home-page-journey/use-home-page-journey.js.map +1 -1
- package/dist/features/milestone/create/comps/add-custom-chapter/course-catalog.js +36 -38
- 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 +22 -24
- 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 +22 -23
- 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 +47 -49
- 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 +87 -94
- 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 +12 -13
- 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 +21 -23
- 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 +162 -165
- package/dist/features/milestone/create/milestone-create-helpers.js.map +1 -1
- package/dist/features/milestone/edit/comps/edit-milestone-modal/index.js +47 -48
- package/dist/features/milestone/edit/comps/edit-milestone-modal/index.js.map +1 -1
- package/dist/features/milestone/milestone-list-container/milestone-list/milestone-list.js +121 -100
- package/dist/features/milestone/milestone-list-container/milestone-list/milestone-list.js.map +1 -1
- package/dist/features/milestone/milestone-list-container/milestone-list/milestone-widget/milestone-widget-styled.js +14 -15
- package/dist/features/milestone/milestone-list-container/milestone-list/milestone-widget/milestone-widget-styled.js.map +1 -1
- package/dist/features/milestone/milestone-list-container/milestone-list-container.js +51 -52
- package/dist/features/milestone/milestone-list-container/milestone-list-container.js.map +1 -1
- package/dist/features/trial-session/comps/pricing/pricing.js +35 -36
- 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/utils/media.js +16 -0
- package/dist/features/utils/media.js.map +1 -0
- package/dist/features/worksheet/worksheet/hooks/use-s3-helper.js +19 -22
- package/dist/features/worksheet/worksheet/hooks/use-s3-helper.js.map +1 -1
- package/dist/index.d.ts +35 -92
- package/dist/index.js +321 -323
- package/dist/index.js.map +1 -1
- package/dist/static/cuemath-app-qr-code.7205ee79.svg +1 -0
- package/package.json +1 -1
- package/dist/assets/line-icons/icons/puzzle-icon.js +0 -51
- package/dist/assets/line-icons/icons/puzzle-icon.js.map +0 -1
- package/dist/assets/line-icons/icons/share.js +0 -48
- package/dist/assets/line-icons/icons/share.js.map +0 -1
- package/dist/assets/line-icons/icons/tile.js +0 -54
- package/dist/assets/line-icons/icons/tile.js.map +0 -1
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout-styles.js +0 -12
- package/dist/features/auth/comps/auth-page-layout/auth-page-layout-styles.js.map +0 -1
- package/dist/features/cue-canvas/bottombar/homework-controls.js +0 -73
- package/dist/features/cue-canvas/bottombar/homework-controls.js.map +0 -1
- package/dist/features/cue-canvas/hooks/use-config-updater.js +0 -12
- package/dist/features/cue-canvas/hooks/use-config-updater.js.map +0 -1
- package/dist/features/cue-canvas/hooks/use-upload-helper.js +0 -23
- package/dist/features/cue-canvas/hooks/use-upload-helper.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/homework/helper.js +0 -20
- package/dist/features/cue-canvas/sidebar/homework/helper.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/homework/homework-menu.js +0 -33
- package/dist/features/cue-canvas/sidebar/homework/homework-menu.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/homework/homework-request.js +0 -68
- package/dist/features/cue-canvas/sidebar/homework/homework-request.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/homework/homework-styled.js +0 -25
- package/dist/features/cue-canvas/sidebar/homework/homework-styled.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/homework/homework.js +0 -39
- package/dist/features/cue-canvas/sidebar/homework/homework.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/api/get-puzzles.js +0 -13
- package/dist/features/cue-canvas/sidebar/puzzles/api/get-puzzles.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/filter-selection-menu.js +0 -60
- package/dist/features/cue-canvas/sidebar/puzzles/filter-selection-menu.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/filters-section.js +0 -44
- package/dist/features/cue-canvas/sidebar/puzzles/filters-section.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/filters.js +0 -107
- package/dist/features/cue-canvas/sidebar/puzzles/filters.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/hooks/use-fetch-cue-canvas-activity.js +0 -42
- package/dist/features/cue-canvas/sidebar/puzzles/hooks/use-fetch-cue-canvas-activity.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/launch-puzzle.js +0 -84
- package/dist/features/cue-canvas/sidebar/puzzles/launch-puzzle.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/puzzle-menu-header.js +0 -36
- package/dist/features/cue-canvas/sidebar/puzzles/puzzle-menu-header.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/puzzle-menu.js +0 -133
- package/dist/features/cue-canvas/sidebar/puzzles/puzzle-menu.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/puzzles-styled.js +0 -96
- package/dist/features/cue-canvas/sidebar/puzzles/puzzles-styled.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/puzzles.js +0 -29
- package/dist/features/cue-canvas/sidebar/puzzles/puzzles.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/puzzles/utils.js +0 -120
- package/dist/features/cue-canvas/sidebar/puzzles/utils.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/sidebar-styled.js +0 -32
- package/dist/features/cue-canvas/sidebar/sidebar-styled.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/sidebar.js +0 -29
- package/dist/features/cue-canvas/sidebar/sidebar.js.map +0 -1
- package/dist/features/cue-canvas/sidebar/tiles/tile.js +0 -16
- package/dist/features/cue-canvas/sidebar/tiles/tile.js.map +0 -1
- package/dist/features/homework/hw-card-list/hw-card-list-utils.js +0 -8
- package/dist/features/homework/hw-card-list/hw-card-list-utils.js.map +0 -1
- package/dist/features/hooks/use-debounce.js +0 -16
- package/dist/features/hooks/use-debounce.js.map +0 -1
- package/dist/features/milestone/milestone-list-container/api/get-past-milestone-count.js +0 -18
- package/dist/features/milestone/milestone-list-container/api/get-past-milestone-count.js.map +0 -1
- package/dist/features/trial-session/comps/pricing/india-pricing/index.js +0 -96
- package/dist/features/trial-session/comps/pricing/india-pricing/index.js.map +0 -1
- package/dist/features/trial-session/comps/pricing/india-pricing/india-pricing-styled.js +0 -59
- package/dist/features/trial-session/comps/pricing/india-pricing/india-pricing-styled.js.map +0 -1
- package/dist/static/ellipse-clip.dfb25608.svg +0 -1
@@ -1,118 +1,118 @@
|
|
1
|
-
import { useCallback as
|
1
|
+
import { useCallback as c, 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 n } from "./use-circle-sounds-enums.js";
|
4
|
+
let d = 0;
|
5
|
+
const o = {
|
6
|
+
[n.BACKGROUND]: null,
|
7
|
+
[n.BACKGROUND_RUSHHOUR]: null,
|
8
|
+
[n.TUTORIAL]: null,
|
9
|
+
[n.SWIPE_01]: null,
|
10
|
+
[n.SWIPE_02]: null,
|
11
|
+
[n.SWIPE_03]: null,
|
12
|
+
[n.SWIPE_04]: null,
|
13
|
+
[n.SWIPE_DOWN]: null,
|
14
|
+
[n.TOGGLE]: null,
|
15
|
+
[n.POINTS_AWARDED]: null,
|
16
|
+
[n.POINTS_ADDED]: null,
|
17
|
+
[n.GAME_CARD_CLICK]: null,
|
18
|
+
[n.CLOCK_IN]: null,
|
19
|
+
[n.CLOCK_OUT]: null,
|
20
|
+
[n.ACCURACY_IN]: null,
|
21
|
+
[n.ACCURACY_OUT]: null,
|
22
|
+
[n.STREAK_IN]: null,
|
23
|
+
[n.STREAK_OUT]: null,
|
24
|
+
[n.ACCURACY_INTRO]: null,
|
25
|
+
[n.ACCURACY_TARGET]: null,
|
26
|
+
[n.TIME_INTRO]: null,
|
27
|
+
[n.TIME_TARGET]: null,
|
28
|
+
[n.METER_FILL]: null
|
29
|
+
}, I = {}, D = () => {
|
30
|
+
const s = c((e) => {
|
31
|
+
if (!o[e]) {
|
32
|
+
const l = new Audio(A[e]);
|
33
|
+
o[e] = 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
|
+
}, []), f = C(/* @__PURE__ */ new Set()), p = C({}), v = c(() => {
|
36
|
+
document.visibilityState === "hidden" ? Object.keys(o).forEach((e) => {
|
37
|
+
const l = o[e];
|
38
|
+
l && !l.paused && (l.pause(), f.current.add(e));
|
39
|
+
}) : document.visibilityState === "visible" && (f.current.forEach((e) => {
|
40
|
+
const l = o[e];
|
41
41
|
l == null || l.play();
|
42
|
-
}),
|
42
|
+
}), f.current.clear());
|
43
43
|
}, []);
|
44
44
|
T(() => {
|
45
|
-
document.addEventListener("visibilitychange",
|
46
|
-
const
|
45
|
+
document.addEventListener("visibilitychange", v);
|
46
|
+
const e = p.current;
|
47
47
|
return () => {
|
48
|
-
document.removeEventListener("visibilitychange",
|
49
|
-
for (const l of Object.values(
|
48
|
+
document.removeEventListener("visibilitychange", v);
|
49
|
+
for (const l of Object.values(e))
|
50
50
|
l != null && clearInterval(l);
|
51
51
|
};
|
52
|
-
}, [
|
53
|
-
const S =
|
52
|
+
}, [v]);
|
53
|
+
const S = c(() => {
|
54
54
|
var l;
|
55
55
|
E.forEach((u) => {
|
56
|
-
|
56
|
+
s(u);
|
57
57
|
});
|
58
|
-
const
|
59
|
-
|
60
|
-
}, [
|
58
|
+
const e = E[d] || n.SWIPE_01;
|
59
|
+
d < E.length - 1 ? d++ : d = 0, (l = o[e]) == null || l.play();
|
60
|
+
}, [s]), m = c(() => {
|
61
61
|
var l;
|
62
|
-
return
|
63
|
-
}, [
|
64
|
-
(
|
65
|
-
|
66
|
-
const t =
|
62
|
+
return s(n.TOGGLE), (l = o[n.TOGGLE]) == null ? void 0 : l.play();
|
63
|
+
}, [s]), _ = c(
|
64
|
+
(e, l = !0, u = !1) => {
|
65
|
+
s(e);
|
66
|
+
const t = o[e];
|
67
67
|
if (!t) return;
|
68
|
-
if (
|
68
|
+
if (!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 a = t.play();
|
73
|
+
I[e] = a;
|
74
74
|
return;
|
75
75
|
}
|
76
76
|
t.volume = 0;
|
77
|
-
const
|
78
|
-
|
77
|
+
const r = t.play();
|
78
|
+
I[e] = r;
|
79
79
|
const i = setInterval(() => {
|
80
80
|
if (!t) {
|
81
81
|
clearInterval(i);
|
82
82
|
return;
|
83
83
|
}
|
84
|
-
const
|
85
|
-
|
84
|
+
const a = t.volume || 0;
|
85
|
+
a < 1 ? t.volume = Math.min(a + 0.1, 1) : clearInterval(i);
|
86
86
|
}, 100);
|
87
|
-
return
|
87
|
+
return p.current[e] = i, t;
|
88
88
|
},
|
89
|
-
[
|
90
|
-
), R =
|
89
|
+
[s]
|
90
|
+
), R = c((e, l = !0) => {
|
91
91
|
var t;
|
92
|
-
const u =
|
93
|
-
|
92
|
+
const u = o[e];
|
93
|
+
I[e] !== void 0 && ((t = I[e]) == null || t.then(() => {
|
94
94
|
if (!u) return;
|
95
|
-
if (
|
95
|
+
if (l) {
|
96
96
|
u.pause();
|
97
97
|
return;
|
98
98
|
}
|
99
|
-
const
|
99
|
+
const r = setInterval(() => {
|
100
100
|
if (!u) {
|
101
|
-
clearInterval(
|
101
|
+
clearInterval(r);
|
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(r)) : u.volume = i - 0.1;
|
106
106
|
}, 100);
|
107
|
-
|
108
|
-
}).catch((
|
109
|
-
console.log("sound not playing",
|
107
|
+
p.current[e] = r;
|
108
|
+
}).catch((r) => {
|
109
|
+
console.log("sound not playing", r);
|
110
110
|
}));
|
111
111
|
}, []);
|
112
112
|
return { playSwipSound: S, play: _, stop: R, playButtonSound: m };
|
113
113
|
};
|
114
114
|
export {
|
115
|
-
|
115
|
+
o 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 (
|
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":"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"}
|
@@ -1,20 +1,17 @@
|
|
1
|
-
import { createContext as
|
2
|
-
import { CANVAS_COLORS as
|
3
|
-
const
|
1
|
+
import { createContext as t } from "react";
|
2
|
+
import { CANVAS_COLORS as o } from "./constants/constants.js";
|
3
|
+
const c = t({
|
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(o)[0],
|
11
11
|
setActiveColor: () => {
|
12
|
-
},
|
13
|
-
homeworkId: void 0,
|
14
|
-
setHomeworkId: () => {
|
15
12
|
}
|
16
13
|
});
|
17
14
|
export {
|
18
|
-
|
15
|
+
c as default
|
19
16
|
};
|
20
17
|
//# 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
|
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;AACxB,CAAC;"}
|
@@ -1,22 +1,20 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var s = (
|
4
|
-
import
|
5
|
-
import f from "
|
6
|
-
|
7
|
-
class E {
|
1
|
+
var d = Object.defineProperty;
|
2
|
+
var u = (r, t, e) => t in r ? d(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
3
|
+
var s = (r, t, e) => u(r, typeof t != "symbol" ? t + "" : t, e);
|
4
|
+
import v from "../../node_modules/lodash.debounce/index.js";
|
5
|
+
import { removeTileButton as f, removeMask as g, checkTextOrEquationTool as y, getReverseMap as C, getToolAndSubtool as m } from "./cue-canvas-helpers.js";
|
6
|
+
class b {
|
8
7
|
constructor({
|
9
8
|
onPublish: t,
|
10
9
|
onSubscribe: e,
|
11
10
|
onUpdateActiveTool: a,
|
12
|
-
onUpdateHeight:
|
11
|
+
onUpdateHeight: n,
|
13
12
|
uploadImageToS3: o,
|
14
|
-
height:
|
15
|
-
userId:
|
16
|
-
canvasId:
|
17
|
-
userType:
|
18
|
-
renderAs: p
|
19
|
-
updateCanvasConfig: d
|
13
|
+
height: i,
|
14
|
+
userId: l,
|
15
|
+
canvasId: h,
|
16
|
+
userType: c,
|
17
|
+
renderAs: p
|
20
18
|
}) {
|
21
19
|
s(this, "polycanvas");
|
22
20
|
s(this, "publish");
|
@@ -30,22 +28,22 @@ class E {
|
|
30
28
|
s(this, "fileInput", null);
|
31
29
|
s(this, "debouncedViewportChange");
|
32
30
|
s(this, "uploadImageToS3");
|
33
|
-
s(this, "
|
34
|
-
s(this, "gridName");
|
35
|
-
s(this, "publishToChannel", (t) => {
|
31
|
+
s(this, "publishToChannel", (t, e, a) => {
|
36
32
|
this.publish && this.publish({
|
37
33
|
eventName: "cue_canvas_changed",
|
38
34
|
eventPayload: {
|
39
35
|
data: t,
|
40
36
|
height: this.height,
|
41
37
|
userId: this.userId,
|
42
|
-
responseId: this.canvasId
|
38
|
+
responseId: this.canvasId,
|
39
|
+
gridName: e,
|
40
|
+
dimension: a
|
43
41
|
}
|
44
42
|
});
|
45
43
|
});
|
46
44
|
s(this, "onChange", (t) => {
|
47
45
|
const a = Object.fromEntries(t.entries());
|
48
|
-
|
46
|
+
y(a) && this.onUpdateActiveTool("move"), this.publishToChannel(a);
|
49
47
|
});
|
50
48
|
s(this, "undo", () => {
|
51
49
|
if (!this.polycanvas)
|
@@ -53,7 +51,7 @@ class E {
|
|
53
51
|
const t = this.polycanvas.undo();
|
54
52
|
if (!t)
|
55
53
|
return;
|
56
|
-
const e =
|
54
|
+
const e = C(t);
|
57
55
|
this.onChange(e);
|
58
56
|
});
|
59
57
|
s(this, "redo", () => {
|
@@ -75,7 +73,6 @@ class E {
|
|
75
73
|
const t = this.polycanvas.getViewport();
|
76
74
|
this.polycanvas.setViewport(t.x, t.y, t.zoom * 0.9);
|
77
75
|
});
|
78
|
-
s(this, "getCanvasAsImage", async () => this.polycanvas ? await this.polycanvas.image(3e3, 3e3, "png") : void 0);
|
79
76
|
s(this, "downloadCanvasAsImage", async () => {
|
80
77
|
if (!this.polycanvas) return;
|
81
78
|
const t = await this.polycanvas.image(3e3, 3e3, "png");
|
@@ -83,103 +80,96 @@ class E {
|
|
83
80
|
const e = document.createElement("a");
|
84
81
|
e.href = t, e.download = `canvas-drawing-${Date.now()}.png`, e.click();
|
85
82
|
});
|
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
|
-
|
87
|
+
if (!this.publish) return;
|
88
|
+
const e = t;
|
89
|
+
this.publishToChannel({}, void 0, e);
|
88
90
|
});
|
89
91
|
s(this, "openFileUpload", () => {
|
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.
|
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.addImageToCanvas, document.body.appendChild(this.fileInput)), this.fileInput.click();
|
91
93
|
});
|
92
|
-
s(this, "addImageToCanvas", (t) => {
|
93
|
-
|
94
|
-
const e =
|
94
|
+
s(this, "addImageToCanvas", async (t) => {
|
95
|
+
var h;
|
96
|
+
const e = t.target, a = (h = e.files) == null ? void 0 : h[0];
|
97
|
+
if (!a || !this.polycanvas || !this.uploadImageToS3) return;
|
98
|
+
const n = await this.uploadImageToS3(a), o = this.polycanvas.getViewport(), i = {
|
95
99
|
name: "image",
|
96
|
-
href:
|
97
|
-
x:
|
98
|
-
y:
|
99
|
-
|
100
|
-
|
101
|
-
...a
|
100
|
+
href: n,
|
101
|
+
x: o.x + 88,
|
102
|
+
y: o.y + 88
|
103
|
+
}, l = this.polycanvas.add({
|
104
|
+
...i
|
102
105
|
});
|
103
106
|
this.publishToChannel({
|
104
|
-
[
|
105
|
-
});
|
107
|
+
[l]: [void 0, { ...i, status: "locked" }]
|
108
|
+
}), e.value = "";
|
106
109
|
});
|
107
|
-
s(this, "
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
const i = await this.uploadImageToS3(a);
|
112
|
-
i !== "error" && (this.addImageToCanvas(i), e.value = "");
|
110
|
+
s(this, "updateCanvasConfig", (t, e, a) => {
|
111
|
+
this.polycanvas && (t > this.height && this.updateHeight(t), e && this.polycanvas.setViewport(e.x, e.y, e.zoom), a && this.polycanvas.setOptions({
|
112
|
+
grid: a
|
113
|
+
}));
|
113
114
|
});
|
114
115
|
s(this, "updateCanvas", ({ data: t, userId: e }) => {
|
115
116
|
const a = this.userType === "TEACHER" || e === this.userId;
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
});
|
121
|
-
} catch {
|
122
|
-
v("Error Updating Canvas", t);
|
123
|
-
}
|
117
|
+
Object.entries(t).forEach(([n, o]) => {
|
118
|
+
var i, l, h;
|
119
|
+
!o[0] && o[1] ? (i = this.polycanvas) == null || i.add({ ...o[1], cannotEdit: !a }, n) : o[0] && !o[1] ? (l = this.polycanvas) == null || l.delete(n) : o[0] && o[1] && ((h = this.polycanvas) == null || h.update(n, { ...o[1] }));
|
120
|
+
});
|
124
121
|
});
|
125
122
|
s(this, "toggleTiles", (t) => {
|
126
123
|
var e;
|
127
124
|
(e = this.polycanvas) == null || e.toggleSidebar(t);
|
128
125
|
});
|
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
|
-
});
|
138
126
|
s(this, "resetViewPort", () => {
|
139
127
|
this.polycanvas && this.polycanvas.resetViewport();
|
140
128
|
});
|
141
129
|
s(this, "changeGrid", (t) => {
|
142
|
-
|
130
|
+
this.polycanvas && (this.polycanvas.setOptions({
|
143
131
|
grid: t
|
144
|
-
}), this.
|
132
|
+
}), this.publishToChannel({}, t));
|
145
133
|
});
|
146
134
|
s(this, "lockSelectedTiles", () => {
|
147
|
-
var a,
|
148
|
-
const { tiles: t } = ((a = this.polycanvas) == null ? void 0 : a.serialize()) || {}, e = ((
|
135
|
+
var a, n;
|
136
|
+
const { tiles: t } = ((a = this.polycanvas) == null ? void 0 : a.serialize()) || {}, e = ((n = this.polycanvas) == null ? void 0 : n.getSelection()) || [];
|
149
137
|
if (e.length > 0 && t) {
|
150
138
|
const o = {};
|
151
|
-
e.forEach((
|
152
|
-
var
|
153
|
-
if (!((
|
154
|
-
const
|
155
|
-
(
|
139
|
+
e.forEach((i) => {
|
140
|
+
var h, c, p;
|
141
|
+
if (!((h = t[i]) != null && h.name)) return;
|
142
|
+
const l = { ...t[i], status: "locked" };
|
143
|
+
(c = this.polycanvas) == null || c.update(i, l), (p = t[i]) != null && p.name && (o[i] = [t[i], l]);
|
156
144
|
}), this.publishToChannel(o);
|
157
145
|
}
|
158
146
|
});
|
159
147
|
s(this, "unlockAllTiles", () => {
|
160
148
|
if (!this.polycanvas) return;
|
161
149
|
const { tiles: t } = this.polycanvas.serialize(), e = {};
|
162
|
-
t && Object.entries(t).length > 0 && (Object.entries(t).forEach(([a,
|
163
|
-
var
|
164
|
-
if (
|
165
|
-
const o = { ...
|
166
|
-
(
|
150
|
+
t && Object.entries(t).length > 0 && (Object.entries(t).forEach(([a, n]) => {
|
151
|
+
var i;
|
152
|
+
if (n.status !== "locked") return;
|
153
|
+
const o = { ...n, status: void 0 };
|
154
|
+
(i = this.polycanvas) == null || i.update(a, o), e[a] = [n, o];
|
167
155
|
}), this.publishToChannel(e));
|
168
156
|
});
|
169
157
|
s(this, "replaceCanvas", (t) => {
|
170
158
|
if (!this.polycanvas) return;
|
171
159
|
const { data: e, gridName: a } = t;
|
172
|
-
this.polycanvas.clear(), a && this.
|
173
|
-
|
160
|
+
this.polycanvas.clear(), a && this.polycanvas.setOptions({
|
161
|
+
grid: a
|
162
|
+
}), Object.entries(e).forEach(([n, o]) => {
|
163
|
+
var i;
|
174
164
|
if (!o[0] && o[1]) {
|
175
|
-
(
|
165
|
+
(i = this.polycanvas) == null || i.add({ ...o[1] }, n);
|
176
166
|
return;
|
177
167
|
}
|
178
|
-
}), this.publishToChannel(e);
|
168
|
+
}), this.publishToChannel(e, a);
|
179
169
|
});
|
180
170
|
s(this, "setTool", (t) => {
|
181
171
|
if (this.polycanvas) {
|
182
|
-
const [e, a] =
|
172
|
+
const [e, a] = m(t);
|
183
173
|
switch (e) {
|
184
174
|
case "clearAll":
|
185
175
|
this.clearCanvas();
|
@@ -232,10 +222,10 @@ class E {
|
|
232
222
|
*/
|
233
223
|
s(this, "update", (t) => {
|
234
224
|
if (Array.isArray(t)) {
|
235
|
-
const e = t.map((i) => i.height).filter(Boolean), a = Math.max(...e);
|
236
|
-
|
225
|
+
const e = t.map((i) => i.height).filter(Boolean), a = Math.max(...e), n = t.map((i) => i.dimension).filter(Boolean)[t.length - 1], o = t.map((i) => i.gridName).filter(Boolean)[t.length - 1];
|
226
|
+
this.updateCanvasConfig(a, n, o), t.forEach((i) => this.updateCanvas(i));
|
237
227
|
} else
|
238
|
-
t.height
|
228
|
+
this.updateCanvasConfig(t.height, t.dimension, t == null ? void 0 : t.gridName), this.updateCanvas(t);
|
239
229
|
});
|
240
230
|
s(this, "setColor", (t) => {
|
241
231
|
this.polycanvas && this.polycanvas.setColor(t);
|
@@ -247,9 +237,9 @@ class E {
|
|
247
237
|
s(this, "destroy", () => {
|
248
238
|
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));
|
249
239
|
});
|
250
|
-
this.onUpdateHeight =
|
240
|
+
this.onUpdateHeight = n, this.onUpdateActiveTool = a, this.height = i, this.uploadImageToS3 = o, this.userId = l, this.canvasId = h, this.publish = t, this.userType = c, this.renderAs = p, this.debouncedViewportChange = v(this.onViewPortChange, 300), e == null || e(this.canvasId, this.update);
|
251
241
|
}
|
252
|
-
async create({ canvasElementRef: t, canvasConfig: e, canvasSetting: a, initialData:
|
242
|
+
async create({ canvasElementRef: t, canvasConfig: e, canvasSetting: a, initialData: n }) {
|
253
243
|
if (!t.current)
|
254
244
|
throw new Error("PolyCanvas: Div Element Not found for canvas");
|
255
245
|
this.polycanvas = await window.Polypad.create(t.current, {
|
@@ -257,11 +247,11 @@ class E {
|
|
257
247
|
options: e
|
258
248
|
},
|
259
249
|
...a,
|
260
|
-
imageUpload: this.renderAs === "whiteboard" && this.userType === "TEACHER"
|
261
|
-
}), this.renderAs === "whiteboard" && this.userType === "TEACHER" && (this.polycanvas.toggleSidebar(!1),
|
250
|
+
imageUpload: this.renderAs === "whiteboard" && this.userType === "TEACHER" ? this.uploadFileToCanvas : void 0
|
251
|
+
}), this.renderAs === "whiteboard" && this.userType === "TEACHER" && (this.polycanvas.toggleSidebar(!1), f(t), this.polycanvas.on("viewport", this.debouncedViewportChange)), g(t), this.polycanvas.on("change", this.onChange), n && this.update(n);
|
262
252
|
}
|
263
253
|
}
|
264
254
|
export {
|
265
|
-
|
255
|
+
b as CueCanvasCore
|
266
256
|
};
|
267
257
|
//# sourceMappingURL=cue-canvas-core.js.map
|