@cuemath/leap 2.9.7-akm-1 → 2.9.7-gg1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.js +74 -102
- package/dist/features/circle-games/hooks/use-circle-sounds/use-circle-sounds.js.map +1 -1
- package/dist/features/worksheet/worksheet/hooks/use-create-imperative-handle.js +96 -78
- package/dist/features/worksheet/worksheet/hooks/use-create-imperative-handle.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-question/learnosity-question.js +79 -47
- package/dist/features/worksheet/worksheet/worksheet-question/learnosity-question.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-question/worksheet-question.js +150 -147
- package/dist/features/worksheet/worksheet/worksheet-question/worksheet-question.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-types.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet.js +325 -300
- package/dist/features/worksheet/worksheet/worksheet.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/package.json +1 -1
@@ -1,71 +1,103 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import { memo as
|
3
|
-
import
|
4
|
-
import { LearnosityQuestionContainer as
|
5
|
-
const
|
1
|
+
import { jsx as S } from "react/jsx-runtime";
|
2
|
+
import { memo as g, useRef as I, useCallback as M, useEffect as m } from "react";
|
3
|
+
import Q from "../hooks/use-learnosity-append.js";
|
4
|
+
import { LearnosityQuestionContainer as $ } from "./worksheet-question-styled.js";
|
5
|
+
const D = g(
|
6
6
|
({
|
7
7
|
signedRequest: R,
|
8
|
-
appended:
|
9
|
-
canRender:
|
10
|
-
canForceAppend:
|
11
|
-
question:
|
12
|
-
response:
|
13
|
-
learnosity:
|
14
|
-
isConceptIntro:
|
8
|
+
appended: o,
|
9
|
+
canRender: E,
|
10
|
+
canForceAppend: a,
|
11
|
+
question: n,
|
12
|
+
response: s,
|
13
|
+
learnosity: w,
|
14
|
+
isConceptIntro: h,
|
15
|
+
simState: u,
|
16
|
+
onMediaStateChange: _
|
15
17
|
}) => {
|
16
|
-
const
|
17
|
-
(
|
18
|
+
const c = I(null), t = I(s), { forceAppend: p } = Q(R), d = M(
|
19
|
+
(e) => {
|
20
|
+
const { source: r, data: i } = e, { type: l } = i ?? {};
|
21
|
+
l === "SIM_IS_READY" ? r.postMessage(
|
22
|
+
{
|
23
|
+
type: "SIMULATION_CONFIG",
|
24
|
+
payload: {
|
25
|
+
userRole: a ? "teacher" : "student",
|
26
|
+
simulationState: u
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"*"
|
30
|
+
) : l === "SIM_STATE_UPDATE" && _(n, "SIMULATION", e.data.payload);
|
31
|
+
},
|
32
|
+
[a, u, _, n]
|
33
|
+
), y = M(
|
34
|
+
(e) => {
|
18
35
|
window.requestAnimationFrame(() => {
|
19
|
-
var
|
20
|
-
const
|
21
|
-
|
22
|
-
|
23
|
-
}), (
|
24
|
-
question:
|
25
|
-
response:
|
26
|
-
callback: (
|
27
|
-
var
|
28
|
-
|
36
|
+
var i, l, T;
|
37
|
+
const r = document.createElement("div");
|
38
|
+
r.classList.add("learnosity-response"), r.classList.add(`question-${n.response_id}`), (l = (i = c.current) == null ? void 0 : i.children[0]) == null || l.querySelectorAll("svg path").forEach((f) => {
|
39
|
+
f.id = `${f.id} + temp`;
|
40
|
+
}), (T = c.current) == null || T.append(r), p({
|
41
|
+
question: n,
|
42
|
+
response: e,
|
43
|
+
callback: (f) => {
|
44
|
+
var v, A;
|
45
|
+
f || ((A = (v = c.current) == null ? void 0 : v.children[0]) == null || A.remove(), t.current && t.current !== e ? y(t.current) : t.current = void 0);
|
29
46
|
}
|
30
47
|
});
|
31
48
|
});
|
32
49
|
},
|
33
|
-
[p,
|
34
|
-
),
|
35
|
-
return
|
36
|
-
let
|
37
|
-
return
|
38
|
-
const
|
39
|
-
|
40
|
-
questions: [
|
41
|
-
...
|
50
|
+
[p, n]
|
51
|
+
), L = I(!1);
|
52
|
+
return m(() => {
|
53
|
+
let e;
|
54
|
+
return E && (L.current || (e = window.requestAnimationFrame(() => {
|
55
|
+
const r = t.current ?? s;
|
56
|
+
L.current = !0, w.appendQuestion({
|
57
|
+
questions: [n],
|
58
|
+
...r ? {
|
42
59
|
responses: {
|
43
|
-
[
|
60
|
+
[n.response_id]: {
|
44
61
|
// Learnosity is mutating the response object, so we need to clone it
|
45
|
-
...
|
62
|
+
...r
|
46
63
|
}
|
47
64
|
}
|
48
65
|
} : {}
|
49
66
|
});
|
50
67
|
}))), () => {
|
51
|
-
|
68
|
+
e && window.cancelAnimationFrame(e);
|
52
69
|
};
|
53
|
-
}, [
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
70
|
+
}, [E, w, n, s]), m(() => {
|
71
|
+
var e;
|
72
|
+
return o && (t.current = void 0, (e = c.current) != null && e.querySelector("iframe") && window.addEventListener("message", d)), () => {
|
73
|
+
window.removeEventListener("message", d);
|
74
|
+
};
|
75
|
+
}, [o, d]), m(() => {
|
76
|
+
var e, r;
|
77
|
+
if (u && o) {
|
78
|
+
const i = (e = c.current) == null ? void 0 : e.querySelector("iframe");
|
79
|
+
i && ((r = i.contentWindow) == null || r.postMessage(
|
80
|
+
{
|
81
|
+
type: "SIM_STATE_UPDATE",
|
82
|
+
payload: u
|
83
|
+
},
|
84
|
+
"*"
|
85
|
+
));
|
86
|
+
}
|
87
|
+
}, [o, a, u]), m(() => {
|
88
|
+
o && s && a && s !== t.current && (t.current ? t.current = s : (t.current = s, y(s)));
|
89
|
+
}, [o, a, s, y]), /* @__PURE__ */ S(
|
90
|
+
$,
|
59
91
|
{
|
60
|
-
ref:
|
61
|
-
$isConceptIntro:
|
62
|
-
$isTeacher:
|
63
|
-
children: /* @__PURE__ */
|
92
|
+
ref: c,
|
93
|
+
$isConceptIntro: h,
|
94
|
+
$isTeacher: a,
|
95
|
+
children: /* @__PURE__ */ S("div", { className: `learnosity-response question-${n.response_id}` })
|
64
96
|
}
|
65
97
|
);
|
66
98
|
}
|
67
99
|
);
|
68
100
|
export {
|
69
|
-
|
101
|
+
D as default
|
70
102
|
};
|
71
103
|
//# sourceMappingURL=learnosity-question.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"learnosity-question.js","sources":["../../../../../src/features/worksheet/worksheet/worksheet-question/learnosity-question.tsx"],"sourcesContent":["import type { ILearnosityQuestionResponse } from '../worksheet-types';\nimport type { ILearnosityQuestionProps } from './worksheet-question-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useRef } from 'react';\n\nimport useLearnosityAppend from '../hooks/use-learnosity-append';\nimport * as Styled from './worksheet-question-styled';\n\nconst LearnosityQuestion: FC<ILearnosityQuestionProps> = memo(\n ({\n signedRequest,\n appended,\n canRender,\n canForceAppend,\n question,\n response,\n learnosity,\n isConceptIntro,\n }) => {\n const containerElementRef = useRef<HTMLDivElement>(null);\n const latestQuestionResponseRef = useRef<ILearnosityQuestionResponse | undefined>(response);\n const { forceAppend } = useLearnosityAppend(signedRequest);\n\n const updateResponse = useCallback(\n (newResponse: ILearnosityQuestionResponse) => {\n window.requestAnimationFrame(() => {\n const questionElement = document.createElement('div');\n\n questionElement.classList.add('learnosity-response');\n questionElement.classList.add(`question-${question.response_id}`);\n // Drawing questions looks for already appended path elements with id, if present it will not append the path, to overcome this issue we are adding temp to the id\n containerElementRef.current?.children[0]?.querySelectorAll('svg path').forEach(path => {\n path.id = `${path.id} + temp`;\n });\n\n containerElementRef.current?.append(questionElement);\n forceAppend({\n question,\n response: newResponse,\n callback: error => {\n if (error) return;\n\n containerElementRef.current?.children[0]?.remove();\n\n if (\n latestQuestionResponseRef.current &&\n latestQuestionResponseRef.current !== newResponse\n )\n updateResponse(latestQuestionResponseRef.current);\n else latestQuestionResponseRef.current = undefined;\n },\n });\n });\n },\n [forceAppend, question],\n );\n\n const appendQuestionCalledRef = useRef(false);\n\n useEffect(() => {\n let requestId: number;\n\n if (canRender) {\n if (!appendQuestionCalledRef.current) {\n requestId = window.requestAnimationFrame(() => {\n const appenndableResponse = latestQuestionResponseRef.current ?? response;\n\n appendQuestionCalledRef.current = true;\n learnosity.appendQuestion({\n questions: [question],\n ...(appenndableResponse\n ? {\n responses: {\n [question.response_id]: {\n // Learnosity is mutating the response object, so we need to clone it\n ...appenndableResponse,\n },\n },\n }\n : {}),\n });\n });\n }\n }\n\n return () => {\n if (requestId) window.cancelAnimationFrame(requestId);\n };\n }, [canRender, learnosity, question, response]);\n\n useEffect(() => {\n if (appended) {\n latestQuestionResponseRef.current = undefined;\n }\n }, [appended]);\n\n useEffect(() => {\n if (appended && response && canForceAppend) {\n if (response !== latestQuestionResponseRef.current) {\n if (!latestQuestionResponseRef.current) {\n latestQuestionResponseRef.current = response;\n updateResponse(response);\n } else {\n latestQuestionResponseRef.current = response;\n }\n }\n }\n }, [appended, canForceAppend, response, updateResponse]);\n\n return (\n <Styled.LearnosityQuestionContainer\n ref={containerElementRef}\n $isConceptIntro={isConceptIntro}\n $isTeacher={canForceAppend}\n >\n <div className={`learnosity-response question-${question.response_id}`} />\n </Styled.LearnosityQuestionContainer>\n );\n },\n);\n\nexport default LearnosityQuestion;\n"],"names":["LearnosityQuestion","memo","signedRequest","appended","canRender","canForceAppend","question","response","learnosity","isConceptIntro","containerElementRef","useRef","latestQuestionResponseRef","forceAppend","useLearnosityAppend","
|
1
|
+
{"version":3,"file":"learnosity-question.js","sources":["../../../../../src/features/worksheet/worksheet/worksheet-question/learnosity-question.tsx"],"sourcesContent":["import type { ILearnosityQuestionResponse } from '../worksheet-types';\nimport type { ILearnosityQuestionProps } from './worksheet-question-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useRef } from 'react';\n\nimport useLearnosityAppend from '../hooks/use-learnosity-append';\nimport * as Styled from './worksheet-question-styled';\n\nconst LearnosityQuestion: FC<ILearnosityQuestionProps> = memo(\n ({\n signedRequest,\n appended,\n canRender,\n canForceAppend,\n question,\n response,\n learnosity,\n isConceptIntro,\n simState,\n onMediaStateChange,\n }) => {\n const containerElementRef = useRef<HTMLDivElement>(null);\n const latestQuestionResponseRef = useRef<ILearnosityQuestionResponse | undefined>(response);\n const { forceAppend } = useLearnosityAppend(signedRequest);\n\n const handleSimIframeMessage = useCallback(\n (event: MessageEvent) => {\n const { source, data } = event;\n const { type } = data ?? ({} as { type: string });\n\n if (type === 'SIM_IS_READY') {\n (source as Window).postMessage(\n {\n type: 'SIMULATION_CONFIG',\n payload: {\n userRole: canForceAppend ? 'teacher' : 'student',\n simulationState: simState,\n },\n },\n '*',\n );\n } else if (type === 'SIM_STATE_UPDATE') {\n onMediaStateChange(question, 'SIMULATION', event.data.payload);\n }\n },\n [canForceAppend, simState, onMediaStateChange, question],\n );\n\n const updateResponse = useCallback(\n (newResponse: ILearnosityQuestionResponse) => {\n window.requestAnimationFrame(() => {\n const questionElement = document.createElement('div');\n\n questionElement.classList.add('learnosity-response');\n questionElement.classList.add(`question-${question.response_id}`);\n // Drawing questions looks for already appended path elements with id, if present it will not append the path, to overcome this issue we are adding temp to the id\n containerElementRef.current?.children[0]?.querySelectorAll('svg path').forEach(path => {\n path.id = `${path.id} + temp`;\n });\n\n containerElementRef.current?.append(questionElement);\n forceAppend({\n question,\n response: newResponse,\n callback: error => {\n if (error) return;\n\n containerElementRef.current?.children[0]?.remove();\n\n if (\n latestQuestionResponseRef.current &&\n latestQuestionResponseRef.current !== newResponse\n )\n updateResponse(latestQuestionResponseRef.current);\n else latestQuestionResponseRef.current = undefined;\n },\n });\n });\n },\n [forceAppend, question],\n );\n\n const appendQuestionCalledRef = useRef(false);\n\n useEffect(() => {\n let requestId: number;\n\n if (canRender) {\n if (!appendQuestionCalledRef.current) {\n requestId = window.requestAnimationFrame(() => {\n const appenndableResponse = latestQuestionResponseRef.current ?? response;\n\n appendQuestionCalledRef.current = true;\n learnosity.appendQuestion({\n questions: [question],\n ...(appenndableResponse\n ? {\n responses: {\n [question.response_id]: {\n // Learnosity is mutating the response object, so we need to clone it\n ...appenndableResponse,\n },\n },\n }\n : {}),\n });\n });\n }\n }\n\n return () => {\n if (requestId) window.cancelAnimationFrame(requestId);\n };\n }, [canRender, learnosity, question, response]);\n\n useEffect(() => {\n if (appended) {\n latestQuestionResponseRef.current = undefined;\n\n if (containerElementRef.current?.querySelector('iframe')) {\n window.addEventListener('message', handleSimIframeMessage);\n }\n }\n\n return () => {\n window.removeEventListener('message', handleSimIframeMessage);\n };\n }, [appended, handleSimIframeMessage]);\n\n useEffect(() => {\n if (simState && appended) {\n const simIframe = containerElementRef.current?.querySelector('iframe');\n\n if (simIframe) {\n simIframe.contentWindow?.postMessage(\n {\n type: 'SIM_STATE_UPDATE',\n payload: simState,\n },\n '*',\n );\n }\n }\n }, [appended, canForceAppend, simState]);\n\n useEffect(() => {\n if (appended && response && canForceAppend) {\n if (response !== latestQuestionResponseRef.current) {\n if (!latestQuestionResponseRef.current) {\n latestQuestionResponseRef.current = response;\n updateResponse(response);\n } else {\n latestQuestionResponseRef.current = response;\n }\n }\n }\n }, [appended, canForceAppend, response, updateResponse]);\n\n return (\n <Styled.LearnosityQuestionContainer\n ref={containerElementRef}\n $isConceptIntro={isConceptIntro}\n $isTeacher={canForceAppend}\n >\n <div className={`learnosity-response question-${question.response_id}`} />\n </Styled.LearnosityQuestionContainer>\n );\n },\n);\n\nexport default LearnosityQuestion;\n"],"names":["LearnosityQuestion","memo","signedRequest","appended","canRender","canForceAppend","question","response","learnosity","isConceptIntro","simState","onMediaStateChange","containerElementRef","useRef","latestQuestionResponseRef","forceAppend","useLearnosityAppend","handleSimIframeMessage","useCallback","event","source","data","type","updateResponse","newResponse","questionElement","_b","_a","path","_c","error","appendQuestionCalledRef","useEffect","requestId","appenndableResponse","simIframe","jsx","Styled.LearnosityQuestionContainer"],"mappings":";;;;AASA,MAAMA,IAAmDC;AAAA,EACvD,CAAC;AAAA,IACC,eAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,UAAAC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