@cuemath/leap 3.5.30-gg2 → 3.5.30-gg4
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/worksheet/worksheet/worksheet-provider.js +13 -12
- package/dist/features/worksheet/worksheet/worksheet-provider.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-store.js +160 -152
- package/dist/features/worksheet/worksheet/worksheet-store.js.map +1 -1
- package/dist/features/worksheet/worksheet/worksheet-types.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/node_modules/zustand/esm/middleware.js +17 -191
- package/dist/node_modules/zustand/esm/middleware.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { memo as c, useRef as
|
|
3
|
-
import { createWorksheetStore as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { memo as c, useRef as u, useEffect as s } from "react";
|
|
3
|
+
import { createWorksheetStore as i, WorksheetContext as m } from "./worksheet-store.js";
|
|
4
|
+
const v = c(
|
|
5
5
|
function({ children: n, ...e }) {
|
|
6
|
-
const
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
}, [e]),
|
|
10
|
-
const
|
|
6
|
+
const t = u(i(e));
|
|
7
|
+
return s(() => {
|
|
8
|
+
t.current.getState().mergeWorksheetProps(e);
|
|
9
|
+
}, [e]), s(() => {
|
|
10
|
+
const r = t.current;
|
|
11
11
|
return () => {
|
|
12
|
-
|
|
12
|
+
const o = r == null ? void 0 : r.getState();
|
|
13
|
+
o && typeof o.destroy == "function" && o.destroy();
|
|
13
14
|
};
|
|
14
|
-
}, []), /* @__PURE__ */
|
|
15
|
+
}, []), /* @__PURE__ */ f(m.Provider, { value: t.current, children: n });
|
|
15
16
|
}
|
|
16
17
|
);
|
|
17
18
|
export {
|
|
18
|
-
|
|
19
|
+
v as default
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=worksheet-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worksheet-provider.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-provider.tsx"],"sourcesContent":["import { memo, useEffect, useRef, type FC, type PropsWithChildren } from 'react';\n\nimport { createWorksheetStore, WorksheetContext } from './worksheet-store';\nimport type { TWorksheetStoreProps } from './worksheet-types';\n\nconst WorksheetProvider: FC<PropsWithChildren<TWorksheetStoreProps>> = memo(\n function WorksheetProvider({ children, ...worksheetProps }) {\n const storeRef = useRef(createWorksheetStore(worksheetProps));\n\n useEffect(() => {\n storeRef.current.getState().mergeWorksheetProps(worksheetProps);\n }, [worksheetProps]);\n\n useEffect(() => {\n const
|
|
1
|
+
{"version":3,"file":"worksheet-provider.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-provider.tsx"],"sourcesContent":["import { memo, useEffect, useRef, type FC, type PropsWithChildren } from 'react';\n\nimport { createWorksheetStore, WorksheetContext } from './worksheet-store';\nimport type { TWorksheetStoreProps } from './worksheet-types';\n\nconst WorksheetProvider: FC<PropsWithChildren<TWorksheetStoreProps>> = memo(\n function WorksheetProvider({ children, ...worksheetProps }) {\n const storeRef = useRef(createWorksheetStore(worksheetProps));\n\n useEffect(() => {\n storeRef.current.getState().mergeWorksheetProps(worksheetProps);\n }, [worksheetProps]);\n\n useEffect(() => {\n const currentStore = storeRef.current;\n\n return () => {\n const state = currentStore?.getState();\n\n if (state && typeof state.destroy === 'function') {\n state.destroy();\n }\n };\n }, []);\n\n return (\n <WorksheetContext.Provider value={storeRef.current}>{children}</WorksheetContext.Provider>\n );\n },\n);\n\nexport default WorksheetProvider;\n"],"names":["WorksheetProvider","memo","children","worksheetProps","storeRef","useRef","createWorksheetStore","useEffect","currentStore","state","WorksheetContext"],"mappings":";;;AAKA,MAAMA,IAAiEC;AAAA,EACrE,SAA2B,EAAE,UAAAC,GAAU,GAAGC,KAAkB;AAC1D,UAAMC,IAAWC,EAAOC,EAAqBH,CAAc,CAAC;AAE5D,WAAAI,EAAU,MAAM;AACd,MAAAH,EAAS,QAAQ,SAAW,EAAA,oBAAoBD,CAAc;AAAA,IAAA,GAC7D,CAACA,CAAc,CAAC,GAEnBI,EAAU,MAAM;AACd,YAAMC,IAAeJ,EAAS;AAE9B,aAAO,MAAM;AACL,cAAAK,IAAQD,KAAA,gBAAAA,EAAc;AAE5B,QAAIC,KAAS,OAAOA,EAAM,WAAY,cACpCA,EAAM,QAAQ;AAAA,MAChB;AAAA,IAEJ,GAAG,CAAE,CAAA,qBAGFC,EAAiB,UAAjB,EAA0B,OAAON,EAAS,SAAU,UAAAF,EAAS,CAAA;AAAA,EAElE;AACF;"}
|
|
@@ -1,260 +1,268 @@
|
|
|
1
1
|
import { createContext as Q } from "react";
|
|
2
|
-
import { createStore as
|
|
3
|
-
import {
|
|
4
|
-
import { getLastUnlockedQuestionIndex as
|
|
2
|
+
import { createStore as A } from "zustand";
|
|
3
|
+
import { subscribeWithSelector as _ } from "../../../node_modules/zustand/esm/middleware.js";
|
|
4
|
+
import { getLastUnlockedQuestionIndex as S, scrollToQuestion as V, getQuestionsFromItems as q, getInitialResponses as w, getInitialQuestionId as B, getLastAttemptableQuestionIndex as M, getWorksheetDimensions as H, getQuestionMetadata as N } from "./worksheet-helpers.js";
|
|
5
5
|
const k = ({
|
|
6
6
|
teacherValidationEnabled: u,
|
|
7
|
-
userType:
|
|
8
|
-
lastUnlockedQuestion:
|
|
9
|
-
lastUnlockedQuestionResponse:
|
|
7
|
+
userType: n,
|
|
8
|
+
lastUnlockedQuestion: b,
|
|
9
|
+
lastUnlockedQuestionResponse: s
|
|
10
10
|
}) => {
|
|
11
11
|
if (u) {
|
|
12
|
-
const { item_type: o, instructor_stimulus:
|
|
13
|
-
if (
|
|
14
|
-
if (o === "exit-ticket" &&
|
|
15
|
-
return
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
12
|
+
const { item_type: o, instructor_stimulus: e, is_optional: i } = b;
|
|
13
|
+
if (n === "TEACHER") {
|
|
14
|
+
if (o === "exit-ticket" && e !== "SystemIntro")
|
|
15
|
+
return s != null && s.submittedByStudent && !(s != null && s.validatedByTeacher) ? "exit-ticket-review-available" : s != null && s.validatedByTeacher ? void 0 : "exit-ticket-teacher-intervention";
|
|
16
|
+
if (i)
|
|
17
|
+
return s != null && s.assignStatus ? void 0 : "optional-items-assignment";
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}, x = ({
|
|
21
21
|
userType: u,
|
|
22
|
-
questions:
|
|
23
|
-
responses:
|
|
24
|
-
behavior:
|
|
22
|
+
questions: n,
|
|
23
|
+
responses: b,
|
|
24
|
+
behavior: s,
|
|
25
25
|
lastUnlockedQuestionIndex: o
|
|
26
|
-
}) =>
|
|
27
|
-
var
|
|
28
|
-
const
|
|
29
|
-
return !(!
|
|
30
|
-
}),
|
|
31
|
-
var
|
|
26
|
+
}) => n.filter((e, i) => {
|
|
27
|
+
var l;
|
|
28
|
+
const a = u === "TEACHER" ? !0 : i <= o, { response_id: c, is_optional: t } = e, r = (l = b[c]) == null ? void 0 : l.assignStatus;
|
|
29
|
+
return !(!a || s.teacherValidationEnabled && (r === "skipped" || t && r !== "assigned" && u === "STUDENT"));
|
|
30
|
+
}), T = (u, n) => {
|
|
31
|
+
var v;
|
|
32
32
|
const {
|
|
33
|
-
learnosityItems:
|
|
34
|
-
learnosityResponses:
|
|
33
|
+
learnosityItems: b,
|
|
34
|
+
learnosityResponses: s,
|
|
35
35
|
updatedResponses: o,
|
|
36
|
-
layout:
|
|
37
|
-
behavior:
|
|
38
|
-
userType:
|
|
39
|
-
initialResponseId:
|
|
40
|
-
initialItemIndex:
|
|
41
|
-
} = u, { navigationMode:
|
|
42
|
-
sectioned:
|
|
43
|
-
adaptive:
|
|
44
|
-
}), f = o ?? (
|
|
45
|
-
questions:
|
|
36
|
+
layout: e,
|
|
37
|
+
behavior: i,
|
|
38
|
+
userType: a,
|
|
39
|
+
initialResponseId: c,
|
|
40
|
+
initialItemIndex: t
|
|
41
|
+
} = u, { navigationMode: r, teacherValidationEnabled: l, initialQuestion: d } = i, m = (n == null ? void 0 : n.questions) ?? q(b, {
|
|
42
|
+
sectioned: l && r !== "ADAPTIVE" && r !== "CURRENT",
|
|
43
|
+
adaptive: r === "ADAPTIVE"
|
|
44
|
+
}), f = o ?? (n == null ? void 0 : n.responses) ?? s ?? w(m), g = S({
|
|
45
|
+
questions: m,
|
|
46
46
|
responses: f,
|
|
47
|
-
behavior:
|
|
48
|
-
userType:
|
|
49
|
-
}),
|
|
50
|
-
questions:
|
|
51
|
-
initialQuestion:
|
|
52
|
-
lastUnlockedQuestionIndex:
|
|
47
|
+
behavior: i,
|
|
48
|
+
userType: a
|
|
49
|
+
}), h = (n == null ? void 0 : n.initialQuestionId) ?? B({
|
|
50
|
+
questions: m,
|
|
51
|
+
initialQuestion: d,
|
|
52
|
+
lastUnlockedQuestionIndex: g,
|
|
53
53
|
lastAttemptableQuestionIndex: M({
|
|
54
|
-
questions:
|
|
54
|
+
questions: m,
|
|
55
55
|
responses: f,
|
|
56
|
-
behavior:
|
|
57
|
-
userType:
|
|
56
|
+
behavior: i,
|
|
57
|
+
userType: a
|
|
58
58
|
}),
|
|
59
|
-
initialResponseId:
|
|
60
|
-
initialItemIndex:
|
|
61
|
-
}),
|
|
62
|
-
(
|
|
59
|
+
initialResponseId: c,
|
|
60
|
+
initialItemIndex: t
|
|
61
|
+
}), p = (n == null ? void 0 : n.activeQuestionId) ?? h, y = m.findIndex(
|
|
62
|
+
(E) => E.response_id === p
|
|
63
63
|
);
|
|
64
64
|
return {
|
|
65
|
-
questions:
|
|
65
|
+
questions: m,
|
|
66
66
|
renderableQuestions: x({
|
|
67
|
-
questions:
|
|
67
|
+
questions: m,
|
|
68
68
|
responses: f,
|
|
69
|
-
behavior:
|
|
70
|
-
userType:
|
|
71
|
-
lastUnlockedQuestionIndex:
|
|
69
|
+
behavior: i,
|
|
70
|
+
userType: a,
|
|
71
|
+
lastUnlockedQuestionIndex: g
|
|
72
72
|
}),
|
|
73
73
|
responses: f,
|
|
74
|
-
lastUnlockedQuestionIndex:
|
|
75
|
-
initialQuestionId:
|
|
76
|
-
activeQuestionId:
|
|
77
|
-
activeQuestionIndex:
|
|
78
|
-
summaryVisible:
|
|
79
|
-
calculatorVisible:
|
|
80
|
-
scribblingEnabled:
|
|
74
|
+
lastUnlockedQuestionIndex: g,
|
|
75
|
+
initialQuestionId: h,
|
|
76
|
+
activeQuestionId: p,
|
|
77
|
+
activeQuestionIndex: y,
|
|
78
|
+
summaryVisible: n ? n.summaryVisible : !1,
|
|
79
|
+
calculatorVisible: n ? n.calculatorVisible : !1,
|
|
80
|
+
scribblingEnabled: n ? n.scribblingEnabled : !1,
|
|
81
81
|
blocker: k({
|
|
82
|
-
currentBlocker:
|
|
83
|
-
teacherValidationEnabled:
|
|
84
|
-
userType:
|
|
85
|
-
lastUnlockedQuestion:
|
|
86
|
-
lastUnlockedQuestionResponse: f[((
|
|
82
|
+
currentBlocker: n == null ? void 0 : n.blocker,
|
|
83
|
+
teacherValidationEnabled: i.teacherValidationEnabled,
|
|
84
|
+
userType: a,
|
|
85
|
+
lastUnlockedQuestion: m[g],
|
|
86
|
+
lastUnlockedQuestionResponse: f[((v = m[g]) == null ? void 0 : v.response_id) ?? ""]
|
|
87
87
|
}),
|
|
88
|
-
...H(
|
|
88
|
+
...H(b, e)
|
|
89
89
|
};
|
|
90
|
-
},
|
|
91
|
-
const
|
|
92
|
-
return
|
|
90
|
+
}, I = (u, n, b) => {
|
|
91
|
+
const s = N(u.questions, n);
|
|
92
|
+
return s ? {
|
|
93
93
|
...u,
|
|
94
94
|
responses: {
|
|
95
95
|
...u.responses,
|
|
96
|
-
[
|
|
97
|
-
...
|
|
98
|
-
...u.responses[
|
|
99
|
-
...
|
|
96
|
+
[n]: {
|
|
97
|
+
...s,
|
|
98
|
+
...u.responses[n],
|
|
99
|
+
...b
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
} : u;
|
|
103
|
-
}, P = (u) =>
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
}, P = (u) => {
|
|
104
|
+
const n = /* @__PURE__ */ new Set(), b = (o, e) => {
|
|
105
|
+
const i = setTimeout(() => {
|
|
106
|
+
n.delete(i), o();
|
|
107
|
+
}, e);
|
|
108
|
+
return n.add(i), i;
|
|
109
|
+
}, s = () => {
|
|
110
|
+
n.forEach((o) => clearTimeout(o)), n.clear();
|
|
111
|
+
};
|
|
112
|
+
return A()(
|
|
113
|
+
_((o) => ({
|
|
106
114
|
// Initialize with exact props passed in
|
|
107
115
|
...u,
|
|
108
|
-
...
|
|
116
|
+
...T(u),
|
|
109
117
|
// Actions
|
|
110
118
|
mergeWorksheetProps: (e) => {
|
|
111
|
-
|
|
112
|
-
...
|
|
119
|
+
o((i) => ({
|
|
120
|
+
...i,
|
|
113
121
|
...e,
|
|
114
|
-
...
|
|
122
|
+
...T(e, i)
|
|
115
123
|
}));
|
|
116
124
|
},
|
|
117
125
|
setResponses: (e) => {
|
|
118
|
-
|
|
119
|
-
var
|
|
120
|
-
const
|
|
121
|
-
...
|
|
122
|
-
responses: typeof e == "function" ? e(
|
|
123
|
-
}, { questions:
|
|
124
|
-
questions:
|
|
126
|
+
o((i) => {
|
|
127
|
+
var m;
|
|
128
|
+
const a = {
|
|
129
|
+
...i,
|
|
130
|
+
responses: typeof e == "function" ? e(i.responses) : e
|
|
131
|
+
}, { questions: c, responses: t, behavior: r, userType: l } = a, d = S({
|
|
132
|
+
questions: c,
|
|
125
133
|
responses: t,
|
|
126
134
|
behavior: r,
|
|
127
135
|
userType: l
|
|
128
136
|
});
|
|
129
137
|
return {
|
|
130
|
-
...
|
|
131
|
-
lastUnlockedQuestionIndex:
|
|
138
|
+
...a,
|
|
139
|
+
lastUnlockedQuestionIndex: d,
|
|
132
140
|
renderableQuestions: x({
|
|
133
|
-
questions:
|
|
141
|
+
questions: c,
|
|
134
142
|
responses: t,
|
|
135
143
|
behavior: r,
|
|
136
144
|
userType: l,
|
|
137
|
-
lastUnlockedQuestionIndex:
|
|
145
|
+
lastUnlockedQuestionIndex: d
|
|
138
146
|
}),
|
|
139
147
|
blocker: k({
|
|
140
|
-
currentBlocker:
|
|
148
|
+
currentBlocker: i == null ? void 0 : i.blocker,
|
|
141
149
|
teacherValidationEnabled: r.teacherValidationEnabled,
|
|
142
150
|
userType: l,
|
|
143
|
-
lastUnlockedQuestion:
|
|
144
|
-
lastUnlockedQuestionResponse: t[((
|
|
151
|
+
lastUnlockedQuestion: c[d],
|
|
152
|
+
lastUnlockedQuestionResponse: t[((m = c[d]) == null ? void 0 : m.response_id) ?? ""]
|
|
145
153
|
})
|
|
146
154
|
};
|
|
147
155
|
});
|
|
148
156
|
},
|
|
149
|
-
updateResponse: ({ responseId: e, response:
|
|
150
|
-
|
|
151
|
-
var
|
|
152
|
-
const l = !!
|
|
153
|
-
response:
|
|
154
|
-
score:
|
|
157
|
+
updateResponse: ({ responseId: e, response: i, score: a, answerChecked: c, timeSpent: t }) => {
|
|
158
|
+
o((r) => {
|
|
159
|
+
var E;
|
|
160
|
+
const l = !!c, d = r.responses[e], m = I(r, e, {
|
|
161
|
+
response: i,
|
|
162
|
+
score: a,
|
|
155
163
|
responseEdited: !l,
|
|
156
|
-
attemptsHistory: l ? [...(
|
|
157
|
-
skipped: !
|
|
164
|
+
attemptsHistory: l ? [...(d == null ? void 0 : d.attemptsHistory) ?? [], { response: i, score: a }] : d == null ? void 0 : d.attemptsHistory,
|
|
165
|
+
skipped: !i,
|
|
158
166
|
timeSpent: t
|
|
159
|
-
}), { questions:
|
|
160
|
-
questions:
|
|
167
|
+
}), { questions: f, responses: g, behavior: h, userType: p } = m, y = S({
|
|
168
|
+
questions: f,
|
|
161
169
|
responses: g,
|
|
162
|
-
behavior:
|
|
163
|
-
userType:
|
|
164
|
-
}),
|
|
165
|
-
return
|
|
170
|
+
behavior: h,
|
|
171
|
+
userType: p
|
|
172
|
+
}), v = g[e];
|
|
173
|
+
return v && r.onResponseChange && r.onResponseChange({
|
|
166
174
|
responseId: e,
|
|
167
|
-
response:
|
|
168
|
-
question:
|
|
175
|
+
response: v,
|
|
176
|
+
question: f.find((C) => C.response_id === e),
|
|
169
177
|
isNewAttempt: l
|
|
170
178
|
}), {
|
|
171
|
-
...
|
|
172
|
-
lastUnlockedQuestionIndex:
|
|
179
|
+
...m,
|
|
180
|
+
lastUnlockedQuestionIndex: y,
|
|
173
181
|
renderableQuestions: x({
|
|
174
|
-
questions:
|
|
182
|
+
questions: f,
|
|
175
183
|
responses: g,
|
|
176
|
-
behavior:
|
|
177
|
-
userType:
|
|
178
|
-
lastUnlockedQuestionIndex:
|
|
184
|
+
behavior: h,
|
|
185
|
+
userType: p,
|
|
186
|
+
lastUnlockedQuestionIndex: y
|
|
179
187
|
}),
|
|
180
188
|
blocker: k({
|
|
181
189
|
currentBlocker: r == null ? void 0 : r.blocker,
|
|
182
|
-
teacherValidationEnabled:
|
|
183
|
-
userType:
|
|
184
|
-
lastUnlockedQuestion:
|
|
185
|
-
lastUnlockedQuestionResponse: g[((
|
|
190
|
+
teacherValidationEnabled: h.teacherValidationEnabled,
|
|
191
|
+
userType: p,
|
|
192
|
+
lastUnlockedQuestion: f[y],
|
|
193
|
+
lastUnlockedQuestionResponse: g[((E = f[y]) == null ? void 0 : E.response_id) ?? ""]
|
|
186
194
|
})
|
|
187
195
|
};
|
|
188
196
|
});
|
|
189
197
|
},
|
|
190
|
-
updateMediaState: (e,
|
|
191
|
-
const
|
|
192
|
-
|
|
198
|
+
updateMediaState: (e, i, a) => {
|
|
199
|
+
const c = i === "SIMULATION" ? "simState" : void 0;
|
|
200
|
+
c && o((t) => {
|
|
193
201
|
if (t.onResponseChange) {
|
|
194
|
-
const r =
|
|
202
|
+
const r = I(t, e, { [c]: a }), l = r == null ? void 0 : r.responses[e];
|
|
195
203
|
return l && t.onResponseChange({
|
|
196
204
|
responseId: e,
|
|
197
205
|
response: l,
|
|
198
206
|
isNewAttempt: !1,
|
|
199
|
-
question: t.questions.find((
|
|
207
|
+
question: t.questions.find((d) => d.response_id === e)
|
|
200
208
|
}), r;
|
|
201
209
|
}
|
|
202
210
|
return t.onMediaStateChange && t.onMediaStateChange(
|
|
203
211
|
t.questions.find((r) => r.response_id === e),
|
|
204
|
-
|
|
205
|
-
|
|
212
|
+
i,
|
|
213
|
+
a
|
|
206
214
|
), t;
|
|
207
215
|
});
|
|
208
216
|
},
|
|
209
217
|
showSummary: () => {
|
|
210
|
-
|
|
218
|
+
o((e) => ({
|
|
211
219
|
...e,
|
|
212
220
|
summaryVisible: !0
|
|
213
221
|
}));
|
|
214
222
|
},
|
|
215
223
|
hideSummary: () => {
|
|
216
|
-
|
|
224
|
+
o((e) => ({
|
|
217
225
|
...e,
|
|
218
226
|
summaryVisible: !1
|
|
219
227
|
}));
|
|
220
228
|
},
|
|
221
229
|
toggleSummary: () => {
|
|
222
|
-
|
|
230
|
+
o((e) => ({
|
|
223
231
|
...e,
|
|
224
232
|
summaryVisible: !e.summaryVisible
|
|
225
233
|
}));
|
|
226
234
|
},
|
|
227
235
|
showCalculator: () => {
|
|
228
|
-
|
|
236
|
+
o((e) => ({
|
|
229
237
|
...e,
|
|
230
238
|
calculatorVisible: !0
|
|
231
239
|
}));
|
|
232
240
|
},
|
|
233
241
|
hideCalculator: () => {
|
|
234
|
-
|
|
242
|
+
o((e) => ({
|
|
235
243
|
...e,
|
|
236
244
|
calculatorVisible: !1
|
|
237
245
|
}));
|
|
238
246
|
},
|
|
239
247
|
toggleScribble: () => {
|
|
240
|
-
|
|
248
|
+
o((e) => ({
|
|
241
249
|
...e,
|
|
242
250
|
scribblingEnabled: !e.scribblingEnabled
|
|
243
251
|
}));
|
|
244
252
|
},
|
|
245
253
|
setBlocker: (e) => {
|
|
246
|
-
|
|
247
|
-
...
|
|
254
|
+
o((i) => ({
|
|
255
|
+
...i,
|
|
248
256
|
blocker: e
|
|
249
257
|
}));
|
|
250
258
|
},
|
|
251
259
|
removeBlocker: () => {
|
|
252
|
-
|
|
253
|
-
var
|
|
260
|
+
o((e) => {
|
|
261
|
+
var i;
|
|
254
262
|
if (e.blocker) {
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
263
|
+
const a = (i = e.questions[e.lastUnlockedQuestionIndex]) == null ? void 0 : i.response_id;
|
|
264
|
+
a && b(() => {
|
|
265
|
+
V(a);
|
|
258
266
|
}, 50);
|
|
259
267
|
}
|
|
260
268
|
return {
|
|
@@ -263,29 +271,29 @@ const k = ({
|
|
|
263
271
|
};
|
|
264
272
|
});
|
|
265
273
|
},
|
|
266
|
-
markForReview: (e,
|
|
267
|
-
|
|
274
|
+
markForReview: (e, i) => {
|
|
275
|
+
o((a) => I(a, e, { markedForReview: i }));
|
|
268
276
|
},
|
|
269
|
-
changeQuestion: (e,
|
|
270
|
-
|
|
277
|
+
changeQuestion: (e, i = !0, a = 0) => {
|
|
278
|
+
o((c) => {
|
|
271
279
|
var r;
|
|
272
280
|
const t = {
|
|
273
|
-
...
|
|
281
|
+
...c,
|
|
274
282
|
summaryVisible: !1
|
|
275
283
|
};
|
|
276
|
-
return
|
|
277
|
-
|
|
278
|
-
},
|
|
284
|
+
return i && c.layout.questionsScrollable ? a > 0 ? b(() => {
|
|
285
|
+
V(e);
|
|
286
|
+
}, a) : requestAnimationFrame(() => V(e)) : c.activeQuestionId !== e && (t.activeQuestionId = e, t.activeQuestionIndex = t.questions.findIndex(
|
|
279
287
|
(l) => l.response_id === e
|
|
280
|
-
), (r = t.onActiveQuestionChange) == null || r.call(
|
|
281
|
-
t,
|
|
282
|
-
t.questions[t.activeQuestionIndex]
|
|
283
|
-
)), t;
|
|
288
|
+
), (r = t.onActiveQuestionChange) == null || r.call(t, t.questions[t.activeQuestionIndex])), t;
|
|
284
289
|
});
|
|
290
|
+
},
|
|
291
|
+
destroy: () => {
|
|
292
|
+
s();
|
|
285
293
|
}
|
|
286
294
|
}))
|
|
287
|
-
)
|
|
288
|
-
|
|
295
|
+
);
|
|
296
|
+
}, O = Q(null);
|
|
289
297
|
export {
|
|
290
298
|
O as WorksheetContext,
|
|
291
299
|
P as createWorksheetStore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worksheet-store.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-store.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { createStore } from 'zustand';\nimport { devtools, subscribeWithSelector } from 'zustand/middleware';\n\nimport {\n getInitialQuestionId,\n getInitialResponses,\n getLastAttemptableQuestionIndex,\n getLastUnlockedQuestionIndex,\n getQuestionMetadata,\n getQuestionsFromItems,\n getWorksheetDimensions,\n scrollToQuestion,\n} from './worksheet-helpers';\nimport type {\n IWorksheetQuestion,\n IWorksheetResponse,\n IWorksheetStore,\n IWorksheetStoreState,\n TWorksheetStoreProps,\n} from './worksheet-types';\n\ninterface IGetDerivedBlocker {\n (options: {\n currentBlocker?: IWorksheetStore['blocker'];\n teacherValidationEnabled: IWorksheetStore['behavior']['teacherValidationEnabled'];\n userType: IWorksheetStore['userType'];\n lastUnlockedQuestion: IWorksheetQuestion;\n lastUnlockedQuestionResponse?: IWorksheetResponse;\n }): IWorksheetStore['blocker'] | undefined;\n}\n\nconst getDerivedBlocker: IGetDerivedBlocker = ({\n teacherValidationEnabled,\n userType,\n lastUnlockedQuestion,\n lastUnlockedQuestionResponse,\n}) => {\n if (teacherValidationEnabled) {\n const { item_type, instructor_stimulus, is_optional } = lastUnlockedQuestion;\n\n if (userType === 'TEACHER') {\n if (item_type === 'exit-ticket' && instructor_stimulus !== 'SystemIntro') {\n if (\n lastUnlockedQuestionResponse?.submittedByStudent &&\n !lastUnlockedQuestionResponse?.validatedByTeacher\n ) {\n return 'exit-ticket-review-available';\n }\n\n if (!lastUnlockedQuestionResponse?.validatedByTeacher) {\n return 'exit-ticket-teacher-intervention';\n }\n\n return undefined;\n }\n\n if (is_optional) {\n if (!lastUnlockedQuestionResponse?.assignStatus) {\n return 'optional-items-assignment';\n }\n\n return undefined;\n }\n }\n }\n\n return undefined;\n};\n\ninterface IGetRenderableQuestions {\n (\n options: Pick<\n IWorksheetStore,\n 'questions' | 'responses' | 'behavior' | 'lastUnlockedQuestionIndex' | 'userType'\n >,\n ): IWorksheetStore['questions'];\n}\nconst getRenderableQuestions: IGetRenderableQuestions = ({\n userType,\n questions,\n responses,\n behavior,\n lastUnlockedQuestionIndex,\n}) => {\n return questions.filter((question, index) => {\n const isUnlocked = userType === 'TEACHER' ? true : index <= lastUnlockedQuestionIndex;\n const { response_id: responseId, is_optional } = question;\n const assignStatus = responses[responseId]?.assignStatus;\n\n if (!isUnlocked) return false;\n\n if (behavior.teacherValidationEnabled) {\n if (assignStatus === 'skipped') return false;\n\n if (is_optional && assignStatus !== 'assigned' && userType === 'STUDENT') {\n return false;\n }\n }\n\n return true;\n });\n};\n\ninterface IGetComputedProperties {\n (props: TWorksheetStoreProps, store?: IWorksheetStore): IWorksheetStoreState;\n}\nconst getComputedProperties: IGetComputedProperties = (props, store) => {\n const {\n learnosityItems,\n learnosityResponses,\n updatedResponses,\n layout,\n behavior,\n userType,\n initialResponseId,\n initialItemIndex,\n } = props;\n const { navigationMode, teacherValidationEnabled, initialQuestion } = behavior;\n const questions =\n store?.questions ??\n getQuestionsFromItems(learnosityItems, {\n sectioned:\n teacherValidationEnabled && navigationMode !== 'ADAPTIVE' && navigationMode !== 'CURRENT',\n adaptive: navigationMode === 'ADAPTIVE',\n });\n const responses =\n updatedResponses ?? store?.responses ?? learnosityResponses ?? getInitialResponses(questions);\n const lastUnlockedQuestionIndex = getLastUnlockedQuestionIndex({\n questions,\n responses,\n behavior,\n userType,\n });\n const initialQuestionId =\n store?.initialQuestionId ??\n getInitialQuestionId({\n questions,\n initialQuestion,\n lastUnlockedQuestionIndex,\n lastAttemptableQuestionIndex: getLastAttemptableQuestionIndex({\n questions,\n responses,\n behavior,\n userType,\n }),\n initialResponseId,\n initialItemIndex,\n });\n\n const activeQuestionId = store?.activeQuestionId ?? initialQuestionId;\n const activeQuestionIndex = questions.findIndex(\n question => question.response_id === activeQuestionId,\n );\n\n return {\n questions,\n renderableQuestions: getRenderableQuestions({\n questions,\n responses,\n behavior,\n userType,\n lastUnlockedQuestionIndex,\n }),\n responses,\n lastUnlockedQuestionIndex,\n initialQuestionId,\n activeQuestionId,\n activeQuestionIndex,\n summaryVisible: store ? store.summaryVisible : false,\n calculatorVisible: store ? store.calculatorVisible : false,\n scribblingEnabled: store ? store.scribblingEnabled : false,\n blocker: getDerivedBlocker({\n currentBlocker: store?.blocker,\n teacherValidationEnabled: behavior.teacherValidationEnabled,\n userType,\n lastUnlockedQuestion: questions[lastUnlockedQuestionIndex]!,\n lastUnlockedQuestionResponse:\n responses[questions[lastUnlockedQuestionIndex]?.response_id ?? ''],\n }),\n ...getWorksheetDimensions(learnosityItems, layout),\n };\n};\n\ninterface IGetMergedResponseState {\n (\n state: IWorksheetStore,\n responseId: string,\n newResponse: Partial<IWorksheetResponse>,\n ): IWorksheetStore;\n}\nconst getMergedResponseState: IGetMergedResponseState = (state, responseId, newResponse) => {\n const questionMeta = getQuestionMetadata(state.questions, responseId);\n\n if (!questionMeta) return state;\n\n return {\n ...state,\n responses: {\n ...state.responses,\n [responseId]: {\n ...questionMeta,\n ...state.responses[responseId],\n ...newResponse,\n },\n },\n };\n};\n\n// Store creator function with strict typing\nexport const createWorksheetStore = (initProps: TWorksheetStoreProps) => {\n return createStore<IWorksheetStore>()(\n devtools(\n subscribeWithSelector(set => {\n return {\n // Initialize with exact props passed in\n ...initProps,\n ...getComputedProperties(initProps),\n\n // Actions\n mergeWorksheetProps: (data: TWorksheetStoreProps) => {\n set(state => ({\n ...state,\n ...data,\n ...getComputedProperties(data, state),\n }));\n },\n\n setResponses: responses => {\n set(state => {\n const newState = {\n ...state,\n responses: typeof responses === 'function' ? responses(state.responses) : responses,\n };\n const { questions, responses: newResponses, behavior, userType } = newState;\n const lastUnlockedQuestionIndex = getLastUnlockedQuestionIndex({\n questions,\n responses: newResponses,\n behavior,\n userType,\n });\n\n return {\n ...newState,\n lastUnlockedQuestionIndex,\n renderableQuestions: getRenderableQuestions({\n questions,\n responses: newResponses,\n behavior,\n userType,\n lastUnlockedQuestionIndex,\n }),\n blocker: getDerivedBlocker({\n currentBlocker: state?.blocker,\n teacherValidationEnabled: behavior.teacherValidationEnabled,\n userType,\n lastUnlockedQuestion: questions[lastUnlockedQuestionIndex]!,\n lastUnlockedQuestionResponse:\n newResponses[questions[lastUnlockedQuestionIndex]?.response_id ?? ''],\n }),\n };\n });\n },\n\n updateResponse: ({ responseId, response, score, answerChecked, timeSpent }) => {\n set(state => {\n const isNewAttempt = !!answerChecked;\n const prevResponse = state.responses[responseId];\n\n const newState = getMergedResponseState(state, responseId, {\n response,\n score,\n responseEdited: !isNewAttempt,\n attemptsHistory: isNewAttempt\n ? [...(prevResponse?.attemptsHistory ?? []), { response, score }]\n : prevResponse?.attemptsHistory,\n skipped: !response,\n timeSpent,\n });\n const { questions, responses, behavior, userType } = newState;\n const lastUnlockedQuestionIndex = getLastUnlockedQuestionIndex({\n questions,\n responses,\n behavior,\n userType,\n });\n const newResponse = responses[responseId];\n\n if (newResponse && state.onResponseChange) {\n state.onResponseChange({\n responseId,\n response: newResponse,\n question: questions.find(q => q.response_id === responseId)!,\n isNewAttempt,\n });\n }\n\n return {\n ...newState,\n lastUnlockedQuestionIndex,\n renderableQuestions: getRenderableQuestions({\n questions,\n responses,\n behavior,\n userType,\n lastUnlockedQuestionIndex,\n }),\n blocker: getDerivedBlocker({\n currentBlocker: state?.blocker,\n teacherValidationEnabled: behavior.teacherValidationEnabled,\n userType,\n lastUnlockedQuestion: questions[lastUnlockedQuestionIndex]!,\n lastUnlockedQuestionResponse:\n responses[questions[lastUnlockedQuestionIndex]?.response_id ?? ''],\n }),\n };\n });\n },\n\n updateMediaState: (responseId, mediaType, mediaState) => {\n const key = mediaType === 'SIMULATION' ? 'simState' : undefined;\n\n if (!key) return;\n\n set(state => {\n if (state.onResponseChange) {\n const newState = getMergedResponseState(state, responseId, { [key]: mediaState });\n const response = newState?.responses[responseId];\n\n if (response) {\n state.onResponseChange({\n responseId,\n response,\n isNewAttempt: false,\n question: state.questions.find(q => q.response_id === responseId)!,\n });\n }\n\n return newState;\n }\n\n if (state.onMediaStateChange) {\n state.onMediaStateChange(\n state.questions.find(q => q.response_id === responseId)!,\n mediaType,\n mediaState,\n );\n }\n\n return state;\n });\n },\n\n showSummary: () => {\n set(state => ({\n ...state,\n summaryVisible: true,\n }));\n },\n\n hideSummary: () => {\n set(state => ({\n ...state,\n summaryVisible: false,\n }));\n },\n\n toggleSummary: () => {\n set(state => ({\n ...state,\n summaryVisible: !state.summaryVisible,\n }));\n },\n\n showCalculator: () => {\n set(state => ({\n ...state,\n calculatorVisible: true,\n }));\n },\n\n hideCalculator: () => {\n set(state => ({\n ...state,\n calculatorVisible: false,\n }));\n },\n\n toggleScribble: () => {\n set(state => ({\n ...state,\n scribblingEnabled: !state.scribblingEnabled,\n }));\n },\n\n setBlocker: blocker => {\n set(state => ({\n ...state,\n blocker,\n }));\n },\n\n removeBlocker: () => {\n set(state => {\n if (state.blocker) {\n const lastUnlockedQuestionId =\n state.questions[state.lastUnlockedQuestionIndex]?.response_id;\n\n if (lastUnlockedQuestionId) {\n setTimeout(() => {\n scrollToQuestion(lastUnlockedQuestionId);\n }, 50);\n }\n }\n\n return {\n ...state,\n blocker: undefined,\n };\n });\n },\n\n markForReview: (responseId: string, markedForReview: boolean) => {\n set(state => getMergedResponseState(state, responseId, { markedForReview }));\n },\n\n changeQuestion: (questionId, shouldScroll = true, scrollDelay = 0) => {\n set(state => {\n const newState = {\n ...state,\n summaryVisible: false,\n };\n\n if (shouldScroll && state.layout.questionsScrollable) {\n if (scrollDelay > 0) {\n setTimeout(() => {\n scrollToQuestion(questionId);\n }, scrollDelay);\n } else {\n requestAnimationFrame(() => scrollToQuestion(questionId));\n }\n } else if (state.activeQuestionId !== questionId) {\n newState.activeQuestionId = questionId;\n newState.activeQuestionIndex = newState.questions.findIndex(\n question => question.response_id === questionId,\n );\n\n newState.onActiveQuestionChange?.(\n newState.questions[newState.activeQuestionIndex]!,\n );\n }\n\n return newState;\n });\n },\n };\n }),\n ),\n );\n};\n\n// Create context with store type\nexport const WorksheetContext = createContext<ReturnType<typeof createWorksheetStore> | null>(null);\n"],"names":["getDerivedBlocker","teacherValidationEnabled","userType","lastUnlockedQuestion","lastUnlockedQuestionResponse","item_type","instructor_stimulus","is_optional","getRenderableQuestions","questions","responses","behavior","lastUnlockedQuestionIndex","question","index","isUnlocked","responseId","assignStatus","_a","getComputedProperties","props","store","learnosityItems","learnosityResponses","updatedResponses","layout","initialResponseId","initialItemIndex","navigationMode","initialQuestion","getQuestionsFromItems","getInitialResponses","getLastUnlockedQuestionIndex","initialQuestionId","getInitialQuestionId","getLastAttemptableQuestionIndex","activeQuestionId","activeQuestionIndex","getWorksheetDimensions","getMergedResponseState","state","newResponse","questionMeta","getQuestionMetadata","createWorksheetStore","initProps","createStore","devtools","subscribeWithSelector","set","data","newState","newResponses","response","score","answerChecked","timeSpent","isNewAttempt","prevResponse","q","mediaType","mediaState","key","blocker","lastUnlockedQuestionId","scrollToQuestion","markedForReview","questionId","shouldScroll","scrollDelay","WorksheetContext","createContext"],"mappings":";;;;AAgCA,MAAMA,IAAwC,CAAC;AAAA,EAC7C,0BAAAC;AAAA,EACA,UAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,8BAAAC;AACF,MAAM;AACJ,MAAIH,GAA0B;AAC5B,UAAM,EAAE,WAAAI,GAAW,qBAAAC,GAAqB,aAAAC,EAAA,IAAgBJ;AAExD,QAAID,MAAa,WAAW;AACtB,UAAAG,MAAc,iBAAiBC,MAAwB;AACzD,eACEF,KAAA,QAAAA,EAA8B,sBAC9B,EAACA,KAAA,QAAAA,EAA8B,sBAExB,iCAGJA,KAAA,QAAAA,EAA8B,qBAI5B,SAHE;AAMX,UAAIG;AACE,eAACH,KAAA,QAAAA,EAA8B,eAI5B,SAHE;AAAA,IAKb;AAAA,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ACf,YAAAJ,EAAiBE,CAAU;AAAA,aAC1BE,CAAW,IAEQ,sBAAA,MAAMJ,EAAiBE,CAAU,CAAC,IAEjD3B,EAAM,qBAAqB2B,MACpChB,EAAS,mBAAmBgB,GACnBhB,EAAA,sBAAsBA,EAAS,UAAU;AAAA,YAChD,CAAAtC,MAAYA,EAAS,gBAAgBsD;AAAA,UAAA,IAG9BjD,IAAAiC,EAAA,2BAAA,QAAAjC,EAAA;AAAA,YAAAiC;AAAA,YACPA,EAAS,UAAUA,EAAS,mBAAmB;AAAA,cAI5CA;AAAA,QAAA,CACR;AAAA,MACH;AAAA,IAAA,EAEH;AAAA,EACH;AAAA,GAKSmB,IAAmBC,EAA8D,IAAI;"}
|
|
1
|
+
{"version":3,"file":"worksheet-store.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-store.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { createStore } from 'zustand';\nimport { subscribeWithSelector } from 'zustand/middleware';\n\nimport {\n getInitialQuestionId,\n getInitialResponses,\n getLastAttemptableQuestionIndex,\n getLastUnlockedQuestionIndex,\n getQuestionMetadata,\n getQuestionsFromItems,\n getWorksheetDimensions,\n scrollToQuestion,\n} from './worksheet-helpers';\nimport type {\n IWorksheetQuestion,\n IWorksheetResponse,\n IWorksheetStore,\n IWorksheetStoreState,\n TWorksheetStoreProps,\n} from './worksheet-types';\n\ninterface IGetDerivedBlocker {\n (options: {\n currentBlocker?: IWorksheetStore['blocker'];\n teacherValidationEnabled: IWorksheetStore['behavior']['teacherValidationEnabled'];\n userType: IWorksheetStore['userType'];\n lastUnlockedQuestion: IWorksheetQuestion;\n lastUnlockedQuestionResponse?: IWorksheetResponse;\n }): IWorksheetStore['blocker'] | undefined;\n}\n\nconst getDerivedBlocker: IGetDerivedBlocker = ({\n teacherValidationEnabled,\n userType,\n lastUnlockedQuestion,\n lastUnlockedQuestionResponse,\n}) => {\n if (teacherValidationEnabled) {\n const { item_type, instructor_stimulus, is_optional } = lastUnlockedQuestion;\n\n if (userType === 'TEACHER') {\n if (item_type === 'exit-ticket' && instructor_stimulus !== 'SystemIntro') {\n if (\n lastUnlockedQuestionResponse?.submittedByStudent &&\n !lastUnlockedQuestionResponse?.validatedByTeacher\n ) {\n return 'exit-ticket-review-available';\n }\n\n if (!lastUnlockedQuestionResponse?.validatedByTeacher) {\n return 'exit-ticket-teacher-intervention';\n }\n\n return undefined;\n }\n\n if (is_optional) {\n if (!lastUnlockedQuestionResponse?.assignStatus) {\n return 'optional-items-assignment';\n }\n\n return undefined;\n }\n }\n }\n\n return undefined;\n};\n\ninterface IGetRenderableQuestions {\n (\n options: Pick<\n IWorksheetStore,\n 'questions' | 'responses' | 'behavior' | 'lastUnlockedQuestionIndex' | 'userType'\n >,\n ): IWorksheetStore['questions'];\n}\nconst getRenderableQuestions: IGetRenderableQuestions = ({\n userType,\n questions,\n responses,\n behavior,\n lastUnlockedQuestionIndex,\n}) => {\n return questions.filter((question, index) => {\n const isUnlocked = userType === 'TEACHER' ? true : index <= lastUnlockedQuestionIndex;\n const { response_id: responseId, is_optional } = question;\n const assignStatus = responses[responseId]?.assignStatus;\n\n if (!isUnlocked) return false;\n\n if (behavior.teacherValidationEnabled) {\n if (assignStatus === 'skipped') return false;\n\n if (is_optional && assignStatus !== 'assigned' && userType === 'STUDENT') {\n return false;\n }\n }\n\n return true;\n });\n};\n\ninterface IGetComputedProperties {\n (props: TWorksheetStoreProps, store?: IWorksheetStore): IWorksheetStoreState;\n}\nconst getComputedProperties: IGetComputedProperties = (props, store) => {\n const {\n learnosityItems,\n learnosityResponses,\n updatedResponses,\n layout,\n behavior,\n userType,\n initialResponseId,\n initialItemIndex,\n } = props;\n const { navigationMode, teacherValidationEnabled, initialQuestion } = behavior;\n const questions =\n store?.questions ??\n getQuestionsFromItems(learnosityItems, {\n sectioned:\n teacherValidationEnabled && navigationMode !== 'ADAPTIVE' && navigationMode !== 'CURRENT',\n adaptive: navigationMode === 'ADAPTIVE',\n });\n const responses =\n updatedResponses ?? store?.responses ?? learnosityResponses ?? getInitialResponses(questions);\n const lastUnlockedQuestionIndex = getLastUnlockedQuestionIndex({\n questions,\n responses,\n behavior,\n userType,\n });\n const initialQuestionId =\n store?.initialQuestionId ??\n getInitialQuestionId({\n questions,\n initialQuestion,\n lastUnlockedQuestionIndex,\n lastAttemptableQuestionIndex: getLastAttemptableQuestionIndex({\n questions,\n responses,\n behavior,\n userType,\n }),\n initialResponseId,\n initialItemIndex,\n });\n\n const activeQuestionId = store?.activeQuestionId ?? initialQuestionId;\n const activeQuestionIndex = questions.findIndex(\n question => question.response_id === activeQuestionId,\n );\n\n return {\n questions,\n renderableQuestions: getRenderableQuestions({\n questions,\n responses,\n behavior,\n userType,\n lastUnlockedQuestionIndex,\n }),\n responses,\n lastUnlockedQuestionIndex,\n initialQuestionId,\n activeQuestionId,\n activeQuestionIndex,\n summaryVisible: store ? store.summaryVisible : false,\n calculatorVisible: store ? store.calculatorVisible : false,\n scribblingEnabled: store ? store.scribblingEnabled : false,\n blocker: getDerivedBlocker({\n currentBlocker: store?.blocker,\n teacherValidationEnabled: behavior.teacherValidationEnabled,\n userType,\n lastUnlockedQuestion: questions[lastUnlockedQuestionIndex]!,\n lastUnlockedQuestionResponse:\n responses[questions[lastUnlockedQuestionIndex]?.response_id ?? ''],\n }),\n ...getWorksheetDimensions(learnosityItems, layout),\n };\n};\n\ninterface IGetMergedResponseState {\n (\n state: IWorksheetStore,\n responseId: string,\n newResponse: Partial<IWorksheetResponse>,\n ): IWorksheetStore;\n}\nconst getMergedResponseState: IGetMergedResponseState = (state, responseId, newResponse) => {\n const questionMeta = getQuestionMetadata(state.questions, responseId);\n\n if (!questionMeta) return state;\n\n return {\n ...state,\n responses: {\n ...state.responses,\n [responseId]: {\n ...questionMeta,\n ...state.responses[responseId],\n ...newResponse,\n },\n },\n };\n};\n\n// Store creator function with strict typing\nexport const createWorksheetStore = (initProps: TWorksheetStoreProps) => {\n // Register store instance for memory leak monitoring\n\n // Track active timeouts to enable cleanup\n const activeTimeouts = new Set<NodeJS.Timeout>();\n\n const createManagedTimeout = (callback: () => void, delay: number): NodeJS.Timeout => {\n const timeoutId = setTimeout(() => {\n activeTimeouts.delete(timeoutId);\n callback();\n }, delay);\n\n activeTimeouts.add(timeoutId);\n\n return timeoutId;\n };\n\n const clearAllTimeouts = () => {\n activeTimeouts.forEach(timeoutId => clearTimeout(timeoutId));\n activeTimeouts.clear();\n };\n\n return createStore<IWorksheetStore>()(\n subscribeWithSelector(set => {\n return {\n // Initialize with exact props passed in\n ...initProps,\n ...getComputedProperties(initProps),\n\n // Actions\n mergeWorksheetProps: (data: TWorksheetStoreProps) => {\n set(state => ({\n ...state,\n ...data,\n ...getComputedProperties(data, state),\n }));\n },\n\n setResponses: responses => {\n set(state => {\n const newState = {\n ...state,\n responses: typeof responses === 'function' ? responses(state.responses) : responses,\n };\n const { questions, responses: newResponses, behavior, userType } = newState;\n const lastUnlockedQuestionIndex = getLastUnlockedQuestionIndex({\n questions,\n responses: newResponses,\n behavior,\n userType,\n });\n\n return {\n ...newState,\n lastUnlockedQuestionIndex,\n renderableQuestions: getRenderableQuestions({\n questions,\n responses: newResponses,\n behavior,\n userType,\n lastUnlockedQuestionIndex,\n }),\n blocker: getDerivedBlocker({\n currentBlocker: state?.blocker,\n teacherValidationEnabled: behavior.teacherValidationEnabled,\n userType,\n lastUnlockedQuestion: questions[lastUnlockedQuestionIndex]!,\n lastUnlockedQuestionResponse:\n newResponses[questions[lastUnlockedQuestionIndex]?.response_id ?? ''],\n }),\n };\n });\n },\n\n updateResponse: ({ responseId, response, score, answerChecked, timeSpent }) => {\n set(state => {\n const isNewAttempt = !!answerChecked;\n const prevResponse = state.responses[responseId];\n\n const newState = getMergedResponseState(state, responseId, {\n response,\n score,\n responseEdited: !isNewAttempt,\n attemptsHistory: isNewAttempt\n ? [...(prevResponse?.attemptsHistory ?? []), { response, score }]\n : prevResponse?.attemptsHistory,\n skipped: !response,\n timeSpent,\n });\n const { questions, responses, behavior, userType } = newState;\n const lastUnlockedQuestionIndex = getLastUnlockedQuestionIndex({\n questions,\n responses,\n behavior,\n userType,\n });\n const newResponse = responses[responseId];\n\n if (newResponse && state.onResponseChange) {\n state.onResponseChange({\n responseId,\n response: newResponse,\n question: questions.find(q => q.response_id === responseId)!,\n isNewAttempt,\n });\n }\n\n return {\n ...newState,\n lastUnlockedQuestionIndex,\n renderableQuestions: getRenderableQuestions({\n questions,\n responses,\n behavior,\n userType,\n lastUnlockedQuestionIndex,\n }),\n blocker: getDerivedBlocker({\n currentBlocker: state?.blocker,\n teacherValidationEnabled: behavior.teacherValidationEnabled,\n userType,\n lastUnlockedQuestion: questions[lastUnlockedQuestionIndex]!,\n lastUnlockedQuestionResponse:\n responses[questions[lastUnlockedQuestionIndex]?.response_id ?? ''],\n }),\n };\n });\n },\n\n updateMediaState: (responseId, mediaType, mediaState) => {\n const key = mediaType === 'SIMULATION' ? 'simState' : undefined;\n\n if (!key) return;\n\n set(state => {\n if (state.onResponseChange) {\n const newState = getMergedResponseState(state, responseId, { [key]: mediaState });\n const response = newState?.responses[responseId];\n\n if (response) {\n state.onResponseChange({\n responseId,\n response,\n isNewAttempt: false,\n question: state.questions.find(q => q.response_id === responseId)!,\n });\n }\n\n return newState;\n }\n\n if (state.onMediaStateChange) {\n state.onMediaStateChange(\n state.questions.find(q => q.response_id === responseId)!,\n mediaType,\n mediaState,\n );\n }\n\n return state;\n });\n },\n\n showSummary: () => {\n set(state => ({\n ...state,\n summaryVisible: true,\n }));\n },\n\n hideSummary: () => {\n set(state => ({\n ...state,\n summaryVisible: false,\n }));\n },\n\n toggleSummary: () => {\n set(state => ({\n ...state,\n summaryVisible: !state.summaryVisible,\n }));\n },\n\n showCalculator: () => {\n set(state => ({\n ...state,\n calculatorVisible: true,\n }));\n },\n\n hideCalculator: () => {\n set(state => ({\n ...state,\n calculatorVisible: false,\n }));\n },\n\n toggleScribble: () => {\n set(state => ({\n ...state,\n scribblingEnabled: !state.scribblingEnabled,\n }));\n },\n\n setBlocker: blocker => {\n set(state => ({\n ...state,\n blocker,\n }));\n },\n\n removeBlocker: () => {\n set(state => {\n if (state.blocker) {\n const lastUnlockedQuestionId =\n state.questions[state.lastUnlockedQuestionIndex]?.response_id;\n\n if (lastUnlockedQuestionId) {\n createManagedTimeout(() => {\n scrollToQuestion(lastUnlockedQuestionId);\n }, 50);\n }\n }\n\n return {\n ...state,\n blocker: undefined,\n };\n });\n },\n\n markForReview: (responseId: string, markedForReview: boolean) => {\n set(state => getMergedResponseState(state, responseId, { markedForReview }));\n },\n\n changeQuestion: (questionId, shouldScroll = true, scrollDelay = 0) => {\n set(state => {\n const newState = {\n ...state,\n summaryVisible: false,\n };\n\n if (shouldScroll && state.layout.questionsScrollable) {\n if (scrollDelay > 0) {\n createManagedTimeout(() => {\n scrollToQuestion(questionId);\n }, scrollDelay);\n } else {\n requestAnimationFrame(() => scrollToQuestion(questionId));\n }\n } else if (state.activeQuestionId !== questionId) {\n newState.activeQuestionId = questionId;\n newState.activeQuestionIndex = newState.questions.findIndex(\n question => question.response_id === questionId,\n );\n\n newState.onActiveQuestionChange?.(newState.questions[newState.activeQuestionIndex]!);\n }\n\n return newState;\n });\n },\n\n destroy: () => {\n clearAllTimeouts();\n },\n };\n }),\n );\n};\n\n// Create context with store type\nexport const WorksheetContext = createContext<ReturnType<typeof createWorksheetStore> | null>(null);\n"],"names":["getDerivedBlocker","teacherValidationEnabled","userType","lastUnlockedQuestion","lastUnlockedQuestionResponse","item_type","instructor_stimulus","is_optional","getRenderableQuestions","questions","responses","behavior","lastUnlockedQuestionIndex","question","index","isUnlocked","responseId","assignStatus","_a","getComputedProperties","props","store","learnosityItems","learnosityResponses","updatedResponses","layout","initialResponseId","initialItemIndex","navigationMode","initialQuestion","getQuestionsFromItems","getInitialResponses","getLastUnlockedQuestionIndex","initialQuestionId","getInitialQuestionId","getLastAttemptableQuestionIndex","activeQuestionId","activeQuestionIndex","getWorksheetDimensions","getMergedResponseState","state","newResponse","questionMeta","getQuestionMetadata","createWorksheetStore","initProps","activeTimeouts","createManagedTimeout","callback","delay","timeoutId","clearAllTimeouts","createStore","subscribeWithSelector","set","data","newState","newResponses","response","score","answerChecked","timeSpent","isNewAttempt","prevResponse","q","mediaType","mediaState","key","blocker","lastUnlockedQuestionId","scrollToQuestion","markedForReview","questionId","shouldScroll","scrollDelay","WorksheetContext","createContext"],"mappings":";;;;AAgCA,MAAMA,IAAwC,CAAC;AAAA,EAC7C,0BAAAC;AAAA,EACA,UAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,8BAAAC;AACF,MAAM;AACJ,MAAIH,GAA0B;AAC5B,UAAM,EAAE,WAAAI,GAAW,qBAAAC,GAAqB,aAAAC,EAAA,IAAgBJ;AAExD,QAAID,MAAa,WAAW;AACtB,UAAAG,MAAc,iBAAiBC,MAAwB;AACzD,eACEF,KAAA,QAAAA,EAA8B,sBAC9B,EAACA,KAAA,QAAAA,EAA8B,sBAExB,iCAGJA,KAAA,QAAAA,EAA8B,qBAI5B,SAHE;AAMX,UAAIG;AACE,eAACH,KAAA,QAAAA,EAA8B,eAI5B,SAHE;AAAA,IAKb;AAAA,EACF;AAGF,GAUMI,IAAkD,CAAC;AAAA,EACvD,UAAAN;AAAA,EACA,WAAAO;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,2BAAAC;AACF,MACSH,EAAU,OAAO,CAACI,GAAUC,MAAU;;AAC3C,QAAMC,IAAab,MAAa,YAAY,KAAOY,KAASF,GACtD,EAAE,aAAaI,GAAY,aAAAT,EAAA,IAAgBM,GAC3CI,KAAeC,IAAAR,EAAUM,CAAU,MAApB,gBAAAE,EAAuB;AAI5C,SAFI,GAACH,KAEDJ,EAAS,6BACPM,MAAiB,aAEjBV,KAAeU,MAAiB,cAAcf,MAAa;AAK1D,CACR,GAMGiB,IAAgD,CAACC,GAAOC,MAAU;;AAChE,QAAA;AAAA,IACJ,iBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA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AS,gBAAgB2D;AAAA,UAAA,IAGvCtD,IAAAsC,EAAS,2BAAT,QAAAtC,EAAA,KAAAsC,GAAkCA,EAAS,UAAUA,EAAS,mBAAmB,KAG5EA;AAAA,QAAA,CACR;AAAA,MACH;AAAA,MAEA,SAAS,MAAM;AACI,QAAAL;MACnB;AAAA,IAAA,EAEH;AAAA,EAAA;AAEL,GAGawB,IAAmBC,EAA8D,IAAI;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worksheet-types.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-types.ts"],"sourcesContent":["import type { MutableRefObject, ReactElement, ReactNode } from 'react';\n\nimport type { TNodeTypes } from '../../../types/models/worksheet';\nimport type { IActionData, TPublish, TSubscribe } from '../../cue-canvas/types/cue-canvas';\nimport type { TPublishMouseMove, TSubscribeMouseMove } from '../../pointer-sync/pointer-types';\nimport type { TColorNames, THueNames, TUserTypes } from '../../ui/types';\nimport type { IFile } from './worksheet-question/subjective-review';\nimport type { TWorksheetBlocker } from './worksheet-blocker/worksheet-blocker-types';\n\nexport enum QUESTION_TAGS {\n TRIAL_TOPIC = 'trial-topic',\n QUESTION_CODE = 'question code',\n}\n\nexport enum QUESTIONS_RATING {\n E = 3,\n S = 2, // Just right\n H = 1,\n}\n\nexport interface ILearnosityError {\n code: number;\n consumerKey: string;\n detail: string;\n errorUI: string;\n msg: string;\n}\n\ninterface ILearnosityQuestionMetadata {\n widget_reference: string;\n sheet_reference: string;\n hints?: string[];\n solution?: string[];\n teacher_tips?: string[];\n valid_response_count: number;\n source: {\n organisation_id: number;\n };\n}\n\nexport type TInstructorStimulus =\n | 'SystemIntro' // lesson v3\n | 'Intro' // lesson v3\n | 'Concept-Intro' // lesson v3\n | 'Instruction' // lesson v3\n | 'Task' // lesson v3\n | 'Try' // trial v3\n | 'Learn' // trial v3\n | 'Apply'; // trial v3\nexport type TItemType =\n | 'overview'\n | 'learning-we-do'\n | 'learning-your-turn'\n | 'learning-explore'\n | 'practice-basic'\n | 'practice-basic-optional'\n | 'practice-regular'\n | 'practice-regular-optional'\n | 'exit-ticket'\n | 'advanced-we-do'\n | 'advanced-your-turn'\n | 'advanced-explore'\n | 'advanced-practice';\n\nexport type TSectionName =\n | 'overview'\n | 'learning'\n | 'practice-basic'\n | 'practice-regular'\n | 'exit-ticket'\n | 'advanced';\n\nexport interface IQuestionValidResponse {\n score: number;\n value: unknown[];\n}\n\nexport interface ISheetNudgeBannerInfo {\n bannerBackgroundColor: TColorNames;\n label: string;\n}\n\nexport interface ILearnosityQuestion {\n response_id: string;\n instructor_stimulus?: TInstructorStimulus;\n metadata: ILearnosityQuestionMetadata;\n instant_feedback?: boolean;\n math_renderer?: string;\n template?: string;\n tokenization?: string;\n numberPad?: string[];\n symbols?: unknown[];\n response_container?: Record<string, unknown>;\n ui_style?: Record<string, unknown>;\n shuffle_options?: boolean;\n // for custom type question validation is undefined.\n validation?: {\n scoring_type?: string;\n unscored?: boolean;\n valid_response?: IQuestionValidResponse;\n alt_responses?: IQuestionValidResponse[];\n penalty?: number;\n min_score_if_attempted?: number;\n };\n is_math?: boolean;\n labels?: Record<string, unknown>;\n line?: Record<string, unknown>;\n points?: string[];\n snap_to_ticks?: boolean;\n ticks?: Record<string, unknown>;\n max_length?: number;\n type:\n | 'hotspot'\n | 'tokenhighlight'\n | 'numberline'\n | 'clozeassociation'\n | 'clozetext'\n | 'association'\n | 'classification'\n | 'clozedropdown'\n | 'clozeformula'\n | 'mcq'\n | 'choicematrix'\n | 'plaintext'\n | 'drawing';\n case_sensitive?: boolean;\n show_copy?: boolean;\n show_cut?: boolean;\n show_paste?: boolean;\n spellcheck?: boolean;\n stimulus?: string;\n stimulus_review?: string;\n stimulus_list?: string[];\n image?: Record<string, unknown>;\n areas?: unknown[];\n area_attributes?: Record<string, unknown>;\n possible_responses?: string[][] | string[];\n duplicate_responses?: boolean;\n response_containers?: unknown[];\n options?: Record<string, unknown>[] | string[];\n feedback_attempts?: number;\n stems?: string[];\n multiple_responses?: boolean;\n}\n\nexport interface ILearnosityItem {\n reference: string;\n questions: ILearnosityQuestion[];\n source: Record<string, unknown>;\n content: string;\n metadata: Record<string, unknown> | unknown[];\n workflow: unknown[];\n response_ids: string[];\n feature_ids: unknown[];\n features: unknown[];\n itemType?: TItemType;\n tags?: string[];\n}\n\nexport interface IWorksheetQuestion extends ILearnosityQuestion {\n item_reference: string;\n item_type?: TItemType;\n section_name?: TSectionName;\n is_optional?: boolean;\n item_tags: string[];\n item_tags_map: Record<string, string>;\n item_number: number;\n item_display_number: number;\n question_number: number;\n total_questions: number;\n}\n\nexport interface ILearnosityQuestionScore {\n score?: number | null;\n max_score: number;\n unscored?: boolean;\n}\n\nexport interface ILearnosityQuestionResponse {\n value: unknown;\n responses?: unknown;\n type: unknown;\n updatedFormat?: boolean;\n wordCount?: number;\n apiVersion: string;\n revision: number;\n feedbackAttemptsCount?: number;\n}\n\nexport interface IAttempt {\n response: ILearnosityQuestionResponse;\n score: ILearnosityQuestionScore;\n}\n\ninterface ITeacherReview {\n reviewComment?: string;\n images?: string[];\n}\nexport interface IWorksheetResponse {\n widgetReference: string;\n itemReference: string;\n itemPosition: number; // 0 based\n questionPosition: number; // 0 based\n isOkayTypeQuestion: boolean;\n response?: ILearnosityQuestionResponse;\n simState?: Record<string, unknown>;\n score?: ILearnosityQuestionScore;\n responseEdited?: boolean;\n hintsUsed?: number;\n markedForReview?: boolean;\n attemptsHistory?: IAttempt[];\n validatedByTeacher?: boolean;\n submittedByStudent?: boolean;\n assignStatus?: 'assigned' | 'skipped';\n rating?: number;\n skipped?: boolean;\n doubtResolved?: boolean;\n teacherReview?: ITeacherReview;\n tags?: Record<string, string>;\n timeSpent?: number;\n}\n\ntype TMathRenderer = 'mathjax' | 'mathquill';\nexport interface ILearnosity {\n ready: () => void;\n questions: () => Record<string, unknown>;\n question: (responseId: string) =>\n | {\n enable: () => boolean;\n disable: () => boolean;\n getQuestion: () => ILearnosityQuestion;\n getMetadata: () => ILearnosityQuestionMetadata;\n getResponse: () => ILearnosityQuestionResponse;\n getScore: (\n callback?: (score: ILearnosityQuestionScore | null) => void,\n ) => ILearnosityQuestionScore;\n validate: (\n options?: { showCorrectAnswers?: boolean; feedbackAttempts?: boolean },\n callback?: () => void,\n ) => void;\n resetValidationUI: () => void;\n on: (eventName: 'changed', callback: () => void) => void;\n off: (eventName: 'changed', callback?: () => void) => void;\n }\n | undefined;\n append: (toAppend: {\n questions: ILearnosityQuestion[];\n responses?: Record<string, unknown>;\n }) => void;\n appendQuestion: (toAppend: {\n questions: ILearnosityQuestion[];\n responses?: Record<string, unknown>;\n }) => void;\n reset: () => void;\n renderMath: (renderer: TMathRenderer) => void;\n}\n\nexport interface IWorksheetBehavior {\n /**\n * If true, Opens the worksheet in resume mode.\n * - If false, Opens the worksheet in review mode.\n */\n canAttempt: boolean;\n /**\n * If true, the user can mark the question for review.\n */\n canMarkForReview: boolean;\n /**\n * The mode of navigation for the worksheet.\n * - `OPEN` mode allows the user to navigate to any question in the worksheet.\n * - `LINEAR` mode allows the user to navigate to the next question only.\n * - `ADAPTIVE` mode allows the user to navigate future questions based on the rating of the current question.\n * - `CURRENT` mode allows the user to navigate to the current question only. Back and forth not allowed.\n */\n navigationMode: 'OPEN' | 'LINEAR' | 'ADAPTIVE' | 'CURRENT';\n /**\n * The initial question to display when the worksheet is loaded.\n * - `FIRST` mode displays the first question in the worksheet.\n * - `CURRENT` mode displays the question that the user was last on.\n */\n initialQuestion: 'FIRST' | 'CURRENT';\n /**\n * If hints are available, on clicking the help button, first availble hint will be shown.\n * Clicking again will show the next hint.\n * If no more hints are available, onHelp will be called.\n */\n hints: boolean;\n /**\n * The time in seconds after which the hints button will be shown.\n */\n hintsTimer?: number; // in seconds\n /**\n * If true, the user can skip the question without attempting it.\n * Skip button will be shown only after the hints are exausted and skipTimer is reached.\n */\n skippable?: boolean;\n /**\n * The time in seconds after which the user can skip the question.\n */\n skippableTime?: number; // in seconds\n /**\n * If true, teacher validation is needed for the question to proceed\n */\n teacherValidationEnabled: boolean;\n /**\n * If worksheet is attempting outside the class setting\n * This needs teacherValidationEnabled to be true\n * TODO: Consider changing to accept validation type: 'system' | 'teacher' | undefined instead of boolean\n */\n canTeacherValidate: boolean;\n /**\n * If true, questions will be validated and feedback will be shown.\n */\n validation: boolean;\n /**\n * If true, solution wont be shown to the user.\n */\n solutionHidden?: boolean;\n /**\n * If true, questions will be validated and feedback will be shown along with the correct answer.\n */\n review: boolean;\n /**\n * The maximum number of attempts allowed for each question.\n * 0 means unlimited attempts.\n * -1 means attempts will not be validated, hence not pushed to attempt history.\n * -2 means the sheet is a puzzle sheet\n * After reaching the maximum number of attempts, the user cannot attempt the question anymore.\n * If maxAtttmpts reached and canExceedAttempts is true, the user can still attempt the question\n * , also user will have the option to move to next question\n */\n maximumAttempts: number;\n /**\n * If true, the user can exceed the maximum number of attempts.\n */\n canExceedAttempts: boolean;\n /**\n * If the worksheet minimumAccuracy is not met, on clicking the final submit button, onMinimumAccuracyNotMet will be called.\n */\n minimumAccuracy: number;\n /**\n * Label for the check button\n * For example,\n * - \"Check\" for Checking the answer\n * - \"Submit\" for Submitting the answer when doing assessment\n */\n checkButtonLabel: string;\n /**\n * If attempt is incorrect, we show retry button, this is the label for the retry button\n * For example,\n * - 'Try Again' for retrying the question\n */\n retryButtonLabel: string;\n /**\n * If true show demos calculator https://www.desmos.com/calculator\n */\n canShowDesmosCalc: boolean;\n\n // If true, canvas is enabled and user can use canvas to scribble on the worksheet by toggling the scribble button\n canvasEnabled?: boolean;\n\n // If true, the user can scribble on workheet\n canScribble?: boolean;\n}\n\nexport type TWORKSHHET_QUESTION_MEDIA_TYPE = 'SIMULATION' | 'VIDEO' | 'AUDIO';\n\nexport interface IWorksheetCallbackProps {\n onResponseChange?: (options: {\n responseId: string;\n response: IWorksheetResponse;\n isNewAttempt: boolean;\n question: IWorksheetQuestion;\n }) => void;\n onBulkResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;\n onResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;\n onMediaStateChange?: (\n question: IWorksheetQuestion,\n mediaType: TWORKSHHET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n onTeacherValidation?: (questionId: string, rating?: keyof typeof QUESTIONS_RATING) => void;\n onOptionalItemAssignment?: (itemType: TItemType) => void;\n onOptionalItemSkip?: (itemType: TItemType) => void;\n onHelp?: (options: { questionId: string; questionNumber: string }) => void;\n onMinimumAccuracyNotMet?: (accuracy: number) => void;\n onExitTicketStart?: () => void;\n onExitTicketSubmit?: () => void;\n onSubmit?: (responses: Record<string, IWorksheetResponse>) => void;\n onActiveQuestionChange?: (question: IWorksheetQuestion) => void;\n onResolveDoubt?: (responseId: string) => void;\n onSkip?: (itemIndex: number, widgetIndex: number) => void;\n onLoaded: () => void;\n onErrored: (error: { code?: number; message: string }) => void;\n onResponsesLoaded?: (responses: Record<string, IWorksheetResponse>) => void;\n openQuestionFeedbackModal?: (itemRef: string) => void;\n}\n\nexport interface ICueCanvasCallbackProps {\n onPublishStrokes?: TPublish;\n onReceiveStrokes?: TSubscribe;\n}\n\nexport interface ICueCanvasProps {\n initialStrokesData?: Record<string, IActionData[]>;\n}\n\nexport interface IPointerSyncCallbackProps {\n onPublishMouseMove?: TPublishMouseMove;\n onSubscribeMouseMove?: TSubscribeMouseMove;\n}\n\nexport interface IWorksheetLayout {\n containerStyle: 'none' | 'card';\n navigationBar: 'none' | 'top' | 'bottom';\n actionBar: 'none' | 'bottom';\n containerWidth: string;\n topOffset: number; // Offset from the top of the screen, for eg: height of the header\n questionsScrollable: boolean;\n minQuestionHeight: string | number;\n minSummaryHeight: string | number;\n renderSideBar: boolean;\n showUserPointer?: boolean;\n renderQuestionHeader?: boolean;\n imageHue?: THueNames;\n background?: 'none' | 'paper';\n questionPadding: number;\n}\n\nexport interface ISubjectiveSheetProps {\n onAddReviewComment?: (\n responseId: string,\n commentData: {\n score: ILearnosityQuestionScore;\n teacherReview: ITeacherReview;\n },\n ) => void;\n openImagesReviewModal?: (props: IOpenImageReviewModalProps) => void;\n handleReviewSubmit?: () => void;\n isSubmittingReview?: boolean;\n isReviewPending?: boolean;\n}\n\ninterface IBaseWorksheetProps {\n userType: TUserTypes;\n userId: string;\n studentId: string;\n studentName?: string;\n worksheetName: string;\n initialResponseId?: string;\n initialItemIndex?: number;\n layout: IWorksheetLayout;\n updatedResponses?: Record<string, IWorksheetResponse>;\n worksheetCompleted: boolean;\n showNudgeBanner?: boolean;\n markedAsCompleted?: boolean;\n canResolveDoubt?: boolean;\n canShowActionBar?: boolean;\n actionBarRightElement?: ReactElement; // Extra Elements to be rendered in the action bar\n attemptId?: string;\n itemsSignedRequest: string;\n questionsSignedRequest: string;\n summaryDescription?: ReactElement | null;\n canSubmitWorksheet?: boolean;\n subjectiveProps?: ISubjectiveSheetProps;\n inClass?: boolean; // If true, the worksheet is rendered inside class\n isLessonV3Enabled?: boolean; // If true, the worksheet is rendered in lesson v3 mode\n isDesmosEnabled?: boolean; // If true, the worksheet can show desmos calculator\n nodeType: TNodeTypes; // NodeType of the worksheet\n mode: 'resume' | 'review' | 'preview'; // mode of the worksheet\n loggerRef: MutableRefObject<(eventName: string, data?: Record<string, unknown>) => void>;\n}\n\ninterface IWorksheetPlugins {\n plugins?: {\n stickers?: ReactNode;\n };\n}\n\nexport interface IUpdateImages {\n filteredImages: string[];\n newImages: IFile[];\n}\nexport interface IOpenImageReviewModalProps {\n isReviewed?: boolean;\n disableScoreForm?: boolean;\n imageUrls?: string[];\n filteredImageUrls?: (props: IUpdateImages) => void;\n uploadedImages?: (IFile | string)[];\n image?: string;\n}\n\nexport interface IWorksheetProps\n extends IBaseWorksheetProps,\n IWorksheetCallbackProps,\n ICueCanvasProps,\n ICueCanvasCallbackProps,\n IPointerSyncCallbackProps,\n IWorksheetPlugins {}\n\nexport interface IWorksheetRef {\n validateQuestion: (\n responseId: string,\n rating?: keyof typeof QUESTIONS_RATING,\n skipRemainingQuestions?: boolean,\n ) => void;\n assignOptionalItems: (itemType: TItemType) => void;\n skipOptionalItems: (itemType: TItemType) => void;\n updateMediaState: (\n responseId: string,\n mediaType: TWORKSHHET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n}\n\ninterface IWorksheetHeaderLayoutArgs {\n isPuzzleWorksheet?: boolean;\n isTestWorksheet?: boolean;\n imageHue?: THueNames;\n}\n\nexport interface IWorksheetHeaderLayoutProps {\n (args: IWorksheetHeaderLayoutArgs): {\n bgColor: TColorNames;\n borderColor?: TColorNames;\n textColor?: TColorNames;\n };\n}\n\nexport type TWorksheetStoreProps = Omit<\n IBaseWorksheetProps,\n 'studentName' | 'canShowActionBar' | 'itemsSignedRequest' | 'nodeType' | 'mode'\n> &\n Required<Pick<IBaseWorksheetProps, 'studentName' | 'canShowActionBar'>> &\n Omit<IWorksheetCallbackProps, 'onLoaded' | 'onErrored'> &\n ICueCanvasProps &\n ICueCanvasCallbackProps &\n IPointerSyncCallbackProps &\n IWorksheetPlugins & {\n behavior: IWorksheetBehavior;\n learnosityItems: ILearnosityItem[];\n learnosityResponses?: Record<string, IWorksheetResponse>;\n learnosity: ILearnosity;\n appendedQuestionIds: string[];\n };\n\nexport interface IWorksheetStoreState {\n questions: IWorksheetQuestion[];\n renderableQuestions: IWorksheetQuestion[];\n responses: Record<string, IWorksheetResponse>;\n lastUnlockedQuestionIndex: number;\n initialQuestionId: string;\n activeQuestionId: string;\n activeQuestionIndex: number;\n questionsContainerWidth: number;\n maxQuestionWidth: number;\n actionbarHeight: number;\n summaryVisible: boolean;\n calculatorVisible: boolean;\n scribblingEnabled: boolean;\n blocker?: TWorksheetBlocker;\n}\n\n// Actions interface - contains all the methods\ninterface IWorksheetStoreActions {\n mergeWorksheetProps: (data: TWorksheetStoreProps) => void;\n setResponses: (\n responses:\n | IWorksheetStore['responses']\n | ((prevResponses: IWorksheetStore['responses']) => IWorksheetStore['responses']),\n ) => void;\n showSummary: () => void;\n hideSummary: () => void;\n toggleSummary: () => void;\n showCalculator: () => void;\n hideCalculator: () => void;\n toggleScribble: () => void;\n setBlocker: (blocker?: TWorksheetBlocker) => void;\n removeBlocker: () => void;\n updateResponse: (options: {\n responseId: string;\n response: ILearnosityQuestionResponse;\n score: ILearnosityQuestionScore;\n timeSpent: number;\n answerChecked?: boolean;\n }) => void;\n updateMediaState: (\n responseId: string,\n mediaType: TWORKSHHET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n markForReview: (responseId: string, markedForReview: boolean) => void;\n changeQuestion: (questionId: string, shouldScroll?: boolean, scrollDelay?: number) => void;\n}\n\n// Combined store interface\nexport interface IWorksheetStore\n extends IWorksheetStoreState,\n TWorksheetStoreProps,\n IWorksheetStoreActions {}\n"],"names":["QUESTION_TAGS","QUESTIONS_RATING"],"mappings":"AASY,IAAAA,sBAAAA,OACVA,EAAA,cAAc,eACdA,EAAA,gBAAgB,iBAFNA,IAAAA,KAAA,CAAA,CAAA,GAKAC,sBAAAA,OACVA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KACAA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KACAA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KAHUA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"worksheet-types.js","sources":["../../../../src/features/worksheet/worksheet/worksheet-types.ts"],"sourcesContent":["import type { MutableRefObject, ReactElement, ReactNode } from 'react';\n\nimport type { TNodeTypes } from '../../../types/models/worksheet';\nimport type { IActionData, TPublish, TSubscribe } from '../../cue-canvas/types/cue-canvas';\nimport type { TPublishMouseMove, TSubscribeMouseMove } from '../../pointer-sync/pointer-types';\nimport type { TColorNames, THueNames, TUserTypes } from '../../ui/types';\nimport type { IFile } from './worksheet-question/subjective-review';\nimport type { TWorksheetBlocker } from './worksheet-blocker/worksheet-blocker-types';\n\nexport enum QUESTION_TAGS {\n TRIAL_TOPIC = 'trial-topic',\n QUESTION_CODE = 'question code',\n}\n\nexport enum QUESTIONS_RATING {\n E = 3,\n S = 2, // Just right\n H = 1,\n}\n\nexport interface ILearnosityError {\n code: number;\n consumerKey: string;\n detail: string;\n errorUI: string;\n msg: string;\n}\n\ninterface ILearnosityQuestionMetadata {\n widget_reference: string;\n sheet_reference: string;\n hints?: string[];\n solution?: string[];\n teacher_tips?: string[];\n valid_response_count: number;\n source: {\n organisation_id: number;\n };\n}\n\nexport type TInstructorStimulus =\n | 'SystemIntro' // lesson v3\n | 'Intro' // lesson v3\n | 'Concept-Intro' // lesson v3\n | 'Instruction' // lesson v3\n | 'Task' // lesson v3\n | 'Try' // trial v3\n | 'Learn' // trial v3\n | 'Apply'; // trial v3\nexport type TItemType =\n | 'overview'\n | 'learning-we-do'\n | 'learning-your-turn'\n | 'learning-explore'\n | 'practice-basic'\n | 'practice-basic-optional'\n | 'practice-regular'\n | 'practice-regular-optional'\n | 'exit-ticket'\n | 'advanced-we-do'\n | 'advanced-your-turn'\n | 'advanced-explore'\n | 'advanced-practice';\n\nexport type TSectionName =\n | 'overview'\n | 'learning'\n | 'practice-basic'\n | 'practice-regular'\n | 'exit-ticket'\n | 'advanced';\n\nexport interface IQuestionValidResponse {\n score: number;\n value: unknown[];\n}\n\nexport interface ISheetNudgeBannerInfo {\n bannerBackgroundColor: TColorNames;\n label: string;\n}\n\nexport interface ILearnosityQuestion {\n response_id: string;\n instructor_stimulus?: TInstructorStimulus;\n metadata: ILearnosityQuestionMetadata;\n instant_feedback?: boolean;\n math_renderer?: string;\n template?: string;\n tokenization?: string;\n numberPad?: string[];\n symbols?: unknown[];\n response_container?: Record<string, unknown>;\n ui_style?: Record<string, unknown>;\n shuffle_options?: boolean;\n // for custom type question validation is undefined.\n validation?: {\n scoring_type?: string;\n unscored?: boolean;\n valid_response?: IQuestionValidResponse;\n alt_responses?: IQuestionValidResponse[];\n penalty?: number;\n min_score_if_attempted?: number;\n };\n is_math?: boolean;\n labels?: Record<string, unknown>;\n line?: Record<string, unknown>;\n points?: string[];\n snap_to_ticks?: boolean;\n ticks?: Record<string, unknown>;\n max_length?: number;\n type:\n | 'hotspot'\n | 'tokenhighlight'\n | 'numberline'\n | 'clozeassociation'\n | 'clozetext'\n | 'association'\n | 'classification'\n | 'clozedropdown'\n | 'clozeformula'\n | 'mcq'\n | 'choicematrix'\n | 'plaintext'\n | 'drawing';\n case_sensitive?: boolean;\n show_copy?: boolean;\n show_cut?: boolean;\n show_paste?: boolean;\n spellcheck?: boolean;\n stimulus?: string;\n stimulus_review?: string;\n stimulus_list?: string[];\n image?: Record<string, unknown>;\n areas?: unknown[];\n area_attributes?: Record<string, unknown>;\n possible_responses?: string[][] | string[];\n duplicate_responses?: boolean;\n response_containers?: unknown[];\n options?: Record<string, unknown>[] | string[];\n feedback_attempts?: number;\n stems?: string[];\n multiple_responses?: boolean;\n}\n\nexport interface ILearnosityItem {\n reference: string;\n questions: ILearnosityQuestion[];\n source: Record<string, unknown>;\n content: string;\n metadata: Record<string, unknown> | unknown[];\n workflow: unknown[];\n response_ids: string[];\n feature_ids: unknown[];\n features: unknown[];\n itemType?: TItemType;\n tags?: string[];\n}\n\nexport interface IWorksheetQuestion extends ILearnosityQuestion {\n item_reference: string;\n item_type?: TItemType;\n section_name?: TSectionName;\n is_optional?: boolean;\n item_tags: string[];\n item_tags_map: Record<string, string>;\n item_number: number;\n item_display_number: number;\n question_number: number;\n total_questions: number;\n}\n\nexport interface ILearnosityQuestionScore {\n score?: number | null;\n max_score: number;\n unscored?: boolean;\n}\n\nexport interface ILearnosityQuestionResponse {\n value: unknown;\n responses?: unknown;\n type: unknown;\n updatedFormat?: boolean;\n wordCount?: number;\n apiVersion: string;\n revision: number;\n feedbackAttemptsCount?: number;\n}\n\nexport interface IAttempt {\n response: ILearnosityQuestionResponse;\n score: ILearnosityQuestionScore;\n}\n\ninterface ITeacherReview {\n reviewComment?: string;\n images?: string[];\n}\nexport interface IWorksheetResponse {\n widgetReference: string;\n itemReference: string;\n itemPosition: number; // 0 based\n questionPosition: number; // 0 based\n isOkayTypeQuestion: boolean;\n response?: ILearnosityQuestionResponse;\n simState?: Record<string, unknown>;\n score?: ILearnosityQuestionScore;\n responseEdited?: boolean;\n hintsUsed?: number;\n markedForReview?: boolean;\n attemptsHistory?: IAttempt[];\n validatedByTeacher?: boolean;\n submittedByStudent?: boolean;\n assignStatus?: 'assigned' | 'skipped';\n rating?: number;\n skipped?: boolean;\n doubtResolved?: boolean;\n teacherReview?: ITeacherReview;\n tags?: Record<string, string>;\n timeSpent?: number;\n}\n\ntype TMathRenderer = 'mathjax' | 'mathquill';\nexport interface ILearnosity {\n ready: () => void;\n questions: () => Record<string, unknown>;\n question: (responseId: string) =>\n | {\n enable: () => boolean;\n disable: () => boolean;\n getQuestion: () => ILearnosityQuestion;\n getMetadata: () => ILearnosityQuestionMetadata;\n getResponse: () => ILearnosityQuestionResponse;\n getScore: (\n callback?: (score: ILearnosityQuestionScore | null) => void,\n ) => ILearnosityQuestionScore;\n validate: (\n options?: { showCorrectAnswers?: boolean; feedbackAttempts?: boolean },\n callback?: () => void,\n ) => void;\n resetValidationUI: () => void;\n on: (eventName: 'changed', callback: () => void) => void;\n off: (eventName: 'changed', callback?: () => void) => void;\n }\n | undefined;\n append: (toAppend: {\n questions: ILearnosityQuestion[];\n responses?: Record<string, unknown>;\n }) => void;\n appendQuestion: (toAppend: {\n questions: ILearnosityQuestion[];\n responses?: Record<string, unknown>;\n }) => void;\n reset: () => void;\n renderMath: (renderer: TMathRenderer) => void;\n}\n\nexport interface IWorksheetBehavior {\n /**\n * If true, Opens the worksheet in resume mode.\n * - If false, Opens the worksheet in review mode.\n */\n canAttempt: boolean;\n /**\n * If true, the user can mark the question for review.\n */\n canMarkForReview: boolean;\n /**\n * The mode of navigation for the worksheet.\n * - `OPEN` mode allows the user to navigate to any question in the worksheet.\n * - `LINEAR` mode allows the user to navigate to the next question only.\n * - `ADAPTIVE` mode allows the user to navigate future questions based on the rating of the current question.\n * - `CURRENT` mode allows the user to navigate to the current question only. Back and forth not allowed.\n */\n navigationMode: 'OPEN' | 'LINEAR' | 'ADAPTIVE' | 'CURRENT';\n /**\n * The initial question to display when the worksheet is loaded.\n * - `FIRST` mode displays the first question in the worksheet.\n * - `CURRENT` mode displays the question that the user was last on.\n */\n initialQuestion: 'FIRST' | 'CURRENT';\n /**\n * If hints are available, on clicking the help button, first availble hint will be shown.\n * Clicking again will show the next hint.\n * If no more hints are available, onHelp will be called.\n */\n hints: boolean;\n /**\n * The time in seconds after which the hints button will be shown.\n */\n hintsTimer?: number; // in seconds\n /**\n * If true, the user can skip the question without attempting it.\n * Skip button will be shown only after the hints are exausted and skipTimer is reached.\n */\n skippable?: boolean;\n /**\n * The time in seconds after which the user can skip the question.\n */\n skippableTime?: number; // in seconds\n /**\n * If true, teacher validation is needed for the question to proceed\n */\n teacherValidationEnabled: boolean;\n /**\n * If worksheet is attempting outside the class setting\n * This needs teacherValidationEnabled to be true\n * TODO: Consider changing to accept validation type: 'system' | 'teacher' | undefined instead of boolean\n */\n canTeacherValidate: boolean;\n /**\n * If true, questions will be validated and feedback will be shown.\n */\n validation: boolean;\n /**\n * If true, solution wont be shown to the user.\n */\n solutionHidden?: boolean;\n /**\n * If true, questions will be validated and feedback will be shown along with the correct answer.\n */\n review: boolean;\n /**\n * The maximum number of attempts allowed for each question.\n * 0 means unlimited attempts.\n * -1 means attempts will not be validated, hence not pushed to attempt history.\n * -2 means the sheet is a puzzle sheet\n * After reaching the maximum number of attempts, the user cannot attempt the question anymore.\n * If maxAtttmpts reached and canExceedAttempts is true, the user can still attempt the question\n * , also user will have the option to move to next question\n */\n maximumAttempts: number;\n /**\n * If true, the user can exceed the maximum number of attempts.\n */\n canExceedAttempts: boolean;\n /**\n * If the worksheet minimumAccuracy is not met, on clicking the final submit button, onMinimumAccuracyNotMet will be called.\n */\n minimumAccuracy: number;\n /**\n * Label for the check button\n * For example,\n * - \"Check\" for Checking the answer\n * - \"Submit\" for Submitting the answer when doing assessment\n */\n checkButtonLabel: string;\n /**\n * If attempt is incorrect, we show retry button, this is the label for the retry button\n * For example,\n * - 'Try Again' for retrying the question\n */\n retryButtonLabel: string;\n /**\n * If true show demos calculator https://www.desmos.com/calculator\n */\n canShowDesmosCalc: boolean;\n\n // If true, canvas is enabled and user can use canvas to scribble on the worksheet by toggling the scribble button\n canvasEnabled?: boolean;\n\n // If true, the user can scribble on workheet\n canScribble?: boolean;\n}\n\nexport type TWORKSHEET_QUESTION_MEDIA_TYPE = 'SIMULATION' | 'VIDEO' | 'AUDIO';\n\nexport interface IWorksheetCallbackProps {\n onResponseChange?: (options: {\n responseId: string;\n response: IWorksheetResponse;\n isNewAttempt: boolean;\n question: IWorksheetQuestion;\n }) => void;\n onBulkResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;\n onResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;\n onMediaStateChange?: (\n question: IWorksheetQuestion,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n onTeacherValidation?: (questionId: string, rating?: keyof typeof QUESTIONS_RATING) => void;\n onOptionalItemAssignment?: (itemType: TItemType) => void;\n onOptionalItemSkip?: (itemType: TItemType) => void;\n onHelp?: (options: { questionId: string; questionNumber: string }) => void;\n onMinimumAccuracyNotMet?: (accuracy: number) => void;\n onExitTicketStart?: () => void;\n onExitTicketSubmit?: () => void;\n onSubmit?: (responses: Record<string, IWorksheetResponse>) => void;\n onActiveQuestionChange?: (question: IWorksheetQuestion) => void;\n onResolveDoubt?: (responseId: string) => void;\n onSkip?: (itemIndex: number, widgetIndex: number) => void;\n onLoaded: () => void;\n onErrored: (error: { code?: number; message: string }) => void;\n onResponsesLoaded?: (responses: Record<string, IWorksheetResponse>) => void;\n openQuestionFeedbackModal?: (itemRef: string) => void;\n}\n\nexport interface ICueCanvasCallbackProps {\n onPublishStrokes?: TPublish;\n onReceiveStrokes?: TSubscribe;\n}\n\nexport interface ICueCanvasProps {\n initialStrokesData?: Record<string, IActionData[]>;\n}\n\nexport interface IPointerSyncCallbackProps {\n onPublishMouseMove?: TPublishMouseMove;\n onSubscribeMouseMove?: TSubscribeMouseMove;\n}\n\nexport interface IWorksheetLayout {\n containerStyle: 'none' | 'card';\n navigationBar: 'none' | 'top' | 'bottom';\n actionBar: 'none' | 'bottom';\n containerWidth: string;\n topOffset: number; // Offset from the top of the screen, for eg: height of the header\n questionsScrollable: boolean;\n minQuestionHeight: string | number;\n minSummaryHeight: string | number;\n renderSideBar: boolean;\n showUserPointer?: boolean;\n renderQuestionHeader?: boolean;\n imageHue?: THueNames;\n background?: 'none' | 'paper';\n questionPadding: number;\n}\n\nexport interface ISubjectiveSheetProps {\n onAddReviewComment?: (\n responseId: string,\n commentData: {\n score: ILearnosityQuestionScore;\n teacherReview: ITeacherReview;\n },\n ) => void;\n openImagesReviewModal?: (props: IOpenImageReviewModalProps) => void;\n handleReviewSubmit?: () => void;\n isSubmittingReview?: boolean;\n isReviewPending?: boolean;\n}\n\ninterface IBaseWorksheetProps {\n userType: TUserTypes;\n userId: string;\n studentId: string;\n studentName?: string;\n worksheetName: string;\n initialResponseId?: string;\n initialItemIndex?: number;\n layout: IWorksheetLayout;\n updatedResponses?: Record<string, IWorksheetResponse>;\n worksheetCompleted: boolean;\n showNudgeBanner?: boolean;\n markedAsCompleted?: boolean;\n canResolveDoubt?: boolean;\n canShowActionBar?: boolean;\n actionBarRightElement?: ReactElement; // Extra Elements to be rendered in the action bar\n attemptId?: string;\n itemsSignedRequest: string;\n questionsSignedRequest: string;\n summaryDescription?: ReactElement | null;\n canSubmitWorksheet?: boolean;\n subjectiveProps?: ISubjectiveSheetProps;\n inClass?: boolean; // If true, the worksheet is rendered inside class\n isLessonV3Enabled?: boolean; // If true, the worksheet is rendered in lesson v3 mode\n isDesmosEnabled?: boolean; // If true, the worksheet can show desmos calculator\n nodeType: TNodeTypes; // NodeType of the worksheet\n mode: 'resume' | 'review' | 'preview'; // mode of the worksheet\n loggerRef: MutableRefObject<(eventName: string, data?: Record<string, unknown>) => void>;\n}\n\ninterface IWorksheetPlugins {\n plugins?: {\n stickers?: ReactNode;\n };\n}\n\nexport interface IUpdateImages {\n filteredImages: string[];\n newImages: IFile[];\n}\nexport interface IOpenImageReviewModalProps {\n isReviewed?: boolean;\n disableScoreForm?: boolean;\n imageUrls?: string[];\n filteredImageUrls?: (props: IUpdateImages) => void;\n uploadedImages?: (IFile | string)[];\n image?: string;\n}\n\nexport interface IWorksheetProps\n extends IBaseWorksheetProps,\n IWorksheetCallbackProps,\n ICueCanvasProps,\n ICueCanvasCallbackProps,\n IPointerSyncCallbackProps,\n IWorksheetPlugins {}\n\nexport interface IWorksheetRef {\n validateQuestion: (\n responseId: string,\n rating?: keyof typeof QUESTIONS_RATING,\n skipRemainingQuestions?: boolean,\n ) => void;\n assignOptionalItems: (itemType: TItemType) => void;\n skipOptionalItems: (itemType: TItemType) => void;\n updateMediaState: (\n responseId: string,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n}\n\ninterface IWorksheetHeaderLayoutArgs {\n isPuzzleWorksheet?: boolean;\n isTestWorksheet?: boolean;\n imageHue?: THueNames;\n}\n\nexport interface IWorksheetHeaderLayoutProps {\n (args: IWorksheetHeaderLayoutArgs): {\n bgColor: TColorNames;\n borderColor?: TColorNames;\n textColor?: TColorNames;\n };\n}\n\nexport type TWorksheetStoreProps = Omit<\n IBaseWorksheetProps,\n 'studentName' | 'canShowActionBar' | 'itemsSignedRequest' | 'nodeType' | 'mode'\n> &\n Required<Pick<IBaseWorksheetProps, 'studentName' | 'canShowActionBar'>> &\n Omit<IWorksheetCallbackProps, 'onLoaded' | 'onErrored'> &\n ICueCanvasProps &\n ICueCanvasCallbackProps &\n IPointerSyncCallbackProps &\n IWorksheetPlugins & {\n behavior: IWorksheetBehavior;\n learnosityItems: ILearnosityItem[];\n learnosityResponses?: Record<string, IWorksheetResponse>;\n learnosity: ILearnosity;\n appendedQuestionIds: string[];\n };\n\nexport interface IWorksheetStoreState {\n questions: IWorksheetQuestion[];\n renderableQuestions: IWorksheetQuestion[];\n responses: Record<string, IWorksheetResponse>;\n lastUnlockedQuestionIndex: number;\n initialQuestionId: string;\n activeQuestionId: string;\n activeQuestionIndex: number;\n questionsContainerWidth: number;\n maxQuestionWidth: number;\n actionbarHeight: number;\n summaryVisible: boolean;\n calculatorVisible: boolean;\n scribblingEnabled: boolean;\n blocker?: TWorksheetBlocker;\n}\n\n// Actions interface - contains all the methods\ninterface IWorksheetStoreActions {\n mergeWorksheetProps: (data: TWorksheetStoreProps) => void;\n setResponses: (\n responses:\n | IWorksheetStore['responses']\n | ((prevResponses: IWorksheetStore['responses']) => IWorksheetStore['responses']),\n ) => void;\n showSummary: () => void;\n hideSummary: () => void;\n toggleSummary: () => void;\n showCalculator: () => void;\n hideCalculator: () => void;\n toggleScribble: () => void;\n setBlocker: (blocker?: TWorksheetBlocker) => void;\n removeBlocker: () => void;\n updateResponse: (options: {\n responseId: string;\n response: ILearnosityQuestionResponse;\n score: ILearnosityQuestionScore;\n timeSpent: number;\n answerChecked?: boolean;\n }) => void;\n updateMediaState: (\n responseId: string,\n mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE,\n mediaState: Record<string, unknown>,\n ) => void;\n markForReview: (responseId: string, markedForReview: boolean) => void;\n changeQuestion: (questionId: string, shouldScroll?: boolean, scrollDelay?: number) => void;\n destroy: () => void;\n}\n\n// Combined store interface\nexport interface IWorksheetStore\n extends IWorksheetStoreState,\n TWorksheetStoreProps,\n IWorksheetStoreActions {}\n"],"names":["QUESTION_TAGS","QUESTIONS_RATING"],"mappings":"AASY,IAAAA,sBAAAA,OACVA,EAAA,cAAc,eACdA,EAAA,gBAAgB,iBAFNA,IAAAA,KAAA,CAAA,CAAA,GAKAC,sBAAAA,OACVA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KACAA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KACAA,EAAAA,EAAA,IAAI,CAAJ,IAAA,KAHUA,IAAAA,KAAA,CAAA,CAAA;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4736,7 +4736,7 @@ declare interface IWorksheetCallbackProps {
|
|
|
4736
4736
|
}) => void;
|
|
4737
4737
|
onBulkResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;
|
|
4738
4738
|
onResponsesChange?: (responses: Record<string, IWorksheetResponse>) => void;
|
|
4739
|
-
onMediaStateChange?: (question: IWorksheetQuestion, mediaType:
|
|
4739
|
+
onMediaStateChange?: (question: IWorksheetQuestion, mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE, mediaState: Record<string, unknown>) => void;
|
|
4740
4740
|
onTeacherValidation?: (questionId: string, rating?: keyof typeof QUESTIONS_RATING) => void;
|
|
4741
4741
|
onOptionalItemAssignment?: (itemType: TItemType) => void;
|
|
4742
4742
|
onOptionalItemSkip?: (itemType: TItemType) => void;
|
|
@@ -4835,7 +4835,7 @@ export declare interface IWorksheetRef {
|
|
|
4835
4835
|
validateQuestion: (responseId: string, rating?: keyof typeof QUESTIONS_RATING, skipRemainingQuestions?: boolean) => void;
|
|
4836
4836
|
assignOptionalItems: (itemType: TItemType) => void;
|
|
4837
4837
|
skipOptionalItems: (itemType: TItemType) => void;
|
|
4838
|
-
updateMediaState: (responseId: string, mediaType:
|
|
4838
|
+
updateMediaState: (responseId: string, mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE, mediaState: Record<string, unknown>) => void;
|
|
4839
4839
|
}
|
|
4840
4840
|
|
|
4841
4841
|
export declare interface IWorksheetResponse {
|
|
@@ -6157,7 +6157,7 @@ export declare type TInclassMessage = {
|
|
|
6157
6157
|
eventPayload: {
|
|
6158
6158
|
attemptId: string;
|
|
6159
6159
|
responseId: string;
|
|
6160
|
-
mediaType:
|
|
6160
|
+
mediaType: TWORKSHEET_QUESTION_MEDIA_TYPE;
|
|
6161
6161
|
mediaState: Record<string, unknown>;
|
|
6162
6162
|
};
|
|
6163
6163
|
} | {
|
|
@@ -7019,12 +7019,12 @@ export declare const Tutorial: ForwardRefExoticComponent<ITutorialProps & RefAtt
|
|
|
7019
7019
|
|
|
7020
7020
|
export declare const TutoringIcon: FC<SVGProps<SVGSVGElement>>;
|
|
7021
7021
|
|
|
7022
|
+
declare type TWORKSHEET_QUESTION_MEDIA_TYPE = 'SIMULATION' | 'VIDEO' | 'AUDIO';
|
|
7023
|
+
|
|
7022
7024
|
declare type TWorksheetItems = {
|
|
7023
7025
|
ref: string;
|
|
7024
7026
|
};
|
|
7025
7027
|
|
|
7026
|
-
declare type TWORKSHHET_QUESTION_MEDIA_TYPE = 'SIMULATION' | 'VIDEO' | 'AUDIO';
|
|
7027
|
-
|
|
7028
7028
|
export declare type TZIndexMap = Record<keyof typeof ZINDEX, number>;
|
|
7029
7029
|
|
|
7030
7030
|
export declare const UIContext: Context<UIContextProps>;
|
|
@@ -1,196 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
return l
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (s)
|
|
14
|
-
return { type: "tracked", store: i, ...s };
|
|
15
|
-
const e = {
|
|
16
|
-
connection: l.connect(n),
|
|
17
|
-
stores: {}
|
|
18
|
-
};
|
|
19
|
-
return m.set(n.name, e), { type: "tracked", store: i, ...e };
|
|
20
|
-
}, I = (i, l) => {
|
|
21
|
-
if (l === void 0) return;
|
|
22
|
-
const n = m.get(i);
|
|
23
|
-
n && (delete n.stores[l], Object.keys(n.stores).length === 0 && m.delete(i));
|
|
24
|
-
}, C = (i) => {
|
|
25
|
-
var l, n;
|
|
26
|
-
if (!i) return;
|
|
27
|
-
const s = i.split(`
|
|
28
|
-
`), e = s.findIndex(
|
|
29
|
-
(y) => y.includes("api.setState")
|
|
30
|
-
);
|
|
31
|
-
if (e < 0) return;
|
|
32
|
-
const b = ((l = s[e + 1]) == null ? void 0 : l.trim()) || "";
|
|
33
|
-
return (n = /.+ (.+) .+/.exec(b)) == null ? void 0 : n[1];
|
|
34
|
-
}, w = (i, l = {}) => (n, s, e) => {
|
|
35
|
-
const { enabled: b, anonymousActionType: y, store: r, ...u } = l;
|
|
36
|
-
let p;
|
|
37
|
-
try {
|
|
38
|
-
p = (b ?? (T ? "production" : void 0) !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__;
|
|
39
|
-
} catch {
|
|
40
|
-
}
|
|
41
|
-
if (!p)
|
|
42
|
-
return i(n, s, e);
|
|
43
|
-
const { connection: t, ...f } = E(r, p, u);
|
|
44
|
-
let S = !0;
|
|
45
|
-
e.setState = (c, v, o) => {
|
|
46
|
-
const a = n(c, v);
|
|
47
|
-
if (!S) return a;
|
|
48
|
-
const O = o === void 0 ? {
|
|
49
|
-
type: y || C(new Error().stack) || "anonymous"
|
|
50
|
-
} : typeof o == "string" ? { type: o } : o;
|
|
51
|
-
return r === void 0 ? (t == null || t.send(O, s()), a) : (t == null || t.send(
|
|
52
|
-
{
|
|
53
|
-
...O,
|
|
54
|
-
type: `${r}/${O.type}`
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
...h(u.name),
|
|
58
|
-
[r]: e.getState()
|
|
59
|
-
}
|
|
60
|
-
), a);
|
|
61
|
-
}, e.devtools = {
|
|
62
|
-
cleanup: () => {
|
|
63
|
-
t && typeof t.unsubscribe == "function" && t.unsubscribe(), I(u.name, r);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const d = (...c) => {
|
|
67
|
-
const v = S;
|
|
68
|
-
S = !1, n(...c), S = v;
|
|
69
|
-
}, _ = i(e.setState, s, e);
|
|
70
|
-
if (f.type === "untracked" ? t == null || t.init(_) : (f.stores[f.store] = e, t == null || t.init(
|
|
71
|
-
Object.fromEntries(
|
|
72
|
-
Object.entries(f.stores).map(([c, v]) => [
|
|
73
|
-
c,
|
|
74
|
-
c === f.store ? _ : v.getState()
|
|
75
|
-
])
|
|
76
|
-
)
|
|
77
|
-
)), e.dispatchFromDevtools && typeof e.dispatch == "function") {
|
|
78
|
-
let c = !1;
|
|
79
|
-
const v = e.dispatch;
|
|
80
|
-
e.dispatch = (...o) => {
|
|
81
|
-
(T ? "production" : void 0) !== "production" && o[0].type === "__setState" && !c && (console.warn(
|
|
82
|
-
'[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'
|
|
83
|
-
), c = !0), v(...o);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return t.subscribe((c) => {
|
|
87
|
-
var v;
|
|
88
|
-
switch (c.type) {
|
|
89
|
-
case "ACTION":
|
|
90
|
-
if (typeof c.payload != "string") {
|
|
91
|
-
console.error(
|
|
92
|
-
"[zustand devtools middleware] Unsupported action format"
|
|
93
|
-
);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
return g(
|
|
97
|
-
c.payload,
|
|
98
|
-
(o) => {
|
|
99
|
-
if (o.type === "__setState") {
|
|
100
|
-
if (r === void 0) {
|
|
101
|
-
d(o.state);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
Object.keys(o.state).length !== 1 && console.error(
|
|
105
|
-
`
|
|
106
|
-
[zustand devtools middleware] Unsupported __setState action format.
|
|
107
|
-
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
108
|
-
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
109
|
-
`
|
|
110
|
-
);
|
|
111
|
-
const a = o.state[r];
|
|
112
|
-
if (a == null)
|
|
113
|
-
return;
|
|
114
|
-
JSON.stringify(e.getState()) !== JSON.stringify(a) && d(a);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
e.dispatchFromDevtools && typeof e.dispatch == "function" && e.dispatch(o);
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
case "DISPATCH":
|
|
121
|
-
switch (c.payload.type) {
|
|
122
|
-
case "RESET":
|
|
123
|
-
return d(_), r === void 0 ? t == null ? void 0 : t.init(e.getState()) : t == null ? void 0 : t.init(h(u.name));
|
|
124
|
-
case "COMMIT":
|
|
125
|
-
if (r === void 0) {
|
|
126
|
-
t == null || t.init(e.getState());
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
return t == null ? void 0 : t.init(h(u.name));
|
|
130
|
-
case "ROLLBACK":
|
|
131
|
-
return g(c.state, (o) => {
|
|
132
|
-
if (r === void 0) {
|
|
133
|
-
d(o), t == null || t.init(e.getState());
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
d(o[r]), t == null || t.init(h(u.name));
|
|
137
|
-
});
|
|
138
|
-
case "JUMP_TO_STATE":
|
|
139
|
-
case "JUMP_TO_ACTION":
|
|
140
|
-
return g(c.state, (o) => {
|
|
141
|
-
if (r === void 0) {
|
|
142
|
-
d(o);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
JSON.stringify(e.getState()) !== JSON.stringify(o[r]) && d(o[r]);
|
|
146
|
-
});
|
|
147
|
-
case "IMPORT_STATE": {
|
|
148
|
-
const { nextLiftedState: o } = c.payload, a = (v = o.computedStates.slice(-1)[0]) == null ? void 0 : v.state;
|
|
149
|
-
if (!a) return;
|
|
150
|
-
d(r === void 0 ? a : a[r]), t == null || t.send(
|
|
151
|
-
null,
|
|
152
|
-
// FIXME no-any
|
|
153
|
-
o
|
|
154
|
-
);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
case "PAUSE_RECORDING":
|
|
158
|
-
return S = !S;
|
|
159
|
-
}
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
}), _;
|
|
163
|
-
}, R = w, g = (i, l) => {
|
|
164
|
-
let n;
|
|
165
|
-
try {
|
|
166
|
-
n = JSON.parse(i);
|
|
167
|
-
} catch (s) {
|
|
168
|
-
console.error(
|
|
169
|
-
"[zustand devtools middleware] Could not parse the received json",
|
|
170
|
-
s
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
n !== void 0 && l(n);
|
|
174
|
-
}, D = (i) => (l, n, s) => {
|
|
175
|
-
const e = s.subscribe;
|
|
176
|
-
return s.subscribe = (y, r, u) => {
|
|
177
|
-
let p = y;
|
|
178
|
-
if (r) {
|
|
179
|
-
const t = (u == null ? void 0 : u.equalityFn) || Object.is;
|
|
180
|
-
let f = y(s.getState());
|
|
181
|
-
p = (S) => {
|
|
182
|
-
const d = y(S);
|
|
183
|
-
if (!t(f, d)) {
|
|
184
|
-
const _ = f;
|
|
185
|
-
r(f = d, _);
|
|
1
|
+
const d = (u) => (s, b, t) => {
|
|
2
|
+
const S = t.subscribe;
|
|
3
|
+
return t.subscribe = (c, l, i) => {
|
|
4
|
+
let r = c;
|
|
5
|
+
if (l) {
|
|
6
|
+
const a = (i == null ? void 0 : i.equalityFn) || Object.is;
|
|
7
|
+
let e = c(t.getState());
|
|
8
|
+
r = (f) => {
|
|
9
|
+
const n = c(f);
|
|
10
|
+
if (!a(e, n)) {
|
|
11
|
+
const o = e;
|
|
12
|
+
l(e = n, o);
|
|
186
13
|
}
|
|
187
|
-
},
|
|
14
|
+
}, i != null && i.fireImmediately && l(e, e);
|
|
188
15
|
}
|
|
189
|
-
return
|
|
190
|
-
},
|
|
191
|
-
},
|
|
16
|
+
return S(r);
|
|
17
|
+
}, u(s, b, t);
|
|
18
|
+
}, v = d;
|
|
192
19
|
export {
|
|
193
|
-
|
|
194
|
-
N as subscribeWithSelector
|
|
20
|
+
v as subscribeWithSelector
|
|
195
21
|
};
|
|
196
22
|
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sources":["../../../../node_modules/zustand/esm/middleware.mjs"],"sourcesContent":["const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...args) => api.dispatch(...args), ...initial };\n};\nconst redux = reduxImpl;\n\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst removeStoreFromTrackedConnections = (name, store) => {\n if (store === void 0) return;\n const connectionInfo = trackedConnections.get(name);\n if (!connectionInfo) return;\n delete connectionInfo.stores[store];\n if (Object.keys(connectionInfo.stores).length === 0) {\n trackedConnections.delete(name);\n }\n};\nconst findCallerName = (stack) => {\n var _a, _b;\n if (!stack) return void 0;\n const traceLines = stack.split(\"\\n\");\n const apiSetStateLineIndex = traceLines.findIndex(\n (traceLine) => traceLine.includes(\"api.setState\")\n );\n if (apiSetStateLineIndex < 0) return void 0;\n const callerLine = ((_a = traceLines[apiSetStateLineIndex + 1]) == null ? void 0 : _a.trim()) || \"\";\n return (_b = /.+ (.+) .+/.exec(callerLine)) == null ? void 0 : _b[1];\n};\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = ((state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? {\n type: anonymousActionType || findCallerName(new Error().stack) || \"anonymous\"\n } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n });\n api.devtools = {\n cleanup: () => {\n if (connection && typeof connection.unsubscribe === \"function\") {\n connection.unsubscribe();\n }\n removeStoreFromTrackedConnections(options.name, store);\n }\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (api.dispatchFromDevtools && typeof api.dispatch === \"function\") {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && args[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...args);\n };\n }\n connection.subscribe((message) => {\n var _a;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (!api.dispatchFromDevtools) return;\n if (typeof api.dispatch !== \"function\") return;\n api.dispatch(action);\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, fn) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) fn(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = ((selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n });\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nfunction combine(initialState, create) {\n return (...args) => Object.assign({}, initialState, create(...args));\n}\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (state, replace) => {\n savedSetState(state, replace);\n return setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n return setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n const migration = options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n );\n if (migration instanceof Promise) {\n return migration.then((result) => [true, result]);\n }\n return [true, migration];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector };\n"],"names":["trackedConnections","getTrackedConnectionState","name","api","key","api2","extractConnectionInformation","store","extensionConnector","options","existingConnection","newConnection","removeStoreFromTrackedConnections","connectionInfo","findCallerName","stack","_a","_b","traceLines","apiSetStateLineIndex","traceLine","callerLine","devtoolsImpl","fn","devtoolsOptions","set","get","enabled","anonymousActionType","__vite_import_meta_env__","connection","connectionInformation","isRecording","state","replace","nameOrAction","r","action","setStateFromDevtools","a","originalIsRecording","initialState","store2","didWarnAboutReservedActionType","originalDispatch","args","message","parseJsonThen","stateFromDevtools","nextLiftedState","lastComputedState","devtools","stringified","parsed","e","subscribeWithSelectorImpl","origSubscribe","selector","optListener","listener","equalityFn","currentSlice","nextSlice","previousSlice","subscribeWithSelector"],"mappings":"6EAUMA,wBAAyC,OACzCC,IAA4B,CAACC,MAAS;A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,MAAU;AACd,cAAA6B,IAAYL,EAASxB,CAAK;AAChC,YAAI,CAAC2B,EAAWC,GAAcC,CAAS,GAAG;AACxC,gBAAMC,IAAgBF;AACV,UAAAH,EAAAG,IAAeC,GAAWC,CAAa;AAAA,QACrD;AAAA,MAAA,GAEEtD,KAAW,QAAgBA,EAAQ,mBACrCiD,EAAYG,GAAcA,CAAY;AAAA,IAE1C;AACA,WAAOL,EAAcG,CAAQ;AAAA,EAAA,GAEVpC,EAAGE,GAAKC,GAAKvB,CAAG;AAEvC,GACM6D,IAAwBT;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"middleware.js","sources":["../../../../node_modules/zustand/esm/middleware.mjs"],"sourcesContent":["const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...args) => api.dispatch(...args), ...initial };\n};\nconst redux = reduxImpl;\n\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst removeStoreFromTrackedConnections = (name, store) => {\n if (store === void 0) return;\n const connectionInfo = trackedConnections.get(name);\n if (!connectionInfo) return;\n delete connectionInfo.stores[store];\n if (Object.keys(connectionInfo.stores).length === 0) {\n trackedConnections.delete(name);\n }\n};\nconst findCallerName = (stack) => {\n var _a, _b;\n if (!stack) return void 0;\n const traceLines = stack.split(\"\\n\");\n const apiSetStateLineIndex = traceLines.findIndex(\n (traceLine) => traceLine.includes(\"api.setState\")\n );\n if (apiSetStateLineIndex < 0) return void 0;\n const callerLine = ((_a = traceLines[apiSetStateLineIndex + 1]) == null ? void 0 : _a.trim()) || \"\";\n return (_b = /.+ (.+) .+/.exec(callerLine)) == null ? void 0 : _b[1];\n};\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = ((state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? {\n type: anonymousActionType || findCallerName(new Error().stack) || \"anonymous\"\n } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n });\n api.devtools = {\n cleanup: () => {\n if (connection && typeof connection.unsubscribe === \"function\") {\n connection.unsubscribe();\n }\n removeStoreFromTrackedConnections(options.name, store);\n }\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (api.dispatchFromDevtools && typeof api.dispatch === \"function\") {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...args) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && args[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...args);\n };\n }\n connection.subscribe((message) => {\n var _a;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (!api.dispatchFromDevtools) return;\n if (typeof api.dispatch !== \"function\") return;\n api.dispatch(action);\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, fn) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) fn(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = ((selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n });\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nfunction combine(initialState, create) {\n return (...args) => Object.assign({}, initialState, create(...args));\n}\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (state, replace) => {\n savedSetState(state, replace);\n return setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n return setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n const migration = options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n );\n if (migration instanceof Promise) {\n return migration.then((result) => [true, result]);\n }\n return [true, migration];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector };\n"],"names":["subscribeWithSelectorImpl","fn","set","get","api","origSubscribe","selector","optListener","options","listener","equalityFn","currentSlice","state","nextSlice","previousSlice","subscribeWithSelector"],"mappings":"AAqPA,MAAMA,IAA4B,CAACC,MAAO,CAACC,GAAKC,GAAKC,MAAQ;AAC3D,QAAMC,IAAgBD,EAAI;AAC1B,SAAAA,EAAI,YAAa,CAACE,GAAUC,GAAaC,MAAY;AACnD,QAAIC,IAAWH;AACf,QAAIC,GAAa;AACf,YAAMG,KAAcF,KAAW,OAAO,SAASA,EAAQ,eAAe,OAAO;AAC7E,UAAIG,IAAeL,EAASF,EAAI,SAAU,CAAA;AAC1C,MAAAK,IAAW,CAACG,MAAU;AACd,cAAAC,IAAYP,EAASM,CAAK;AAChC,YAAI,CAACF,EAAWC,GAAcE,CAAS,GAAG;AACxC,gBAAMC,IAAgBH;AACV,UAAAJ,EAAAI,IAAeE,GAAWC,CAAa;AAAA,QACrD;AAAA,MAAA,GAEEN,KAAW,QAAgBA,EAAQ,mBACrCD,EAAYI,GAAcA,CAAY;AAAA,IAE1C;AACA,WAAON,EAAcI,CAAQ;AAAA,EAAA,GAEVR,EAAGC,GAAKC,GAAKC,CAAG;AAEvC,GACMW,IAAwBf;","x_google_ignoreList":[0]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuemath/leap",
|
|
3
|
-
"version": "3.5.30-
|
|
3
|
+
"version": "3.5.30-gg4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@100mslive/hms-video-store": "0.10.8",
|
|
38
38
|
"@cuemath/av": "2.2.1",
|
|
39
39
|
"@cuemath/cue-message-broker": "1.0.37",
|
|
40
|
-
"@cuemath/eslint-config": "2.
|
|
40
|
+
"@cuemath/eslint-config": "2.4.0",
|
|
41
41
|
"@cuemath/prettier-config": "1.0.4",
|
|
42
42
|
"@cuemath/rest-api": "0.0.7",
|
|
43
43
|
"@cuemath/ts-config": "2.0.0",
|