@elice/material-exercise 1.240710.0 → 1.240711.1
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.
|
@@ -81,6 +81,10 @@ const ExerciseRunner = ({
|
|
|
81
81
|
const setStdioWebSocketState = recoil.useSetRecoilState(recoil$1.exerciseWebsocketQuery('stdio'));
|
|
82
82
|
const handleAiHelpibotError = text => {
|
|
83
83
|
var _a, _b, _c;
|
|
84
|
+
// check whether error callback prop is defined
|
|
85
|
+
if (!onStdioError && !onCodeHelpRequest) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
84
88
|
const error = runner.getProgrammingErrorResult(text);
|
|
85
89
|
if (!!error && typeof onStdioError === 'function') {
|
|
86
90
|
onStdioError(error);
|
|
@@ -8,22 +8,34 @@ require('../components/material-exercise/context/recoilTypes.js');
|
|
|
8
8
|
require('../components/material-exercise/context/subjects.js');
|
|
9
9
|
require('../components/material-exercise/context/ExerciseProvider.js');
|
|
10
10
|
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
//
|
|
14
|
+
const MAX_TEXT_LENGTH = Math.pow(2, 14); // Limited length of text which regex performance is acceptable below 1s.
|
|
15
|
+
//
|
|
16
|
+
//
|
|
17
|
+
//
|
|
11
18
|
const useStdioTextConcator = done => {
|
|
12
19
|
const RUNNER_AND_STDIO_DELAY_SAFETY_FACTOR = 1000;
|
|
13
|
-
const
|
|
20
|
+
const textRef = React.useRef('');
|
|
14
21
|
const isRunning = recoil.useRecoilValue(recoil$1.exerciseRunnerRunningState);
|
|
15
22
|
React.useEffect(() => {
|
|
16
23
|
if (isRunning) {
|
|
17
|
-
|
|
24
|
+
textRef.current = '';
|
|
18
25
|
} else {
|
|
19
26
|
setTimeout(() => {
|
|
20
|
-
done(
|
|
27
|
+
done(textRef.current);
|
|
21
28
|
}, RUNNER_AND_STDIO_DELAY_SAFETY_FACTOR);
|
|
22
29
|
}
|
|
23
30
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
31
|
}, [isRunning]);
|
|
25
32
|
const updateStdioTextConcator = React.useCallback(text => {
|
|
26
|
-
|
|
33
|
+
const currentText = textRef.current;
|
|
34
|
+
if (currentText.length + text.length > MAX_TEXT_LENGTH) {
|
|
35
|
+
textRef.current = currentText.slice(0, MAX_TEXT_LENGTH - text.length) + text;
|
|
36
|
+
} else {
|
|
37
|
+
textRef.current = currentText + text;
|
|
38
|
+
}
|
|
27
39
|
}, []);
|
|
28
40
|
return {
|
|
29
41
|
updateStdioTextConcator,
|
|
@@ -77,6 +77,10 @@ const ExerciseRunner = ({
|
|
|
77
77
|
const setStdioWebSocketState = useSetRecoilState(exerciseWebsocketQuery('stdio'));
|
|
78
78
|
const handleAiHelpibotError = text => {
|
|
79
79
|
var _a, _b, _c;
|
|
80
|
+
// check whether error callback prop is defined
|
|
81
|
+
if (!onStdioError && !onCodeHelpRequest) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
80
84
|
const error = getProgrammingErrorResult(text);
|
|
81
85
|
if (!!error && typeof onStdioError === 'function') {
|
|
82
86
|
onStdioError(error);
|
|
@@ -6,22 +6,34 @@ import '../components/material-exercise/context/recoilTypes.js';
|
|
|
6
6
|
import '../components/material-exercise/context/subjects.js';
|
|
7
7
|
import '../components/material-exercise/context/ExerciseProvider.js';
|
|
8
8
|
|
|
9
|
+
//
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
const MAX_TEXT_LENGTH = Math.pow(2, 14); // Limited length of text which regex performance is acceptable below 1s.
|
|
13
|
+
//
|
|
14
|
+
//
|
|
15
|
+
//
|
|
9
16
|
const useStdioTextConcator = done => {
|
|
10
17
|
const RUNNER_AND_STDIO_DELAY_SAFETY_FACTOR = 1000;
|
|
11
|
-
const
|
|
18
|
+
const textRef = React.useRef('');
|
|
12
19
|
const isRunning = useRecoilValue(exerciseRunnerRunningState);
|
|
13
20
|
React.useEffect(() => {
|
|
14
21
|
if (isRunning) {
|
|
15
|
-
|
|
22
|
+
textRef.current = '';
|
|
16
23
|
} else {
|
|
17
24
|
setTimeout(() => {
|
|
18
|
-
done(
|
|
25
|
+
done(textRef.current);
|
|
19
26
|
}, RUNNER_AND_STDIO_DELAY_SAFETY_FACTOR);
|
|
20
27
|
}
|
|
21
28
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
29
|
}, [isRunning]);
|
|
23
30
|
const updateStdioTextConcator = React.useCallback(text => {
|
|
24
|
-
|
|
31
|
+
const currentText = textRef.current;
|
|
32
|
+
if (currentText.length + text.length > MAX_TEXT_LENGTH) {
|
|
33
|
+
textRef.current = currentText.slice(0, MAX_TEXT_LENGTH - text.length) + text;
|
|
34
|
+
} else {
|
|
35
|
+
textRef.current = currentText + text;
|
|
36
|
+
}
|
|
25
37
|
}, []);
|
|
26
38
|
return {
|
|
27
39
|
updateStdioTextConcator,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elice/material-exercise",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.240711.1",
|
|
4
4
|
"description": "User view and editing components of Elice material exercise",
|
|
5
5
|
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"@elice/icons": "^1.230814.0",
|
|
86
86
|
"@elice/intl": "0.240425.0-rc.2",
|
|
87
87
|
"@elice/markdown": "^1.220815.0",
|
|
88
|
-
"@elice/material-shared-types": "1.
|
|
89
|
-
"@elice/material-shared-utils": "1.
|
|
88
|
+
"@elice/material-shared-types": "1.240711.1",
|
|
89
|
+
"@elice/material-shared-utils": "1.240711.1",
|
|
90
90
|
"@elice/mui-elements": "^5.230825.0",
|
|
91
91
|
"@elice/mui-system": "^5.230825.0",
|
|
92
92
|
"@elice/types": "1.240709.0",
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"recoil": "^0.6.1",
|
|
117
117
|
"styled-components": "^5.2.0"
|
|
118
118
|
},
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "385d0f4773560bcdd9d8e4bcbca6cec1dedb0c64"
|
|
120
120
|
}
|