@elice/material-exercise 1.220808.0 → 1.220913.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.
@@ -79,7 +79,7 @@ const ExerciseRunnerControllerButtonGroup = () => {
79
79
  const isSubmitRunArduinoDisabled = isArduinoExercise ? arduinoUploadProgress !== 'ready' && arduinoUploadProgress !== 'error' || !arduinoOpenedPortName : false;
80
80
  const isSubmitRunDisabled = isSubmitRunHidden || isSubmitRunArduinoDisabled || isNotReady || isConnecting || isSubmitting; // submit grade
81
81
 
82
- const isSubmitGradeHidden = isRunning || isArduinoExercise;
82
+ const isSubmitGradeHidden = isRunning;
83
83
  const isSubmitGradeDisabled = isSubmitGradeHidden || exerciseWithNoGrade || isTestLecture && isTestLectureCompleted || isNotReady || isConnecting || isSubmitting; // cancel
84
84
 
85
85
  const isCancelHidden = !isRunning;
@@ -20,6 +20,20 @@ const StyledHeaderUrlInput = styled__default["default"].input.withConfig({
20
20
  const StyledIframe = styled__default["default"].iframe.withConfig({
21
21
  componentId: "sc-1c55yq-1"
22
22
  })(["flex:1;width:100%;height:100%;min-height:0;border:0;"]);
23
+ /**
24
+ * Attach `_cachebust` search parameter to the URL to prevent caching.
25
+ */
26
+
27
+ const createCacheBustedUrl = url => {
28
+ try {
29
+ const urlObject = new URL(url);
30
+ urlObject.searchParams.set('_cachebust', Date.now().toString());
31
+ return urlObject.href;
32
+ } catch (_) {
33
+ return url;
34
+ }
35
+ };
36
+
23
37
  const WebBrowser = React.forwardRef(({
24
38
  httpUri,
25
39
  menuButtons = null
@@ -27,15 +41,7 @@ const WebBrowser = React.forwardRef(({
27
41
  const [url, setUrl] = React__default["default"].useState('');
28
42
  const [inputUrl, setInputUrl] = React__default["default"].useState('');
29
43
  const iframeRef = React__default["default"].useRef(null);
30
- const iframeSrc = React__default["default"].useMemo(() => {
31
- try {
32
- const urlObj = new URL(url);
33
- urlObj.searchParams.set('_', Date.now().toString());
34
- return urlObj.href;
35
- } catch (_) {
36
- return '';
37
- }
38
- }, [url]);
44
+ const iframeSrc = React__default["default"].useMemo(() => createCacheBustedUrl(url), [url]);
39
45
  /**
40
46
  * Navigate browser.
41
47
  */
@@ -51,8 +57,7 @@ const WebBrowser = React.forwardRef(({
51
57
 
52
58
  const reload = React__default["default"].useCallback(() => {
53
59
  if (iframeRef.current) {
54
- // eslint-disable-next-line no-self-assign
55
- iframeRef.current.src = iframeRef.current.src;
60
+ iframeRef.current.src = createCacheBustedUrl(iframeRef.current.src);
56
61
  }
57
62
  }, []);
58
63
  /**
@@ -72,7 +72,7 @@ const ExerciseRunnerControllerButtonGroup = () => {
72
72
  const isSubmitRunArduinoDisabled = isArduinoExercise ? arduinoUploadProgress !== 'ready' && arduinoUploadProgress !== 'error' || !arduinoOpenedPortName : false;
73
73
  const isSubmitRunDisabled = isSubmitRunHidden || isSubmitRunArduinoDisabled || isNotReady || isConnecting || isSubmitting; // submit grade
74
74
 
75
- const isSubmitGradeHidden = isRunning || isArduinoExercise;
75
+ const isSubmitGradeHidden = isRunning;
76
76
  const isSubmitGradeDisabled = isSubmitGradeHidden || exerciseWithNoGrade || isTestLecture && isTestLectureCompleted || isNotReady || isConnecting || isSubmitting; // cancel
77
77
 
78
78
  const isCancelHidden = !isRunning;
@@ -13,6 +13,20 @@ const StyledHeaderUrlInput = styled.input.withConfig({
13
13
  const StyledIframe = styled.iframe.withConfig({
14
14
  componentId: "sc-1c55yq-1"
15
15
  })(["flex:1;width:100%;height:100%;min-height:0;border:0;"]);
16
+ /**
17
+ * Attach `_cachebust` search parameter to the URL to prevent caching.
18
+ */
19
+
20
+ const createCacheBustedUrl = url => {
21
+ try {
22
+ const urlObject = new URL(url);
23
+ urlObject.searchParams.set('_cachebust', Date.now().toString());
24
+ return urlObject.href;
25
+ } catch (_) {
26
+ return url;
27
+ }
28
+ };
29
+
16
30
  const WebBrowser = forwardRef(({
17
31
  httpUri,
18
32
  menuButtons = null
@@ -20,15 +34,7 @@ const WebBrowser = forwardRef(({
20
34
  const [url, setUrl] = React.useState('');
21
35
  const [inputUrl, setInputUrl] = React.useState('');
22
36
  const iframeRef = React.useRef(null);
23
- const iframeSrc = React.useMemo(() => {
24
- try {
25
- const urlObj = new URL(url);
26
- urlObj.searchParams.set('_', Date.now().toString());
27
- return urlObj.href;
28
- } catch (_) {
29
- return '';
30
- }
31
- }, [url]);
37
+ const iframeSrc = React.useMemo(() => createCacheBustedUrl(url), [url]);
32
38
  /**
33
39
  * Navigate browser.
34
40
  */
@@ -44,8 +50,7 @@ const WebBrowser = forwardRef(({
44
50
 
45
51
  const reload = React.useCallback(() => {
46
52
  if (iframeRef.current) {
47
- // eslint-disable-next-line no-self-assign
48
- iframeRef.current.src = iframeRef.current.src;
53
+ iframeRef.current.src = createCacheBustedUrl(iframeRef.current.src);
49
54
  }
50
55
  }, []);
51
56
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-exercise",
3
- "version": "1.220808.0",
3
+ "version": "1.220913.0",
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",
@@ -115,8 +115,8 @@
115
115
  "@elice/design-tokens": "^1.220803.0",
116
116
  "@elice/icons": "^1.220803.0",
117
117
  "@elice/markdown": "^1.220803.0",
118
- "@elice/material-shared-types": "1.220808.0",
119
- "@elice/material-shared-utils": "1.220808.0",
118
+ "@elice/material-shared-types": "1.220913.0",
119
+ "@elice/material-shared-utils": "1.220913.0",
120
120
  "@elice/types": "^1.220803.0",
121
121
  "@elice/websocket": "^1.220803.0",
122
122
  "@types/classnames": "^2.3.1",
@@ -138,5 +138,5 @@
138
138
  "recoil": "^0.6.1",
139
139
  "styled-components": "^5.2.0"
140
140
  },
141
- "gitHead": "9ed1453798e79b8daa25b3bc92dff0254001e8d7"
141
+ "gitHead": "91229fbe698b41dd68ffb742cd40c379528027b9"
142
142
  }