@intellectif/lk-react 12.0.1 → 14.0.0
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/CHANGELOG.md +73 -0
- package/README.md +17 -6
- package/dist/{WrittenResponse-BgcpEM-e.d.ts → WrittenResponse-C0P34En1.d.ts} +1 -1
- package/dist/{WrittenResponse-ByzXYEoW.d.cts → WrittenResponse-pB1ik8hg.d.cts} +1 -1
- package/dist/chunk-36FTYJWJ.cjs +869 -0
- package/dist/chunk-36FTYJWJ.cjs.map +1 -0
- package/dist/chunk-47HHC4GD.js +763 -0
- package/dist/chunk-47HHC4GD.js.map +1 -0
- package/dist/chunk-62AKSD5Y.js +509 -0
- package/dist/chunk-62AKSD5Y.js.map +1 -0
- package/dist/{chunk-XKGBD3UK.js → chunk-72UGRIMM.js} +6 -5
- package/dist/chunk-72UGRIMM.js.map +1 -0
- package/dist/{chunk-FX7VMZHQ.cjs → chunk-B2XQLU2E.cjs} +58 -8
- package/dist/chunk-B2XQLU2E.cjs.map +1 -0
- package/dist/{chunk-ZFWC4KZC.js → chunk-BO6P723E.js} +26 -31
- package/dist/chunk-BO6P723E.js.map +1 -0
- package/dist/chunk-BRPEB43C.cjs +13 -0
- package/dist/chunk-BRPEB43C.cjs.map +1 -0
- package/dist/{chunk-6KMEB7TF.cjs → chunk-BVRUUYYR.cjs} +42 -15
- package/dist/chunk-BVRUUYYR.cjs.map +1 -0
- package/dist/{chunk-AMGK7DDM.cjs → chunk-D4DQFTA7.cjs} +2 -2
- package/dist/chunk-D4DQFTA7.cjs.map +1 -0
- package/dist/chunk-D57QZILZ.js +863 -0
- package/dist/chunk-D57QZILZ.js.map +1 -0
- package/dist/chunk-F4TBCRGI.cjs +518 -0
- package/dist/chunk-F4TBCRGI.cjs.map +1 -0
- package/dist/{chunk-V6M57YMK.js → chunk-I33FOKZ7.js} +227 -30
- package/dist/chunk-I33FOKZ7.js.map +1 -0
- package/dist/{chunk-GVBEI5R3.cjs → chunk-J2CDPIRC.cjs} +233 -36
- package/dist/chunk-J2CDPIRC.cjs.map +1 -0
- package/dist/{chunk-KYOCDRUO.cjs → chunk-LB3FEV7Z.cjs} +97 -2
- package/dist/chunk-LB3FEV7Z.cjs.map +1 -0
- package/dist/{chunk-QXYAOILF.js → chunk-LGCUOLP6.js} +6 -5
- package/dist/chunk-LGCUOLP6.js.map +1 -0
- package/dist/{chunk-GWD75Q25.js → chunk-LLXCX5KK.js} +6 -5
- package/dist/chunk-LLXCX5KK.js.map +1 -0
- package/dist/chunk-MCO52PV5.js +520 -0
- package/dist/chunk-MCO52PV5.js.map +1 -0
- package/dist/{chunk-G6PUWKQC.cjs → chunk-NDQD3ZRY.cjs} +15 -14
- package/dist/chunk-NDQD3ZRY.cjs.map +1 -0
- package/dist/chunk-OD65OZIW.cjs +159 -0
- package/dist/chunk-OD65OZIW.cjs.map +1 -0
- package/dist/chunk-RCMYEWBE.js +11 -0
- package/dist/chunk-RCMYEWBE.js.map +1 -0
- package/dist/{chunk-KSXEBV2H.cjs → chunk-RRH7ZPXC.cjs} +6 -6
- package/dist/{chunk-KSXEBV2H.cjs.map → chunk-RRH7ZPXC.cjs.map} +1 -1
- package/dist/{chunk-DQNVAXG6.js → chunk-RXS455MR.js} +2 -2
- package/dist/chunk-RXS455MR.js.map +1 -0
- package/dist/{chunk-LIHKQEIP.cjs → chunk-SE6WWDVW.cjs} +15 -14
- package/dist/chunk-SE6WWDVW.cjs.map +1 -0
- package/dist/{chunk-5IH3NRXE.js → chunk-SWY6PWXK.js} +4 -4
- package/dist/{chunk-5IH3NRXE.js.map → chunk-SWY6PWXK.js.map} +1 -1
- package/dist/chunk-TDJEKXEP.js +212 -0
- package/dist/chunk-TDJEKXEP.js.map +1 -0
- package/dist/{chunk-NK5EVL5C.cjs → chunk-U3APKQ7P.cjs} +15 -14
- package/dist/chunk-U3APKQ7P.cjs.map +1 -0
- package/dist/chunk-UDCQTOVU.cjs +523 -0
- package/dist/chunk-UDCQTOVU.cjs.map +1 -0
- package/dist/{chunk-EWTAMY6L.cjs → chunk-USBANZ7K.cjs} +27 -33
- package/dist/chunk-USBANZ7K.cjs.map +1 -0
- package/dist/chunk-WTS34S5E.cjs +765 -0
- package/dist/chunk-WTS34S5E.cjs.map +1 -0
- package/dist/{chunk-2Y6V5E7H.js → chunk-XIBOFTOL.js} +57 -7
- package/dist/chunk-XIBOFTOL.js.map +1 -0
- package/dist/{chunk-ZFSRMGWO.js → chunk-XUEIUEPI.js} +6 -5
- package/dist/chunk-XUEIUEPI.js.map +1 -0
- package/dist/{chunk-64AJVB6O.cjs → chunk-YEYKJFEC.cjs} +14 -13
- package/dist/chunk-YEYKJFEC.cjs.map +1 -0
- package/dist/{chunk-5S2YDMEJ.js → chunk-YMBBM5K7.js} +36 -9
- package/dist/chunk-YMBBM5K7.js.map +1 -0
- package/dist/chunk-YORQQXGO.js +155 -0
- package/dist/chunk-YORQQXGO.js.map +1 -0
- package/dist/components/ActivityPreview.cjs +15 -9
- package/dist/components/ActivityPreview.d.cts +9 -3
- package/dist/components/ActivityPreview.d.ts +9 -3
- package/dist/components/ActivityPreview.js +14 -8
- package/dist/components/ActivitySequence.cjs +16 -10
- package/dist/components/ActivitySequence.d.cts +112 -6
- package/dist/components/ActivitySequence.d.ts +112 -6
- package/dist/components/ActivitySequence.js +15 -9
- package/dist/components/Dictation.cjs +19 -0
- package/dist/components/Dictation.cjs.map +1 -0
- package/dist/components/Dictation.d.cts +17 -0
- package/dist/components/Dictation.d.ts +17 -0
- package/dist/components/Dictation.js +10 -0
- package/dist/components/Dictation.js.map +1 -0
- package/dist/components/FillInTheBlanks.cjs +6 -5
- package/dist/components/FillInTheBlanks.d.cts +2 -1
- package/dist/components/FillInTheBlanks.d.ts +2 -1
- package/dist/components/FillInTheBlanks.js +5 -4
- package/dist/components/GapSelect.cjs +6 -5
- package/dist/components/GapSelect.d.cts +2 -1
- package/dist/components/GapSelect.d.ts +2 -1
- package/dist/components/GapSelect.js +5 -4
- package/dist/components/MultipleChoice.cjs +6 -5
- package/dist/components/MultipleChoice.d.cts +2 -1
- package/dist/components/MultipleChoice.d.ts +2 -1
- package/dist/components/MultipleChoice.js +5 -4
- package/dist/components/PronunciationFeedback.cjs +16 -0
- package/dist/components/PronunciationFeedback.cjs.map +1 -0
- package/dist/components/PronunciationFeedback.d.cts +64 -0
- package/dist/components/PronunciationFeedback.d.ts +64 -0
- package/dist/components/PronunciationFeedback.js +7 -0
- package/dist/components/PronunciationFeedback.js.map +1 -0
- package/dist/components/ReadAloud.cjs +21 -0
- package/dist/components/ReadAloud.cjs.map +1 -0
- package/dist/components/ReadAloud.d.cts +15 -0
- package/dist/components/ReadAloud.d.ts +15 -0
- package/dist/components/ReadAloud.js +12 -0
- package/dist/components/ReadAloud.js.map +1 -0
- package/dist/components/StimulusPanel.cjs +4 -4
- package/dist/components/StimulusPanel.d.cts +2 -1
- package/dist/components/StimulusPanel.d.ts +2 -1
- package/dist/components/StimulusPanel.js +3 -3
- package/dist/components/WrittenResponse.cjs +6 -5
- package/dist/components/WrittenResponse.d.cts +4 -3
- package/dist/components/WrittenResponse.d.ts +4 -3
- package/dist/components/WrittenResponse.js +5 -4
- package/dist/hooks/useSpeechRecorder.cjs +17 -0
- package/dist/hooks/useSpeechRecorder.cjs.map +1 -0
- package/dist/hooks/useSpeechRecorder.d.cts +127 -0
- package/dist/hooks/useSpeechRecorder.d.ts +127 -0
- package/dist/hooks/useSpeechRecorder.js +4 -0
- package/dist/hooks/useSpeechRecorder.js.map +1 -0
- package/dist/i18n/LkIntlProvider.cjs +7 -7
- package/dist/i18n/LkIntlProvider.d.cts +3 -2
- package/dist/i18n/LkIntlProvider.d.ts +3 -2
- package/dist/i18n/LkIntlProvider.js +1 -1
- package/dist/index.cjs +59 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/dist/machine-CuwKqWXC.d.cts +26 -0
- package/dist/machine-CuwKqWXC.d.ts +26 -0
- package/dist/{strings-CN7n-BlE.d.ts → strings--ADnHcaA.d.cts} +261 -8
- package/dist/{strings-CN7n-BlE.d.cts → strings-CtdSf2St.d.ts} +261 -8
- package/dist/theme/ThemeProvider.cjs +6 -6
- package/dist/theme/ThemeProvider.d.cts +4 -4
- package/dist/theme/ThemeProvider.d.ts +4 -4
- package/dist/theme/ThemeProvider.js +1 -1
- package/dist/theme/skin.css +1050 -3
- package/package.json +43 -3
- package/dist/chunk-2Y6V5E7H.js.map +0 -1
- package/dist/chunk-5S2YDMEJ.js.map +0 -1
- package/dist/chunk-64AJVB6O.cjs.map +0 -1
- package/dist/chunk-6KMEB7TF.cjs.map +0 -1
- package/dist/chunk-AMGK7DDM.cjs.map +0 -1
- package/dist/chunk-CK7Z275S.js +0 -117
- package/dist/chunk-CK7Z275S.js.map +0 -1
- package/dist/chunk-DQNVAXG6.js.map +0 -1
- package/dist/chunk-EWTAMY6L.cjs.map +0 -1
- package/dist/chunk-FX7VMZHQ.cjs.map +0 -1
- package/dist/chunk-G6PUWKQC.cjs.map +0 -1
- package/dist/chunk-GVBEI5R3.cjs.map +0 -1
- package/dist/chunk-GWD75Q25.js.map +0 -1
- package/dist/chunk-KYOCDRUO.cjs.map +0 -1
- package/dist/chunk-LIHKQEIP.cjs.map +0 -1
- package/dist/chunk-NK5EVL5C.cjs.map +0 -1
- package/dist/chunk-QXYAOILF.js.map +0 -1
- package/dist/chunk-V6M57YMK.js.map +0 -1
- package/dist/chunk-XKGBD3UK.js.map +0 -1
- package/dist/chunk-ZFSRMGWO.js.map +0 -1
- package/dist/chunk-ZFWC4KZC.js.map +0 -1
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkLB3FEV7Z_cjs = require('../chunk-LB3FEV7Z.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "DEFAULT_STRINGS", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkLB3FEV7Z_cjs.DEFAULT_STRINGS; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "LkIntlProvider", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkLB3FEV7Z_cjs.LkIntlProvider; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "directionForLocale", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkLB3FEV7Z_cjs.directionForLocale; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "mergeStrings", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkLB3FEV7Z_cjs.mergeStrings; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "useLkDirection", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkLB3FEV7Z_cjs.useLkDirection; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "useLkStrings", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkLB3FEV7Z_cjs.useLkStrings; }
|
|
31
31
|
});
|
|
32
32
|
//# sourceMappingURL=LkIntlProvider.cjs.map
|
|
33
33
|
//# sourceMappingURL=LkIntlProvider.cjs.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as LkStringsOverride, L as LkStrings } from '../strings
|
|
2
|
-
export { D as DEFAULT_STRINGS, m as mergeStrings } from '../strings
|
|
1
|
+
import { a as LkStringsOverride, L as LkStrings } from '../strings--ADnHcaA.cjs';
|
|
2
|
+
export { D as DEFAULT_STRINGS, m as mergeStrings } from '../strings--ADnHcaA.cjs';
|
|
3
3
|
import '@intellectif/lk-core';
|
|
4
|
+
import '../machine-CuwKqWXC.cjs';
|
|
4
5
|
|
|
5
6
|
/** Writing direction of the surrounding UI. `auto` defers to the locale. */
|
|
6
7
|
type LkDirection = 'ltr' | 'rtl' | 'auto';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as LkStringsOverride, L as LkStrings } from '../strings-
|
|
2
|
-
export { D as DEFAULT_STRINGS, m as mergeStrings } from '../strings-
|
|
1
|
+
import { a as LkStringsOverride, L as LkStrings } from '../strings-CtdSf2St.js';
|
|
2
|
+
export { D as DEFAULT_STRINGS, m as mergeStrings } from '../strings-CtdSf2St.js';
|
|
3
3
|
import '@intellectif/lk-core';
|
|
4
|
+
import '../machine-CuwKqWXC.js';
|
|
4
5
|
|
|
5
6
|
/** Writing direction of the surrounding UI. `auto` defers to the locale. */
|
|
6
7
|
type LkDirection = 'ltr' | 'rtl' | 'auto';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
export { DEFAULT_STRINGS, LkIntlProvider, directionForLocale, mergeStrings, useLkDirection, useLkStrings } from '../chunk-
|
|
2
|
+
export { DEFAULT_STRINGS, LkIntlProvider, directionForLocale, mergeStrings, useLkDirection, useLkStrings } from '../chunk-TDJEKXEP.js';
|
|
3
3
|
//# sourceMappingURL=LkIntlProvider.js.map
|
|
4
4
|
//# sourceMappingURL=LkIntlProvider.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -2,18 +2,24 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunkPNNUPUH4_cjs = require('./chunk-PNNUPUH4.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
require('./chunk-
|
|
5
|
+
var chunkD4DQFTA7_cjs = require('./chunk-D4DQFTA7.cjs');
|
|
6
|
+
var chunkBVRUUYYR_cjs = require('./chunk-BVRUUYYR.cjs');
|
|
7
|
+
var chunkJ2CDPIRC_cjs = require('./chunk-J2CDPIRC.cjs');
|
|
8
|
+
var chunkRRH7ZPXC_cjs = require('./chunk-RRH7ZPXC.cjs');
|
|
9
|
+
var chunkYEYKJFEC_cjs = require('./chunk-YEYKJFEC.cjs');
|
|
10
|
+
var chunkNDQD3ZRY_cjs = require('./chunk-NDQD3ZRY.cjs');
|
|
11
|
+
var chunkSE6WWDVW_cjs = require('./chunk-SE6WWDVW.cjs');
|
|
12
|
+
var chunkU3APKQ7P_cjs = require('./chunk-U3APKQ7P.cjs');
|
|
13
|
+
var chunkWTS34S5E_cjs = require('./chunk-WTS34S5E.cjs');
|
|
14
|
+
var chunk36FTYJWJ_cjs = require('./chunk-36FTYJWJ.cjs');
|
|
15
|
+
var chunkF4TBCRGI_cjs = require('./chunk-F4TBCRGI.cjs');
|
|
16
|
+
var chunkUDCQTOVU_cjs = require('./chunk-UDCQTOVU.cjs');
|
|
17
|
+
require('./chunk-OD65OZIW.cjs');
|
|
18
|
+
require('./chunk-BRPEB43C.cjs');
|
|
19
|
+
require('./chunk-USBANZ7K.cjs');
|
|
20
|
+
require('./chunk-B2XQLU2E.cjs');
|
|
13
21
|
var chunkXOR4MPEN_cjs = require('./chunk-XOR4MPEN.cjs');
|
|
14
|
-
var
|
|
15
|
-
require('./chunk-FX7VMZHQ.cjs');
|
|
16
|
-
var chunkKYOCDRUO_cjs = require('./chunk-KYOCDRUO.cjs');
|
|
22
|
+
var chunkLB3FEV7Z_cjs = require('./chunk-LB3FEV7Z.cjs');
|
|
17
23
|
|
|
18
24
|
// src/components/types.ts
|
|
19
25
|
function asRenderable(redacted) {
|
|
@@ -29,79 +35,99 @@ Object.defineProperty(exports, "useXAPI", {
|
|
|
29
35
|
});
|
|
30
36
|
Object.defineProperty(exports, "ThemeProvider", {
|
|
31
37
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkD4DQFTA7_cjs.ThemeProvider; }
|
|
33
39
|
});
|
|
34
40
|
Object.defineProperty(exports, "createTailwindTheme", {
|
|
35
41
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkD4DQFTA7_cjs.createTailwindTheme; }
|
|
37
43
|
});
|
|
38
44
|
Object.defineProperty(exports, "darkTheme", {
|
|
39
45
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkD4DQFTA7_cjs.darkTheme; }
|
|
41
47
|
});
|
|
42
48
|
Object.defineProperty(exports, "defaultTheme", {
|
|
43
49
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkD4DQFTA7_cjs.defaultTheme; }
|
|
45
51
|
});
|
|
46
52
|
Object.defineProperty(exports, "useTheme", {
|
|
47
53
|
enumerable: true,
|
|
48
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkD4DQFTA7_cjs.useTheme; }
|
|
49
55
|
});
|
|
50
56
|
Object.defineProperty(exports, "ActivityPreview", {
|
|
51
57
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkBVRUUYYR_cjs.ActivityPreview; }
|
|
53
59
|
});
|
|
54
60
|
Object.defineProperty(exports, "ActivitySequence", {
|
|
55
61
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkJ2CDPIRC_cjs.ActivitySequence; }
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "StimulusPanel", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return chunkRRH7ZPXC_cjs.StimulusPanel; }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "WrittenResponse", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return chunkYEYKJFEC_cjs.WrittenResponse; }
|
|
57
71
|
});
|
|
58
72
|
Object.defineProperty(exports, "MultipleChoice", {
|
|
59
73
|
enumerable: true,
|
|
60
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkNDQD3ZRY_cjs.MultipleChoice; }
|
|
61
75
|
});
|
|
62
76
|
Object.defineProperty(exports, "FillInTheBlanks", {
|
|
63
77
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkSE6WWDVW_cjs.FillInTheBlanks; }
|
|
65
79
|
});
|
|
66
80
|
Object.defineProperty(exports, "GapSelect", {
|
|
67
81
|
enumerable: true,
|
|
68
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkU3APKQ7P_cjs.GapSelect; }
|
|
69
83
|
});
|
|
70
|
-
Object.defineProperty(exports, "
|
|
84
|
+
Object.defineProperty(exports, "Dictation", {
|
|
71
85
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkWTS34S5E_cjs.Dictation; }
|
|
73
87
|
});
|
|
74
|
-
Object.defineProperty(exports, "
|
|
88
|
+
Object.defineProperty(exports, "ReadAloud", {
|
|
75
89
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunk36FTYJWJ_cjs.ReadAloud; }
|
|
77
91
|
});
|
|
78
|
-
Object.defineProperty(exports, "
|
|
92
|
+
Object.defineProperty(exports, "PronunciationFeedback", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () { return chunkF4TBCRGI_cjs.PronunciationFeedback; }
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "CAPTURE_PROCESSOR_SOURCE", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () { return chunkUDCQTOVU_cjs.CAPTURE_PROCESSOR_SOURCE; }
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, "useSpeechRecorder", {
|
|
79
101
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkUDCQTOVU_cjs.useSpeechRecorder; }
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "useActivityState", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () { return chunkXOR4MPEN_cjs.useActivityState; }
|
|
81
107
|
});
|
|
82
108
|
Object.defineProperty(exports, "DEFAULT_STRINGS", {
|
|
83
109
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkLB3FEV7Z_cjs.DEFAULT_STRINGS; }
|
|
85
111
|
});
|
|
86
112
|
Object.defineProperty(exports, "LkIntlProvider", {
|
|
87
113
|
enumerable: true,
|
|
88
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkLB3FEV7Z_cjs.LkIntlProvider; }
|
|
89
115
|
});
|
|
90
116
|
Object.defineProperty(exports, "directionForLocale", {
|
|
91
117
|
enumerable: true,
|
|
92
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkLB3FEV7Z_cjs.directionForLocale; }
|
|
93
119
|
});
|
|
94
120
|
Object.defineProperty(exports, "mergeStrings", {
|
|
95
121
|
enumerable: true,
|
|
96
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkLB3FEV7Z_cjs.mergeStrings; }
|
|
97
123
|
});
|
|
98
124
|
Object.defineProperty(exports, "useLkDirection", {
|
|
99
125
|
enumerable: true,
|
|
100
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkLB3FEV7Z_cjs.useLkDirection; }
|
|
101
127
|
});
|
|
102
128
|
Object.defineProperty(exports, "useLkStrings", {
|
|
103
129
|
enumerable: true,
|
|
104
|
-
get: function () { return
|
|
130
|
+
get: function () { return chunkLB3FEV7Z_cjs.useLkStrings; }
|
|
105
131
|
});
|
|
106
132
|
exports.asRenderable = asRenderable;
|
|
107
133
|
exports.asRenderableSequence = asRenderableSequence;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA6LO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AA6BO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.cjs","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n MediaPlayClaim,\n MediaPlayGrant,\n MediaPlayLedgerEntry,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\nimport type { LkStringsOverride } from '../i18n/strings.js';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, and the only behaviour before `renderMode` existed):\n * the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `promptHtml`, and a\n * stimulus's `bodyHtml`). The SDK deliberately ships NO sanitiser — that would\n * add a dependency and, worse, a false promise. Rich text is rendered only when\n * you supply this function; without it the component falls back to the\n * plain-text field, which is always escaped. Fail-safe by construction: the SDK\n * never injects HTML it was not explicitly given a sanitiser for.\n *\n * `FillInTheBlanks.passageHtml` is the one exception, and is **never**\n * rendered: the passage hosts the answer inputs, so it cannot be split at the\n * `{{blank}}` placeholders without voiding the sanitiser. The plain `passage`\n * is always used, and passing `passageHtml` warns in development.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither to keep the pre-2.1.0 behaviour, where\n * the component owns the answer outright.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /**\n * Mount the component as already submitted — read at mount only, like any\n * `default*` prop.\n *\n * Restoring an attempt without it reopens a question the learner had already\n * submitted as answerable, so on a summative paper they can change and\n * re-submit it. `AttemptState.submittedSlotIds` is what this consumes.\n */\n defaultSubmitted?: boolean;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n /**\n * Binds this activity's own `data.media` to a play budget the consumer\n * persists. Usually supplied by `<ActivitySequence mediaBudget={…}>`; pass it\n * yourself when rendering an activity standalone.\n */\n mediaBudget?: MediaBudgetBinding;\n /** Translations for the audio transport chrome. See {@link MediaTransportStrings}. */\n mediaStrings?: Partial<MediaTransportStrings>;\n /**\n * Overrides the SDK's chrome text for this activity, layered on whatever\n * `LkIntlProvider` supplies. `mediaStrings` still works and is merged after\n * this, so an existing 0.8.x call site keeps behaving as it did.\n */\n strings?: LkStringsOverride;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n /**\n * BCP 47 tag stamped as `lang` on this component's root. This is the\n * INTERFACE language — the SDK's own chrome renders inside that element — so\n * it should carry the same value you give `<LkIntlProvider locale>`. Passing\n * a different one re-declares the language of every SDK string in this\n * subtree without changing the words.\n *\n * It is NOT `data.locale`, which labels xAPI statements only. Authored\n * content in another language belongs on `stimulus.locale`, which\n * `<StimulusPanel>` puts on the passage alone.\n */\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n *\n * Per-type redacted interfaces (`RedactedMultipleChoiceData`, …) ship from\n * lk-core since 0.6.0, but they are not yet *assignable* to `data`:\n * {@link Renderable} widens `scoringStrategy` and leaves nested answer-key\n * fields (`options[].isCorrect`, `blanks[].acceptedAnswers`) required, so a\n * real redacted payload still needs this bridge. Closing that gap is tracked\n * in the roadmap.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key, and\n * all three built-in activities throw at render in the default `practice` mode\n * rather than fail later: `<MultipleChoice>` and `<FillInTheBlanks>` because\n * they grade locally, and `<WrittenResponse>` because `practice` still runs its\n * local submit path and emits a practice-mode xAPI statement.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n\n/**\n * Every word the SDK's audio transport renders.\n *\n * Words, not characters: the `m:ss / m:ss` clock is digits and punctuation and\n * is formatted by the component, because it reads identically in every locale\n * this SDK targets. The scrubber's SPOKEN value does have a word in it and does\n * have a key ({@link MediaTransportStrings.timeValue}).\n *\n * Supply them to translate it. These are the highest-stakes strings on a\n * listening paper — \"No plays remaining\" decides whether a learner believes\n * they may try again — so shipping them as untranslatable English inside a\n * Spanish panel was not acceptable. Supplying any of them also sets `lang` on\n * the transport chrome, so a screen reader does not read the SDK's own words\n * with the passage's phonetics.\n */\nexport interface MediaTransportStrings {\n play: string;\n pause: string;\n preparing: string;\n mute: string;\n unmute: string;\n volume: string;\n speed: string;\n seek: string;\n /**\n * Spoken value of the scrubber, e.g. `('1:05', '4:30') => '1:05 of 4:30'`.\n * Takes ALREADY-FORMATTED `m:ss` strings: a translation should not have to\n * reimplement the clock to change the word between them.\n */\n timeValue: (elapsed: string, duration: string) => string;\n /** e.g. `(1, 2) => '1 of 2 plays remaining'`. */\n playsRemaining: (remaining: number, max: number) => string;\n noPlaysRemaining: string;\n /** Shown before the LAST play is spent, so a stray press cannot cost it. */\n lastPlayConfirm: string;\n lastPlayStart: string;\n lastPlayCancel: string;\n seekBlocked: string;\n rateBlocked: string;\n playFailed: string;\n}\n\n/**\n * Binds ONE media block to a play budget the consumer persists.\n *\n * The SDK refuses a play; it does not remember one. Everything durable here is\n * the consuming application's — see {@link SequenceMediaBudget.onPlayConsumed}.\n */\nexport interface MediaBudgetBinding {\n /** From `slotMediaKey(slotId)` / `stimulusMediaKey(slotId)` in lk-core. */\n key: string;\n /** Plays already spent, and where playback stood. Read at mount only. */\n entry?: MediaPlayLedgerEntry;\n /** Defaults to `renderMode !== 'review'`. An explicit boolean wins either way. */\n enforced?: boolean;\n /** Slot context stamped onto the claim and the interaction event. */\n slotId: string;\n index: number;\n activityId?: string;\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. */\n strings?: Partial<MediaTransportStrings>;\n}\n\n/**\n * The pager-level half of a play budget. One prop, because it is one concept.\n */\nexport interface SequenceMediaBudget {\n /**\n * `MediaPlayLedger.entries` goes straight in. An absent key means nothing\n * spent. Read at mount, like `responses`.\n */\n plays?: Readonly<Record<string, MediaPlayLedgerEntry>>;\n /**\n * Re-seed token. Change this string and the budgets re-seed from `plays`\n * WITHOUT remounting the pager — the invigilator path (\"the audio never\n * started, give her the play back\") that would otherwise cost the learner\n * their focus, their scroll position and an unsaved answer.\n */\n resumeKey?: string;\n /** Explicit override of the default (`renderMode !== 'review'`). */\n enforced?: boolean;\n /**\n * Called the instant a play is claimed, BEFORE any audio is audible.\n *\n * Two tiers, chosen by what you return:\n *\n * - **Return nothing (optimistic).** Playback starts immediately and the\n * count is only as durable as your write. **Do not debounce this, and do\n * not batch it with the answer autosave** — an eight-second debounce is\n * exactly long enough to start a third play and hard-reload. A `pagehide`\n * beacon is a backstop, not the mechanism. A crash between this call and\n * your write landing RETURNS the play to the learner; that is the honest\n * description of what you are buying.\n * - **Return a promise (confirmed).** Playback is held — the button reads\n * \"Preparing…\" and is `aria-busy` — until it settles. Resolve with\n * `{ playsUsed }` from an ATOMIC server write (`UPDATE … SET plays = plays\n * + 1 … RETURNING plays`, or a compare-and-set on\n * `claim.previousPlaysUsed`). A resolved count above `maxPlays` refuses the\n * play, which is how a second tab is caught: two mounts both seeded at 0\n * both claim 1, and only an atomic increment can tell them apart. A\n * rejection charges nothing and lets the learner retry. This is the only\n * tier in which \"consumed before audible\" is true of storage rather than\n * only of memory; use it for summative papers.\n *\n * Never settle the promise and the learner cannot play at all: settle it.\n */\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n /**\n * Called when a charged play produced no audio — the element errored before\n * playback advanced past 0.25 s, an expired signed URL being the realistic\n * cause. Supply it to give the play back, decrementing with a compare-and-set\n * on `claim.playsUsed`. Omit it and the play stays spent: the SDK will not\n * decrement a ledger it has no channel to correct.\n */\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n /**\n * Position reports, so a refresh resumes the play the learner already paid\n * for instead of charging them again. Fires on pause, on end (with 0), and at\n * most once per whole second of playback.\n *\n * **This one you MAY throttle** — the granularity you persist is the\n * granularity of the replay a crash grants. Three seconds is sane; three\n * minutes is not.\n */\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. Defaults are English. */\n strings?: Partial<MediaTransportStrings>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkMO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AAoCO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.cjs","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n MediaPlayClaim,\n MediaPlayGrant,\n MediaPlayLedgerEntry,\n RecordingRef,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\nimport type { RecordedTake } from '../hooks/useSpeechRecorder.js';\nimport type { LkStringsOverride } from '../i18n/strings.js';\nimport type { ReadAloudAssessResult } from './ReadAloud/ReadAloud.js';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, and the only behaviour before `renderMode` existed):\n * the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `promptHtml`, and a\n * stimulus's `bodyHtml`). The SDK deliberately ships NO sanitiser — that would\n * add a dependency and, worse, a false promise. Rich text is rendered only when\n * you supply this function; without it the component falls back to the\n * plain-text field, which is always escaped. Fail-safe by construction: the SDK\n * never injects HTML it was not explicitly given a sanitiser for.\n *\n * `FillInTheBlanks.passageHtml` is the one exception, and is **never**\n * rendered: the passage hosts the answer inputs, so it cannot be split at the\n * `{{blank}}` placeholders without voiding the sanitiser. The plain `passage`\n * is always used, and passing `passageHtml` warns in development.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither to keep the pre-2.1.0 behaviour, where\n * the component owns the answer outright.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /**\n * Mount the component as already submitted — read at mount only, like any\n * `default*` prop.\n *\n * Restoring an attempt without it reopens a question the learner had already\n * submitted as answerable, so on a summative paper they can change and\n * re-submit it. `AttemptState.submittedSlotIds` is what this consumes.\n */\n defaultSubmitted?: boolean;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n /**\n * Binds this activity's own `data.media` to a play budget the consumer\n * persists. Usually supplied by `<ActivitySequence mediaBudget={…}>`; pass it\n * yourself when rendering an activity standalone.\n */\n mediaBudget?: MediaBudgetBinding;\n /** Translations for the audio transport chrome. See {@link MediaTransportStrings}. */\n mediaStrings?: Partial<MediaTransportStrings>;\n /**\n * Overrides the SDK's chrome text for this activity, layered on whatever\n * `LkIntlProvider` supplies. `mediaStrings` still works and is merged after\n * this, so an existing 0.8.x call site keeps behaving as it did.\n */\n strings?: LkStringsOverride;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n /**\n * BCP 47 tag stamped as `lang` on this component's root. This is the\n * INTERFACE language — the SDK's own chrome renders inside that element — so\n * it should carry the same value you give `<LkIntlProvider locale>`. Passing\n * a different one re-declares the language of every SDK string in this\n * subtree without changing the words.\n *\n * It is NOT `data.locale`, which labels xAPI statements — and, on a\n * dictation, places the dictation's own words: `<Dictation>` puts it, and\n * the direction it names, on its title, hints, marks and solution. Other\n * authored content in another language belongs on `stimulus.locale`, which\n * `<StimulusPanel>` puts on the passage alone.\n */\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n *\n * Per-type redacted interfaces (`RedactedMultipleChoiceData`, …) ship from\n * lk-core since 0.6.0, but they are not yet *assignable* to `data`:\n * {@link Renderable} widens `scoringStrategy` and leaves nested answer-key\n * fields (`options[].isCorrect`, `blanks[].acceptedAnswers`) required, so a\n * real redacted payload still needs this bridge. Closing that gap is tracked\n * in the roadmap.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key, and\n * almost every built-in activity throws at render in the default `practice`\n * mode rather than fail later: `<MultipleChoice>`, `<FillInTheBlanks>`,\n * `<GapSelect>` and `<Dictation>` because they grade locally, and\n * `<WrittenResponse>` because `practice` still runs its local submit path and\n * emits a practice-mode xAPI statement.\n *\n * `<ReadAloud>` is the exception and renders a projection in every mode: a\n * read-aloud item has no answer key to withhold, so `redact()` removes only the\n * authored feedback and leaves the reading, its language and its bounds — which\n * is everything the component puts on screen. It grades nothing locally either;\n * the grade comes back from whatever the application asked to judge the take.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n\n/**\n * Every word the SDK's audio transport renders.\n *\n * Words, not characters: the `m:ss / m:ss` clock is digits and punctuation and\n * is formatted by the component, because it reads identically in every locale\n * this SDK targets. The scrubber's SPOKEN value does have a word in it and does\n * have a key ({@link MediaTransportStrings.timeValue}).\n *\n * Supply them to translate it. These are the highest-stakes strings on a\n * listening paper — \"No plays remaining\" decides whether a learner believes\n * they may try again — so shipping them as untranslatable English inside a\n * Spanish panel was not acceptable. Supplying any of them also sets `lang` on\n * the transport chrome, so a screen reader does not read the SDK's own words\n * with the passage's phonetics.\n */\nexport interface MediaTransportStrings {\n play: string;\n pause: string;\n preparing: string;\n mute: string;\n unmute: string;\n volume: string;\n speed: string;\n seek: string;\n /**\n * Spoken value of the scrubber, e.g. `('1:05', '4:30') => '1:05 of 4:30'`.\n * Takes ALREADY-FORMATTED `m:ss` strings: a translation should not have to\n * reimplement the clock to change the word between them.\n */\n timeValue: (elapsed: string, duration: string) => string;\n /** e.g. `(1, 2) => '1 of 2 plays remaining'`. */\n playsRemaining: (remaining: number, max: number) => string;\n noPlaysRemaining: string;\n /** Shown before the LAST play is spent, so a stray press cannot cost it. */\n lastPlayConfirm: string;\n lastPlayStart: string;\n lastPlayCancel: string;\n seekBlocked: string;\n rateBlocked: string;\n playFailed: string;\n}\n\n/**\n * Binds ONE media block to a play budget the consumer persists.\n *\n * The SDK refuses a play; it does not remember one. Everything durable here is\n * the consuming application's — see {@link SequenceMediaBudget.onPlayConsumed}.\n */\nexport interface MediaBudgetBinding {\n /** From `slotMediaKey(slotId)` / `stimulusMediaKey(slotId)` in lk-core. */\n key: string;\n /** Plays already spent, and where playback stood. Read at mount only. */\n entry?: MediaPlayLedgerEntry;\n /** Defaults to `renderMode !== 'review'`. An explicit boolean wins either way. */\n enforced?: boolean;\n /** Slot context stamped onto the claim and the interaction event. */\n slotId: string;\n index: number;\n activityId?: string;\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. */\n strings?: Partial<MediaTransportStrings>;\n}\n\n/**\n * The pager-level half of a play budget. One prop, because it is one concept.\n */\nexport interface SequenceMediaBudget {\n /**\n * `MediaPlayLedger.entries` goes straight in. An absent key means nothing\n * spent. Read at mount, like `responses`.\n */\n plays?: Readonly<Record<string, MediaPlayLedgerEntry>>;\n /**\n * Re-seed token. Change this string and the budgets re-seed from `plays`\n * WITHOUT remounting the pager — the invigilator path (\"the audio never\n * started, give her the play back\") that would otherwise cost the learner\n * their focus, their scroll position and an unsaved answer.\n */\n resumeKey?: string;\n /** Explicit override of the default (`renderMode !== 'review'`). */\n enforced?: boolean;\n /**\n * Called the instant a play is claimed, BEFORE any audio is audible.\n *\n * Two tiers, chosen by what you return:\n *\n * - **Return nothing (optimistic).** Playback starts immediately and the\n * count is only as durable as your write. **Do not debounce this, and do\n * not batch it with the answer autosave** — an eight-second debounce is\n * exactly long enough to start a third play and hard-reload. A `pagehide`\n * beacon is a backstop, not the mechanism. A crash between this call and\n * your write landing RETURNS the play to the learner; that is the honest\n * description of what you are buying.\n * - **Return a promise (confirmed).** Playback is held — the button reads\n * \"Preparing…\" and is `aria-busy` — until it settles. Resolve with\n * `{ playsUsed }` from an ATOMIC server write (`UPDATE … SET plays = plays\n * + 1 … RETURNING plays`, or a compare-and-set on\n * `claim.previousPlaysUsed`). A resolved count above `maxPlays` refuses the\n * play, which is how a second tab is caught: two mounts both seeded at 0\n * both claim 1, and only an atomic increment can tell them apart. A\n * rejection charges nothing and lets the learner retry. This is the only\n * tier in which \"consumed before audible\" is true of storage rather than\n * only of memory; use it for summative papers.\n *\n * Never settle the promise and the learner cannot play at all: settle it.\n */\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n /**\n * Called when a charged play produced no audio — the element errored before\n * playback advanced past 0.25 s, an expired signed URL being the realistic\n * cause. Supply it to give the play back, decrementing with a compare-and-set\n * on `claim.playsUsed`. Omit it and the play stays spent: the SDK will not\n * decrement a ledger it has no channel to correct.\n */\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n /**\n * Position reports, so a refresh resumes the play the learner already paid\n * for instead of charging them again. Fires on pause, on end (with 0), and at\n * most once per whole second of playback.\n *\n * **This one you MAY throttle** — the granularity you persist is the\n * granularity of the replay a crash grants. Three seconds is sane; three\n * minutes is not.\n */\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. Defaults are English. */\n strings?: Partial<MediaTransportStrings>;\n}\n\n/**\n * Which slot a recording belongs to, stamped on every call the pager makes.\n *\n * Exactly the shape {@link ActivitySequenceProps.onSubmit} already passes, so\n * one identity travels with the answer and with the take that answer points at\n * — and a consumer writes `slotId` in both places rather than reconciling two\n * spellings of \"which question was this\".\n */\nexport interface SequenceRecordingSlot {\n /** Identity from `flattenSequence` — stable under shuffling. Store against THIS. */\n slotId: string;\n /** Presented position, which moves under shuffling. */\n index: number;\n activityId: string;\n}\n\n/**\n * The pager-level half of a read-aloud recording binding: where every take in\n * this sequence is stored, and how a judgement comes back.\n *\n * One prop at both levels, because it is one concept — the media-budget\n * precedent ({@link SequenceMediaBudget} beside {@link MediaBudgetBinding}).\n * The difference is the second argument: a per-slot binding knows which slot it\n * belongs to, so a sequence-level one is told.\n *\n * The SDK records and hands over; it never judges. `assess` is `practice` only\n * and optional — a sequence that only stores takes gets the \"assessment is not\n * available\" notice rather than a throw — and `playbackUrl` is `review` only.\n * A slot whose activity is not a read-aloud never calls any of them.\n */\nexport interface SequenceRecordingBinding {\n /**\n * Puts the take in your storage and returns its key. **Required** outside\n * `review`: without it a learner can speak into a control that submits\n * nothing, which the component refuses to render. Settle it.\n */\n upload(take: RecordedTake, slot: SequenceRecordingSlot): Promise<RecordingRef>;\n /** Judges the stored take. `practice` only; an exam never assesses on the client. */\n assess?(ref: RecordingRef, slot: SequenceRecordingSlot): Promise<ReadAloudAssessResult>;\n /** A playable link to a stored take. `review` only. */\n playbackUrl?(ref: RecordingRef, slot: SequenceRecordingSlot): Promise<string>;\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
export { ActivityPreview, ActivityPreviewProps } from './components/ActivityPreview.cjs';
|
|
2
2
|
export { ActivityRenderer, ActivitySequence, ActivitySequenceProps, SequenceItemOutcome } from './components/ActivitySequence.cjs';
|
|
3
|
+
export { Dictation, DictationProps } from './components/Dictation.cjs';
|
|
3
4
|
export { FillInTheBlanks, FillInTheBlanksProps } from './components/FillInTheBlanks.cjs';
|
|
4
5
|
export { GapSelect, GapSelectProps } from './components/GapSelect.cjs';
|
|
5
6
|
export { MultipleChoice, MultipleChoiceProps } from './components/MultipleChoice.cjs';
|
|
7
|
+
export { PronunciationFeedback, PronunciationFeedbackProps } from './components/PronunciationFeedback.cjs';
|
|
8
|
+
export { ReadAloud } from './components/ReadAloud.cjs';
|
|
6
9
|
export { StimulusPanel, StimulusPanelProps } from './components/StimulusPanel.cjs';
|
|
7
|
-
export { A as ActivityProps, D as DEFAULT_STRINGS, H as HtmlSanitizer, L as LkStrings, a as LkStringsOverride, M as MediaBudgetBinding, b as MediaTransportStrings, R as
|
|
10
|
+
export { A as ActivityProps, D as DEFAULT_STRINGS, H as HtmlSanitizer, L as LkStrings, a as LkStringsOverride, M as MediaBudgetBinding, b as MediaTransportStrings, R as ReadAloudAssessResult, c as ReadAloudProps, d as RecordingBinding, e as RenderMode, f as Renderable, g as RenderableActivity, S as SequenceMediaBudget, h as SequenceRecordingBinding, i as SequenceRecordingSlot, j as asRenderable, k as asRenderableSequence, m as mergeStrings } from './strings--ADnHcaA.cjs';
|
|
8
11
|
export { WrittenResponse } from './components/WrittenResponse.cjs';
|
|
9
12
|
export { ActivityState, UseActivityStateResult, useActivityState } from './hooks/useActivityState.cjs';
|
|
13
|
+
export { CAPTURE_PROCESSOR_SOURCE, SpeechRecorder, SpeechRecorderOptions, useSpeechRecorder } from './hooks/useSpeechRecorder.cjs';
|
|
10
14
|
export { UseXAPIResult, useXAPI } from './hooks/useXAPI.cjs';
|
|
11
15
|
export { LkDirection, LkIntlProvider, LkIntlProviderProps, directionForLocale, useLkDirection, useLkStrings } from './i18n/LkIntlProvider.cjs';
|
|
12
16
|
export { TailwindThemeExtension, ThemeProvider, ThemeProviderProps, createTailwindTheme, darkTheme, defaultTheme, useTheme } from './theme/ThemeProvider.cjs';
|
|
13
|
-
export {
|
|
17
|
+
export { R as RecordedTake, S as SpeechRecorderError, a as SpeechRecorderStatus } from './machine-CuwKqWXC.cjs';
|
|
18
|
+
export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-pB1ik8hg.cjs';
|
|
14
19
|
import 'react/jsx-runtime';
|
|
15
20
|
import '@intellectif/lk-core';
|
|
16
21
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
export { ActivityPreview, ActivityPreviewProps } from './components/ActivityPreview.js';
|
|
2
2
|
export { ActivityRenderer, ActivitySequence, ActivitySequenceProps, SequenceItemOutcome } from './components/ActivitySequence.js';
|
|
3
|
+
export { Dictation, DictationProps } from './components/Dictation.js';
|
|
3
4
|
export { FillInTheBlanks, FillInTheBlanksProps } from './components/FillInTheBlanks.js';
|
|
4
5
|
export { GapSelect, GapSelectProps } from './components/GapSelect.js';
|
|
5
6
|
export { MultipleChoice, MultipleChoiceProps } from './components/MultipleChoice.js';
|
|
7
|
+
export { PronunciationFeedback, PronunciationFeedbackProps } from './components/PronunciationFeedback.js';
|
|
8
|
+
export { ReadAloud } from './components/ReadAloud.js';
|
|
6
9
|
export { StimulusPanel, StimulusPanelProps } from './components/StimulusPanel.js';
|
|
7
|
-
export { A as ActivityProps, D as DEFAULT_STRINGS, H as HtmlSanitizer, L as LkStrings, a as LkStringsOverride, M as MediaBudgetBinding, b as MediaTransportStrings, R as
|
|
10
|
+
export { A as ActivityProps, D as DEFAULT_STRINGS, H as HtmlSanitizer, L as LkStrings, a as LkStringsOverride, M as MediaBudgetBinding, b as MediaTransportStrings, R as ReadAloudAssessResult, c as ReadAloudProps, d as RecordingBinding, e as RenderMode, f as Renderable, g as RenderableActivity, S as SequenceMediaBudget, h as SequenceRecordingBinding, i as SequenceRecordingSlot, j as asRenderable, k as asRenderableSequence, m as mergeStrings } from './strings-CtdSf2St.js';
|
|
8
11
|
export { WrittenResponse } from './components/WrittenResponse.js';
|
|
9
12
|
export { ActivityState, UseActivityStateResult, useActivityState } from './hooks/useActivityState.js';
|
|
13
|
+
export { CAPTURE_PROCESSOR_SOURCE, SpeechRecorder, SpeechRecorderOptions, useSpeechRecorder } from './hooks/useSpeechRecorder.js';
|
|
10
14
|
export { UseXAPIResult, useXAPI } from './hooks/useXAPI.js';
|
|
11
15
|
export { LkDirection, LkIntlProvider, LkIntlProviderProps, directionForLocale, useLkDirection, useLkStrings } from './i18n/LkIntlProvider.js';
|
|
12
16
|
export { TailwindThemeExtension, ThemeProvider, ThemeProviderProps, createTailwindTheme, darkTheme, defaultTheme, useTheme } from './theme/ThemeProvider.js';
|
|
13
|
-
export {
|
|
17
|
+
export { R as RecordedTake, S as SpeechRecorderError, a as SpeechRecorderStatus } from './machine-CuwKqWXC.js';
|
|
18
|
+
export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-C0P34En1.js';
|
|
14
19
|
import 'react/jsx-runtime';
|
|
15
20
|
import '@intellectif/lk-core';
|
|
16
21
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
export { useXAPI } from './chunk-2TW6WLBC.js';
|
|
3
|
-
export { ThemeProvider, createTailwindTheme, darkTheme, defaultTheme, useTheme } from './chunk-
|
|
4
|
-
export { ActivityPreview } from './chunk-
|
|
5
|
-
export { ActivitySequence } from './chunk-
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
|
|
3
|
+
export { ThemeProvider, createTailwindTheme, darkTheme, defaultTheme, useTheme } from './chunk-RXS455MR.js';
|
|
4
|
+
export { ActivityPreview } from './chunk-YMBBM5K7.js';
|
|
5
|
+
export { ActivitySequence } from './chunk-I33FOKZ7.js';
|
|
6
|
+
export { StimulusPanel } from './chunk-SWY6PWXK.js';
|
|
7
|
+
export { WrittenResponse } from './chunk-LLXCX5KK.js';
|
|
8
|
+
export { MultipleChoice } from './chunk-LGCUOLP6.js';
|
|
9
|
+
export { FillInTheBlanks } from './chunk-72UGRIMM.js';
|
|
10
|
+
export { GapSelect } from './chunk-XUEIUEPI.js';
|
|
11
|
+
export { Dictation } from './chunk-47HHC4GD.js';
|
|
12
|
+
export { ReadAloud } from './chunk-D57QZILZ.js';
|
|
13
|
+
export { PronunciationFeedback } from './chunk-62AKSD5Y.js';
|
|
14
|
+
export { CAPTURE_PROCESSOR_SOURCE, useSpeechRecorder } from './chunk-MCO52PV5.js';
|
|
15
|
+
import './chunk-YORQQXGO.js';
|
|
16
|
+
import './chunk-RCMYEWBE.js';
|
|
17
|
+
import './chunk-BO6P723E.js';
|
|
18
|
+
import './chunk-XIBOFTOL.js';
|
|
11
19
|
export { useActivityState } from './chunk-6N43WDVG.js';
|
|
12
|
-
export {
|
|
13
|
-
import './chunk-2Y6V5E7H.js';
|
|
14
|
-
export { DEFAULT_STRINGS, LkIntlProvider, directionForLocale, mergeStrings, useLkDirection, useLkStrings } from './chunk-CK7Z275S.js';
|
|
20
|
+
export { DEFAULT_STRINGS, LkIntlProvider, directionForLocale, mergeStrings, useLkDirection, useLkStrings } from './chunk-TDJEKXEP.js';
|
|
15
21
|
|
|
16
22
|
// src/components/types.ts
|
|
17
23
|
function asRenderable(redacted) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6LO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AA6BO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n MediaPlayClaim,\n MediaPlayGrant,\n MediaPlayLedgerEntry,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\nimport type { LkStringsOverride } from '../i18n/strings.js';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, and the only behaviour before `renderMode` existed):\n * the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `promptHtml`, and a\n * stimulus's `bodyHtml`). The SDK deliberately ships NO sanitiser — that would\n * add a dependency and, worse, a false promise. Rich text is rendered only when\n * you supply this function; without it the component falls back to the\n * plain-text field, which is always escaped. Fail-safe by construction: the SDK\n * never injects HTML it was not explicitly given a sanitiser for.\n *\n * `FillInTheBlanks.passageHtml` is the one exception, and is **never**\n * rendered: the passage hosts the answer inputs, so it cannot be split at the\n * `{{blank}}` placeholders without voiding the sanitiser. The plain `passage`\n * is always used, and passing `passageHtml` warns in development.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither to keep the pre-2.1.0 behaviour, where\n * the component owns the answer outright.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /**\n * Mount the component as already submitted — read at mount only, like any\n * `default*` prop.\n *\n * Restoring an attempt without it reopens a question the learner had already\n * submitted as answerable, so on a summative paper they can change and\n * re-submit it. `AttemptState.submittedSlotIds` is what this consumes.\n */\n defaultSubmitted?: boolean;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n /**\n * Binds this activity's own `data.media` to a play budget the consumer\n * persists. Usually supplied by `<ActivitySequence mediaBudget={…}>`; pass it\n * yourself when rendering an activity standalone.\n */\n mediaBudget?: MediaBudgetBinding;\n /** Translations for the audio transport chrome. See {@link MediaTransportStrings}. */\n mediaStrings?: Partial<MediaTransportStrings>;\n /**\n * Overrides the SDK's chrome text for this activity, layered on whatever\n * `LkIntlProvider` supplies. `mediaStrings` still works and is merged after\n * this, so an existing 0.8.x call site keeps behaving as it did.\n */\n strings?: LkStringsOverride;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n /**\n * BCP 47 tag stamped as `lang` on this component's root. This is the\n * INTERFACE language — the SDK's own chrome renders inside that element — so\n * it should carry the same value you give `<LkIntlProvider locale>`. Passing\n * a different one re-declares the language of every SDK string in this\n * subtree without changing the words.\n *\n * It is NOT `data.locale`, which labels xAPI statements only. Authored\n * content in another language belongs on `stimulus.locale`, which\n * `<StimulusPanel>` puts on the passage alone.\n */\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n *\n * Per-type redacted interfaces (`RedactedMultipleChoiceData`, …) ship from\n * lk-core since 0.6.0, but they are not yet *assignable* to `data`:\n * {@link Renderable} widens `scoringStrategy` and leaves nested answer-key\n * fields (`options[].isCorrect`, `blanks[].acceptedAnswers`) required, so a\n * real redacted payload still needs this bridge. Closing that gap is tracked\n * in the roadmap.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key, and\n * all three built-in activities throw at render in the default `practice` mode\n * rather than fail later: `<MultipleChoice>` and `<FillInTheBlanks>` because\n * they grade locally, and `<WrittenResponse>` because `practice` still runs its\n * local submit path and emits a practice-mode xAPI statement.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n\n/**\n * Every word the SDK's audio transport renders.\n *\n * Words, not characters: the `m:ss / m:ss` clock is digits and punctuation and\n * is formatted by the component, because it reads identically in every locale\n * this SDK targets. The scrubber's SPOKEN value does have a word in it and does\n * have a key ({@link MediaTransportStrings.timeValue}).\n *\n * Supply them to translate it. These are the highest-stakes strings on a\n * listening paper — \"No plays remaining\" decides whether a learner believes\n * they may try again — so shipping them as untranslatable English inside a\n * Spanish panel was not acceptable. Supplying any of them also sets `lang` on\n * the transport chrome, so a screen reader does not read the SDK's own words\n * with the passage's phonetics.\n */\nexport interface MediaTransportStrings {\n play: string;\n pause: string;\n preparing: string;\n mute: string;\n unmute: string;\n volume: string;\n speed: string;\n seek: string;\n /**\n * Spoken value of the scrubber, e.g. `('1:05', '4:30') => '1:05 of 4:30'`.\n * Takes ALREADY-FORMATTED `m:ss` strings: a translation should not have to\n * reimplement the clock to change the word between them.\n */\n timeValue: (elapsed: string, duration: string) => string;\n /** e.g. `(1, 2) => '1 of 2 plays remaining'`. */\n playsRemaining: (remaining: number, max: number) => string;\n noPlaysRemaining: string;\n /** Shown before the LAST play is spent, so a stray press cannot cost it. */\n lastPlayConfirm: string;\n lastPlayStart: string;\n lastPlayCancel: string;\n seekBlocked: string;\n rateBlocked: string;\n playFailed: string;\n}\n\n/**\n * Binds ONE media block to a play budget the consumer persists.\n *\n * The SDK refuses a play; it does not remember one. Everything durable here is\n * the consuming application's — see {@link SequenceMediaBudget.onPlayConsumed}.\n */\nexport interface MediaBudgetBinding {\n /** From `slotMediaKey(slotId)` / `stimulusMediaKey(slotId)` in lk-core. */\n key: string;\n /** Plays already spent, and where playback stood. Read at mount only. */\n entry?: MediaPlayLedgerEntry;\n /** Defaults to `renderMode !== 'review'`. An explicit boolean wins either way. */\n enforced?: boolean;\n /** Slot context stamped onto the claim and the interaction event. */\n slotId: string;\n index: number;\n activityId?: string;\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. */\n strings?: Partial<MediaTransportStrings>;\n}\n\n/**\n * The pager-level half of a play budget. One prop, because it is one concept.\n */\nexport interface SequenceMediaBudget {\n /**\n * `MediaPlayLedger.entries` goes straight in. An absent key means nothing\n * spent. Read at mount, like `responses`.\n */\n plays?: Readonly<Record<string, MediaPlayLedgerEntry>>;\n /**\n * Re-seed token. Change this string and the budgets re-seed from `plays`\n * WITHOUT remounting the pager — the invigilator path (\"the audio never\n * started, give her the play back\") that would otherwise cost the learner\n * their focus, their scroll position and an unsaved answer.\n */\n resumeKey?: string;\n /** Explicit override of the default (`renderMode !== 'review'`). */\n enforced?: boolean;\n /**\n * Called the instant a play is claimed, BEFORE any audio is audible.\n *\n * Two tiers, chosen by what you return:\n *\n * - **Return nothing (optimistic).** Playback starts immediately and the\n * count is only as durable as your write. **Do not debounce this, and do\n * not batch it with the answer autosave** — an eight-second debounce is\n * exactly long enough to start a third play and hard-reload. A `pagehide`\n * beacon is a backstop, not the mechanism. A crash between this call and\n * your write landing RETURNS the play to the learner; that is the honest\n * description of what you are buying.\n * - **Return a promise (confirmed).** Playback is held — the button reads\n * \"Preparing…\" and is `aria-busy` — until it settles. Resolve with\n * `{ playsUsed }` from an ATOMIC server write (`UPDATE … SET plays = plays\n * + 1 … RETURNING plays`, or a compare-and-set on\n * `claim.previousPlaysUsed`). A resolved count above `maxPlays` refuses the\n * play, which is how a second tab is caught: two mounts both seeded at 0\n * both claim 1, and only an atomic increment can tell them apart. A\n * rejection charges nothing and lets the learner retry. This is the only\n * tier in which \"consumed before audible\" is true of storage rather than\n * only of memory; use it for summative papers.\n *\n * Never settle the promise and the learner cannot play at all: settle it.\n */\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n /**\n * Called when a charged play produced no audio — the element errored before\n * playback advanced past 0.25 s, an expired signed URL being the realistic\n * cause. Supply it to give the play back, decrementing with a compare-and-set\n * on `claim.playsUsed`. Omit it and the play stays spent: the SDK will not\n * decrement a ledger it has no channel to correct.\n */\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n /**\n * Position reports, so a refresh resumes the play the learner already paid\n * for instead of charging them again. Fires on pause, on end (with 0), and at\n * most once per whole second of playback.\n *\n * **This one you MAY throttle** — the granularity you persist is the\n * granularity of the replay a crash grants. Three seconds is sane; three\n * minutes is not.\n */\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. Defaults are English. */\n strings?: Partial<MediaTransportStrings>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkMO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AAoCO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n MediaPlayClaim,\n MediaPlayGrant,\n MediaPlayLedgerEntry,\n RecordingRef,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\nimport type { RecordedTake } from '../hooks/useSpeechRecorder.js';\nimport type { LkStringsOverride } from '../i18n/strings.js';\nimport type { ReadAloudAssessResult } from './ReadAloud/ReadAloud.js';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, and the only behaviour before `renderMode` existed):\n * the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `promptHtml`, and a\n * stimulus's `bodyHtml`). The SDK deliberately ships NO sanitiser — that would\n * add a dependency and, worse, a false promise. Rich text is rendered only when\n * you supply this function; without it the component falls back to the\n * plain-text field, which is always escaped. Fail-safe by construction: the SDK\n * never injects HTML it was not explicitly given a sanitiser for.\n *\n * `FillInTheBlanks.passageHtml` is the one exception, and is **never**\n * rendered: the passage hosts the answer inputs, so it cannot be split at the\n * `{{blank}}` placeholders without voiding the sanitiser. The plain `passage`\n * is always used, and passing `passageHtml` warns in development.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither to keep the pre-2.1.0 behaviour, where\n * the component owns the answer outright.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /**\n * Mount the component as already submitted — read at mount only, like any\n * `default*` prop.\n *\n * Restoring an attempt without it reopens a question the learner had already\n * submitted as answerable, so on a summative paper they can change and\n * re-submit it. `AttemptState.submittedSlotIds` is what this consumes.\n */\n defaultSubmitted?: boolean;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n /**\n * Binds this activity's own `data.media` to a play budget the consumer\n * persists. Usually supplied by `<ActivitySequence mediaBudget={…}>`; pass it\n * yourself when rendering an activity standalone.\n */\n mediaBudget?: MediaBudgetBinding;\n /** Translations for the audio transport chrome. See {@link MediaTransportStrings}. */\n mediaStrings?: Partial<MediaTransportStrings>;\n /**\n * Overrides the SDK's chrome text for this activity, layered on whatever\n * `LkIntlProvider` supplies. `mediaStrings` still works and is merged after\n * this, so an existing 0.8.x call site keeps behaving as it did.\n */\n strings?: LkStringsOverride;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n /**\n * BCP 47 tag stamped as `lang` on this component's root. This is the\n * INTERFACE language — the SDK's own chrome renders inside that element — so\n * it should carry the same value you give `<LkIntlProvider locale>`. Passing\n * a different one re-declares the language of every SDK string in this\n * subtree without changing the words.\n *\n * It is NOT `data.locale`, which labels xAPI statements — and, on a\n * dictation, places the dictation's own words: `<Dictation>` puts it, and\n * the direction it names, on its title, hints, marks and solution. Other\n * authored content in another language belongs on `stimulus.locale`, which\n * `<StimulusPanel>` puts on the passage alone.\n */\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n *\n * Per-type redacted interfaces (`RedactedMultipleChoiceData`, …) ship from\n * lk-core since 0.6.0, but they are not yet *assignable* to `data`:\n * {@link Renderable} widens `scoringStrategy` and leaves nested answer-key\n * fields (`options[].isCorrect`, `blanks[].acceptedAnswers`) required, so a\n * real redacted payload still needs this bridge. Closing that gap is tracked\n * in the roadmap.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key, and\n * almost every built-in activity throws at render in the default `practice`\n * mode rather than fail later: `<MultipleChoice>`, `<FillInTheBlanks>`,\n * `<GapSelect>` and `<Dictation>` because they grade locally, and\n * `<WrittenResponse>` because `practice` still runs its local submit path and\n * emits a practice-mode xAPI statement.\n *\n * `<ReadAloud>` is the exception and renders a projection in every mode: a\n * read-aloud item has no answer key to withhold, so `redact()` removes only the\n * authored feedback and leaves the reading, its language and its bounds — which\n * is everything the component puts on screen. It grades nothing locally either;\n * the grade comes back from whatever the application asked to judge the take.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n\n/**\n * Every word the SDK's audio transport renders.\n *\n * Words, not characters: the `m:ss / m:ss` clock is digits and punctuation and\n * is formatted by the component, because it reads identically in every locale\n * this SDK targets. The scrubber's SPOKEN value does have a word in it and does\n * have a key ({@link MediaTransportStrings.timeValue}).\n *\n * Supply them to translate it. These are the highest-stakes strings on a\n * listening paper — \"No plays remaining\" decides whether a learner believes\n * they may try again — so shipping them as untranslatable English inside a\n * Spanish panel was not acceptable. Supplying any of them also sets `lang` on\n * the transport chrome, so a screen reader does not read the SDK's own words\n * with the passage's phonetics.\n */\nexport interface MediaTransportStrings {\n play: string;\n pause: string;\n preparing: string;\n mute: string;\n unmute: string;\n volume: string;\n speed: string;\n seek: string;\n /**\n * Spoken value of the scrubber, e.g. `('1:05', '4:30') => '1:05 of 4:30'`.\n * Takes ALREADY-FORMATTED `m:ss` strings: a translation should not have to\n * reimplement the clock to change the word between them.\n */\n timeValue: (elapsed: string, duration: string) => string;\n /** e.g. `(1, 2) => '1 of 2 plays remaining'`. */\n playsRemaining: (remaining: number, max: number) => string;\n noPlaysRemaining: string;\n /** Shown before the LAST play is spent, so a stray press cannot cost it. */\n lastPlayConfirm: string;\n lastPlayStart: string;\n lastPlayCancel: string;\n seekBlocked: string;\n rateBlocked: string;\n playFailed: string;\n}\n\n/**\n * Binds ONE media block to a play budget the consumer persists.\n *\n * The SDK refuses a play; it does not remember one. Everything durable here is\n * the consuming application's — see {@link SequenceMediaBudget.onPlayConsumed}.\n */\nexport interface MediaBudgetBinding {\n /** From `slotMediaKey(slotId)` / `stimulusMediaKey(slotId)` in lk-core. */\n key: string;\n /** Plays already spent, and where playback stood. Read at mount only. */\n entry?: MediaPlayLedgerEntry;\n /** Defaults to `renderMode !== 'review'`. An explicit boolean wins either way. */\n enforced?: boolean;\n /** Slot context stamped onto the claim and the interaction event. */\n slotId: string;\n index: number;\n activityId?: string;\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. */\n strings?: Partial<MediaTransportStrings>;\n}\n\n/**\n * The pager-level half of a play budget. One prop, because it is one concept.\n */\nexport interface SequenceMediaBudget {\n /**\n * `MediaPlayLedger.entries` goes straight in. An absent key means nothing\n * spent. Read at mount, like `responses`.\n */\n plays?: Readonly<Record<string, MediaPlayLedgerEntry>>;\n /**\n * Re-seed token. Change this string and the budgets re-seed from `plays`\n * WITHOUT remounting the pager — the invigilator path (\"the audio never\n * started, give her the play back\") that would otherwise cost the learner\n * their focus, their scroll position and an unsaved answer.\n */\n resumeKey?: string;\n /** Explicit override of the default (`renderMode !== 'review'`). */\n enforced?: boolean;\n /**\n * Called the instant a play is claimed, BEFORE any audio is audible.\n *\n * Two tiers, chosen by what you return:\n *\n * - **Return nothing (optimistic).** Playback starts immediately and the\n * count is only as durable as your write. **Do not debounce this, and do\n * not batch it with the answer autosave** — an eight-second debounce is\n * exactly long enough to start a third play and hard-reload. A `pagehide`\n * beacon is a backstop, not the mechanism. A crash between this call and\n * your write landing RETURNS the play to the learner; that is the honest\n * description of what you are buying.\n * - **Return a promise (confirmed).** Playback is held — the button reads\n * \"Preparing…\" and is `aria-busy` — until it settles. Resolve with\n * `{ playsUsed }` from an ATOMIC server write (`UPDATE … SET plays = plays\n * + 1 … RETURNING plays`, or a compare-and-set on\n * `claim.previousPlaysUsed`). A resolved count above `maxPlays` refuses the\n * play, which is how a second tab is caught: two mounts both seeded at 0\n * both claim 1, and only an atomic increment can tell them apart. A\n * rejection charges nothing and lets the learner retry. This is the only\n * tier in which \"consumed before audible\" is true of storage rather than\n * only of memory; use it for summative papers.\n *\n * Never settle the promise and the learner cannot play at all: settle it.\n */\n onPlayConsumed?: (claim: MediaPlayClaim) => undefined | Promise<MediaPlayGrant | undefined>;\n /**\n * Called when a charged play produced no audio — the element errored before\n * playback advanced past 0.25 s, an expired signed URL being the realistic\n * cause. Supply it to give the play back, decrementing with a compare-and-set\n * on `claim.playsUsed`. Omit it and the play stays spent: the SDK will not\n * decrement a ledger it has no channel to correct.\n */\n onPlayRefunded?: (claim: MediaPlayClaim) => void;\n /**\n * Position reports, so a refresh resumes the play the learner already paid\n * for instead of charging them again. Fires on pause, on end (with 0), and at\n * most once per whole second of playback.\n *\n * **This one you MAY throttle** — the granularity you persist is the\n * granularity of the replay a crash grants. Three seconds is sane; three\n * minutes is not.\n */\n onPosition?: (key: string, seconds: number) => void;\n /** Translations for the transport chrome. Defaults are English. */\n strings?: Partial<MediaTransportStrings>;\n}\n\n/**\n * Which slot a recording belongs to, stamped on every call the pager makes.\n *\n * Exactly the shape {@link ActivitySequenceProps.onSubmit} already passes, so\n * one identity travels with the answer and with the take that answer points at\n * — and a consumer writes `slotId` in both places rather than reconciling two\n * spellings of \"which question was this\".\n */\nexport interface SequenceRecordingSlot {\n /** Identity from `flattenSequence` — stable under shuffling. Store against THIS. */\n slotId: string;\n /** Presented position, which moves under shuffling. */\n index: number;\n activityId: string;\n}\n\n/**\n * The pager-level half of a read-aloud recording binding: where every take in\n * this sequence is stored, and how a judgement comes back.\n *\n * One prop at both levels, because it is one concept — the media-budget\n * precedent ({@link SequenceMediaBudget} beside {@link MediaBudgetBinding}).\n * The difference is the second argument: a per-slot binding knows which slot it\n * belongs to, so a sequence-level one is told.\n *\n * The SDK records and hands over; it never judges. `assess` is `practice` only\n * and optional — a sequence that only stores takes gets the \"assessment is not\n * available\" notice rather than a throw — and `playbackUrl` is `review` only.\n * A slot whose activity is not a read-aloud never calls any of them.\n */\nexport interface SequenceRecordingBinding {\n /**\n * Puts the take in your storage and returns its key. **Required** outside\n * `review`: without it a learner can speak into a control that submits\n * nothing, which the component refuses to render. Settle it.\n */\n upload(take: RecordedTake, slot: SequenceRecordingSlot): Promise<RecordingRef>;\n /** Judges the stored take. `practice` only; an exam never assesses on the client. */\n assess?(ref: RecordingRef, slot: SequenceRecordingSlot): Promise<ReadAloudAssessResult>;\n /** A playable link to a stored take. `review` only. */\n playbackUrl?(ref: RecordingRef, slot: SequenceRecordingSlot): Promise<string>;\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The recorder's state, as one pure reduction.
|
|
3
|
+
*
|
|
4
|
+
* Kept out of the hook because the hook's own work — opening a microphone,
|
|
5
|
+
* building a graph, tearing both down — is asynchronous, and a state machine
|
|
6
|
+
* spread across five callbacks is exactly where an auto-stop that races a
|
|
7
|
+
* learner's `stop()` hides. Every transition is here, synchronous and
|
|
8
|
+
* testable without a microphone; the hook only says which event happened.
|
|
9
|
+
*
|
|
10
|
+
* No transition reads a browser global, which is what lets `status`, `error`
|
|
11
|
+
* and `canRecord` be rendered on a server.
|
|
12
|
+
*/
|
|
13
|
+
/** A recording the learner has made and not yet discarded. */
|
|
14
|
+
interface RecordedTake {
|
|
15
|
+
/** Mono 16-bit PCM WAV at 16 kHz — the format `inspectWav` measures. */
|
|
16
|
+
blob: Blob;
|
|
17
|
+
mimeType: string;
|
|
18
|
+
/** The encoded recording's own length, not a wall-clock timing of the attempt. */
|
|
19
|
+
durationMs: number;
|
|
20
|
+
/** The loudest sample of the take, 0..1. */
|
|
21
|
+
peakLevel: number;
|
|
22
|
+
}
|
|
23
|
+
type SpeechRecorderStatus = 'idle' | 'requesting-permission' | 'recording' | 'recorded' | 'error';
|
|
24
|
+
type SpeechRecorderError = 'permission-denied' | 'no-device' | 'unsupported' | 'too-short' | 'failed';
|
|
25
|
+
|
|
26
|
+
export type { RecordedTake as R, SpeechRecorderError as S, SpeechRecorderStatus as a };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The recorder's state, as one pure reduction.
|
|
3
|
+
*
|
|
4
|
+
* Kept out of the hook because the hook's own work — opening a microphone,
|
|
5
|
+
* building a graph, tearing both down — is asynchronous, and a state machine
|
|
6
|
+
* spread across five callbacks is exactly where an auto-stop that races a
|
|
7
|
+
* learner's `stop()` hides. Every transition is here, synchronous and
|
|
8
|
+
* testable without a microphone; the hook only says which event happened.
|
|
9
|
+
*
|
|
10
|
+
* No transition reads a browser global, which is what lets `status`, `error`
|
|
11
|
+
* and `canRecord` be rendered on a server.
|
|
12
|
+
*/
|
|
13
|
+
/** A recording the learner has made and not yet discarded. */
|
|
14
|
+
interface RecordedTake {
|
|
15
|
+
/** Mono 16-bit PCM WAV at 16 kHz — the format `inspectWav` measures. */
|
|
16
|
+
blob: Blob;
|
|
17
|
+
mimeType: string;
|
|
18
|
+
/** The encoded recording's own length, not a wall-clock timing of the attempt. */
|
|
19
|
+
durationMs: number;
|
|
20
|
+
/** The loudest sample of the take, 0..1. */
|
|
21
|
+
peakLevel: number;
|
|
22
|
+
}
|
|
23
|
+
type SpeechRecorderStatus = 'idle' | 'requesting-permission' | 'recording' | 'recorded' | 'error';
|
|
24
|
+
type SpeechRecorderError = 'permission-denied' | 'no-device' | 'unsupported' | 'too-short' | 'failed';
|
|
25
|
+
|
|
26
|
+
export type { RecordedTake as R, SpeechRecorderError as S, SpeechRecorderStatus as a };
|