@elice/material-runbox-legacy 1.240718.0-trasncript.2 → 1.240718.2
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/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.js +20 -22
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.styled.js +1 -5
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.js +171 -250
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.js +6 -10
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.js +43 -80
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.js +30 -63
- package/cjs/components/material-runbox-legacy/websocket.js +2 -2
- package/es/components/material-runbox-legacy/MaterialRunboxLegacy.js +20 -22
- package/es/components/material-runbox-legacy/MaterialRunboxLegacy.styled.js +1 -1
- package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.js +171 -246
- package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.js +6 -6
- package/es/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.js +43 -76
- package/es/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.js +30 -59
- package/es/components/material-runbox-legacy/websocket.js +2 -2
- package/package.json +12 -9
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -383
- package/cjs/components/material-runbox-legacy/index.js +0 -7
- package/cjs/components/material-runbox-legacy/locales/index.js +0 -13
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -374
- package/es/components/material-runbox-legacy/index.js +0 -1
- package/es/components/material-runbox-legacy/locales/index.js +0 -4
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { usePrevious } from 'react-use';
|
|
5
3
|
import { Vspace, LaptopOrLarger, Flex, Text, AntProgress, Hspace, IconButton, Tooltip, Box, Spinner, Notification } from '@elice/blocks';
|
|
@@ -8,6 +6,7 @@ import { useRawEliceIntl } from '@elice/intl';
|
|
|
8
6
|
import { WSMaterialRunboxLegacyStdio } from './websocket.js';
|
|
9
7
|
import { RunboxHeader, RunboxStatusLight, RunboxBody, RunboxBodyOverlay, RunboxBodyIframe } from './MaterialRunboxLegacyContent.styled.js';
|
|
10
8
|
|
|
9
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
11
10
|
var MaterialRunboxLegacyStatus;
|
|
12
11
|
(function (MaterialRunboxLegacyStatus) {
|
|
13
12
|
MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Idle"] = 0] = "Idle";
|
|
@@ -18,74 +17,47 @@ var MaterialRunboxLegacyStatus;
|
|
|
18
17
|
MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Terminated"] = 5] = "Terminated";
|
|
19
18
|
MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Error"] = 6] = "Error";
|
|
20
19
|
})(MaterialRunboxLegacyStatus || (MaterialRunboxLegacyStatus = {}));
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setRunboxUrlLoaded = _React$useState4[1];
|
|
35
|
-
var isRunboxUrlLoadedPrev = usePrevious(isRunboxUrlLoaded);
|
|
36
|
-
var _React$useState5 = React.useState(MaterialRunboxLegacyStatus.Idle),
|
|
37
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
38
|
-
runboxStatus = _React$useState6[0],
|
|
39
|
-
setRunboxStatus = _React$useState6[1];
|
|
40
|
-
var isRunboxPreparing = runboxStatus !== MaterialRunboxLegacyStatus.Done && runboxStatus !== MaterialRunboxLegacyStatus.Terminated;
|
|
41
|
-
WSMaterialRunboxLegacyStdio.useMessage(function (message) {
|
|
20
|
+
const MaterialRunboxLegacyContent = ({
|
|
21
|
+
runboxUrl,
|
|
22
|
+
isRunboxTerminated,
|
|
23
|
+
isRunboxJoinError,
|
|
24
|
+
reconnect
|
|
25
|
+
}) => {
|
|
26
|
+
const intl = useRawEliceIntl();
|
|
27
|
+
const [runboxStats, setRunboxStats] = React.useState(null);
|
|
28
|
+
const [isRunboxUrlLoaded, setRunboxUrlLoaded] = React.useState(false);
|
|
29
|
+
const isRunboxUrlLoadedPrev = usePrevious(isRunboxUrlLoaded);
|
|
30
|
+
const [runboxStatus, setRunboxStatus] = React.useState(MaterialRunboxLegacyStatus.Idle);
|
|
31
|
+
const isRunboxPreparing = runboxStatus !== MaterialRunboxLegacyStatus.Done && runboxStatus !== MaterialRunboxLegacyStatus.Terminated;
|
|
32
|
+
WSMaterialRunboxLegacyStdio.useMessage(message => {
|
|
42
33
|
if (message.type === 'stats') {
|
|
43
34
|
setRunboxStats(message.data);
|
|
44
35
|
}
|
|
36
|
+
}, {
|
|
37
|
+
camelize: true
|
|
45
38
|
});
|
|
46
|
-
|
|
39
|
+
const handleReconnect = () => {
|
|
47
40
|
setRunboxStats(null);
|
|
48
41
|
setRunboxUrlLoaded(false);
|
|
49
42
|
reconnect();
|
|
50
43
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return navigator.clipboard.writeText(runboxUrl);
|
|
65
|
-
case 5:
|
|
66
|
-
Notification.success(intl.formatMessage({
|
|
67
|
-
id: 'runboxLegacy.share.success'
|
|
68
|
-
}));
|
|
69
|
-
_context.next = 11;
|
|
70
|
-
break;
|
|
71
|
-
case 8:
|
|
72
|
-
_context.prev = 8;
|
|
73
|
-
_context.t0 = _context["catch"](2);
|
|
74
|
-
alert(runboxUrl);
|
|
75
|
-
case 11:
|
|
76
|
-
case "end":
|
|
77
|
-
return _context.stop();
|
|
78
|
-
}
|
|
79
|
-
}, _callee, null, [[2, 8]]);
|
|
80
|
-
}));
|
|
81
|
-
return function handleShare() {
|
|
82
|
-
return _ref2.apply(this, arguments);
|
|
83
|
-
};
|
|
84
|
-
}();
|
|
44
|
+
const handleShare = async () => {
|
|
45
|
+
if (!runboxUrl) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
await navigator.clipboard.writeText(runboxUrl);
|
|
50
|
+
Notification.success(intl.formatMessage({
|
|
51
|
+
id: 'runboxLegacy.share.success'
|
|
52
|
+
}));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
alert(runboxUrl);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
85
57
|
//
|
|
86
58
|
// Change `isRunboxUrlLoaded` flag to false, when runbox url removed.
|
|
87
59
|
//
|
|
88
|
-
React.useEffect(
|
|
60
|
+
React.useEffect(() => {
|
|
89
61
|
if (!runboxUrl) {
|
|
90
62
|
setRunboxUrlLoaded(false);
|
|
91
63
|
}
|
|
@@ -93,8 +65,8 @@ var MaterialRunboxLegacyContent = function MaterialRunboxLegacyContent(_ref) {
|
|
|
93
65
|
//
|
|
94
66
|
// Determine runbox status.
|
|
95
67
|
//
|
|
96
|
-
React.useEffect(
|
|
97
|
-
setRunboxStatus(
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
setRunboxStatus((() => {
|
|
98
70
|
switch (true) {
|
|
99
71
|
case isRunboxJoinError:
|
|
100
72
|
return MaterialRunboxLegacyStatus.Error;
|
|
@@ -111,12 +83,12 @@ var MaterialRunboxLegacyContent = function MaterialRunboxLegacyContent(_ref) {
|
|
|
111
83
|
default:
|
|
112
84
|
return MaterialRunboxLegacyStatus.Idle;
|
|
113
85
|
}
|
|
114
|
-
}());
|
|
86
|
+
})());
|
|
115
87
|
}, [isRunboxJoinError, isRunboxTerminated, isRunboxUrlLoaded, isRunboxUrlLoadedPrev, runboxUrl]);
|
|
116
88
|
/**
|
|
117
89
|
* Runbox status message shown at header.
|
|
118
90
|
*/
|
|
119
|
-
|
|
91
|
+
const renderRunboxStatusMessage = () => {
|
|
120
92
|
switch (runboxStatus) {
|
|
121
93
|
case MaterialRunboxLegacyStatus.Idle:
|
|
122
94
|
return intl.formatMessage({
|
|
@@ -147,201 +119,154 @@ var MaterialRunboxLegacyContent = function MaterialRunboxLegacyContent(_ref) {
|
|
|
147
119
|
/**
|
|
148
120
|
* Header of runbox.
|
|
149
121
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
size: "small",
|
|
248
|
-
border: true,
|
|
249
|
-
disabled: isRunboxPreparing,
|
|
250
|
-
onClick: handleShare
|
|
251
|
-
}), jsx(Hspace, {
|
|
252
|
-
width: 0.5
|
|
253
|
-
}), jsx(Tooltip, {
|
|
254
|
-
title: isRunboxPreparing ? intl.formatMessage({
|
|
255
|
-
id: 'runboxLegacy.reloadButton.tooltip'
|
|
256
|
-
}) : undefined,
|
|
257
|
-
children: jsx("span", {
|
|
258
|
-
children: jsx(IconButton, {
|
|
259
|
-
icon: eilReset,
|
|
260
|
-
iconSpin: isRunboxPreparing,
|
|
261
|
-
role: "greyfb",
|
|
262
|
-
size: "small",
|
|
263
|
-
border: true,
|
|
264
|
-
disabled: isRunboxPreparing,
|
|
265
|
-
onClick: handleReconnect
|
|
266
|
-
})
|
|
267
|
-
})
|
|
268
|
-
})]
|
|
269
|
-
});
|
|
122
|
+
const renderRunboxHeader = () => {
|
|
123
|
+
const runboxStatsInfo = runboxStats ? React.createElement(LaptopOrLarger, null, React.createElement(Flex, null, React.createElement(Flex, {
|
|
124
|
+
align: "center"
|
|
125
|
+
}, React.createElement(Text, {
|
|
126
|
+
size: "tiny",
|
|
127
|
+
lineHeight: 1.5,
|
|
128
|
+
role: "gray7",
|
|
129
|
+
bold: true
|
|
130
|
+
}, "CPU:\u00A0"), React.createElement(Flex, {
|
|
131
|
+
align: "center",
|
|
132
|
+
width: "30px"
|
|
133
|
+
}, React.createElement(AntProgress, {
|
|
134
|
+
type: "line",
|
|
135
|
+
percent: runboxStats.cpu.percent,
|
|
136
|
+
status: 'active',
|
|
137
|
+
showInfo: false
|
|
138
|
+
})), React.createElement(Text, {
|
|
139
|
+
size: "tiny",
|
|
140
|
+
lineHeight: 1.5,
|
|
141
|
+
role: "gray5"
|
|
142
|
+
}, "\u00A0", `${runboxStats.cpu.percent.toFixed(0)}%`)), React.createElement(Hspace, {
|
|
143
|
+
width: 1
|
|
144
|
+
}), React.createElement(Flex, {
|
|
145
|
+
align: "center"
|
|
146
|
+
}, React.createElement(Text, {
|
|
147
|
+
size: "tiny",
|
|
148
|
+
lineHeight: 1.5,
|
|
149
|
+
role: "gray7",
|
|
150
|
+
bold: true
|
|
151
|
+
}, "MEM:\u00A0"), React.createElement(Flex, {
|
|
152
|
+
align: "center",
|
|
153
|
+
width: "30px"
|
|
154
|
+
}, React.createElement(AntProgress, {
|
|
155
|
+
percent: runboxStats.memory.currentBytes / runboxStats.memory.limitBytes * 100,
|
|
156
|
+
status: 'active',
|
|
157
|
+
showInfo: false
|
|
158
|
+
})), React.createElement(Text, {
|
|
159
|
+
size: "tiny",
|
|
160
|
+
lineHeight: 1.5,
|
|
161
|
+
role: "gray5"
|
|
162
|
+
}, "\u00A0", `${(runboxStats.memory.currentBytes / 1024 / 1024).toFixed(0)}M / ${(runboxStats.memory.limitBytes / 1024 / 1024).toFixed(0)}M`)), React.createElement(Hspace, {
|
|
163
|
+
width: 1
|
|
164
|
+
}), React.createElement(Text, {
|
|
165
|
+
size: "tiny",
|
|
166
|
+
lineHeight: 1.5,
|
|
167
|
+
role: "gray7",
|
|
168
|
+
bold: true
|
|
169
|
+
}, "DISK:\u00A0"), React.createElement(Text, {
|
|
170
|
+
size: "tiny",
|
|
171
|
+
lineHeight: 1.5,
|
|
172
|
+
role: "gray5"
|
|
173
|
+
}, `Read ${(runboxStats.block.rxBytes / 1024 / 1024).toFixed(0)}M Write ${(runboxStats.block.txBytes / 1024 / 1024).toFixed(0)}M`), React.createElement(Hspace, {
|
|
174
|
+
width: 1
|
|
175
|
+
}), React.createElement(Text, {
|
|
176
|
+
size: "tiny",
|
|
177
|
+
lineHeight: 1.5,
|
|
178
|
+
role: "gray7",
|
|
179
|
+
bold: true
|
|
180
|
+
}, "NET:\u00A0"), React.createElement(Text, {
|
|
181
|
+
size: "tiny",
|
|
182
|
+
lineHeight: 1.5,
|
|
183
|
+
role: "gray5"
|
|
184
|
+
}, `↓${(runboxStats.network.rxBytes / 1024 / 1024).toFixed(0)}M ↑${(runboxStats.network.txBytes / 1024 / 1024).toFixed(0)}M`), React.createElement(Hspace, {
|
|
185
|
+
width: 1
|
|
186
|
+
}))) : null;
|
|
187
|
+
return React.createElement(RunboxHeader, null, runboxStatsInfo, React.createElement(Flex, {
|
|
188
|
+
align: "center"
|
|
189
|
+
}, React.createElement(RunboxStatusLight, {
|
|
190
|
+
status: runboxStatus
|
|
191
|
+
}), React.createElement(Hspace, {
|
|
192
|
+
width: 0.5
|
|
193
|
+
}), React.createElement(Text, {
|
|
194
|
+
size: "small"
|
|
195
|
+
}, renderRunboxStatusMessage())), React.createElement(Hspace, {
|
|
196
|
+
width: 1
|
|
197
|
+
}), React.createElement(IconButton, {
|
|
198
|
+
icon: eilShare,
|
|
199
|
+
role: "greyfb",
|
|
200
|
+
size: "small",
|
|
201
|
+
border: true,
|
|
202
|
+
disabled: isRunboxPreparing,
|
|
203
|
+
onClick: handleShare
|
|
204
|
+
}), React.createElement(Hspace, {
|
|
205
|
+
width: 0.5
|
|
206
|
+
}), React.createElement(Tooltip, {
|
|
207
|
+
title: isRunboxPreparing ? intl.formatMessage({
|
|
208
|
+
id: 'runboxLegacy.reloadButton.tooltip'
|
|
209
|
+
}) : undefined
|
|
210
|
+
}, React.createElement("span", null, React.createElement(IconButton, {
|
|
211
|
+
icon: eilReset,
|
|
212
|
+
iconSpin: isRunboxPreparing,
|
|
213
|
+
role: "greyfb",
|
|
214
|
+
size: "small",
|
|
215
|
+
border: true,
|
|
216
|
+
disabled: isRunboxPreparing,
|
|
217
|
+
onClick: handleReconnect
|
|
218
|
+
}))));
|
|
270
219
|
};
|
|
271
220
|
/**
|
|
272
221
|
* Body of runbox.
|
|
273
222
|
*/
|
|
274
|
-
|
|
223
|
+
const renderRunboxBody = () => {
|
|
275
224
|
if (runboxStatus === MaterialRunboxLegacyStatus.Terminated) {
|
|
276
|
-
return
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
children: intl.formatMessage({
|
|
285
|
-
id: 'runboxLegacy.overlay.message.terminated'
|
|
286
|
-
})
|
|
287
|
-
})
|
|
288
|
-
})
|
|
289
|
-
})
|
|
290
|
-
});
|
|
225
|
+
return React.createElement(RunboxBody, null, React.createElement(RunboxBodyOverlay, null, React.createElement(Box, null, React.createElement(Text, {
|
|
226
|
+
size: "small",
|
|
227
|
+
preWrap: true,
|
|
228
|
+
lineHeight: 1.5,
|
|
229
|
+
textAlign: "center"
|
|
230
|
+
}, intl.formatMessage({
|
|
231
|
+
id: 'runboxLegacy.overlay.message.terminated'
|
|
232
|
+
})))));
|
|
291
233
|
}
|
|
292
234
|
if (runboxStatus === MaterialRunboxLegacyStatus.Error) {
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
children: intl.formatMessage({
|
|
302
|
-
id: 'runboxLegacy.overlay.message.error'
|
|
303
|
-
})
|
|
304
|
-
})
|
|
305
|
-
})
|
|
306
|
-
})
|
|
307
|
-
});
|
|
235
|
+
return React.createElement(RunboxBody, null, React.createElement(RunboxBodyOverlay, null, React.createElement(Box, null, React.createElement(Text, {
|
|
236
|
+
size: "small",
|
|
237
|
+
preWrap: true,
|
|
238
|
+
lineHeight: 1.5,
|
|
239
|
+
textAlign: "center"
|
|
240
|
+
}, intl.formatMessage({
|
|
241
|
+
id: 'runboxLegacy.overlay.message.error'
|
|
242
|
+
})))));
|
|
308
243
|
}
|
|
309
|
-
return
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
src: runboxUrl + '/?folder=/mnt/elice/workspace',
|
|
329
|
-
title: "material-runbox-legacy",
|
|
330
|
-
onLoad: function onLoad() {
|
|
331
|
-
return setRunboxUrlLoaded(true);
|
|
332
|
-
},
|
|
333
|
-
allow: "clipboard-read; clipboard-write; camera *; microphone *"
|
|
334
|
-
}) : null]
|
|
335
|
-
});
|
|
244
|
+
return React.createElement(RunboxBody, null, React.createElement(RunboxBodyOverlay, {
|
|
245
|
+
"aria-hidden": !isRunboxPreparing
|
|
246
|
+
}, React.createElement(Box, null, React.createElement(Spinner, null), React.createElement(Vspace, {
|
|
247
|
+
height: 1
|
|
248
|
+
}), React.createElement(Text, {
|
|
249
|
+
size: "small",
|
|
250
|
+
preWrap: true,
|
|
251
|
+
lineHeight: 1.5,
|
|
252
|
+
textAlign: "center"
|
|
253
|
+
}, runboxStatus === MaterialRunboxLegacyStatus.Disconnected ? intl.formatMessage({
|
|
254
|
+
id: 'runboxLegacy.overlay.message.disconnected'
|
|
255
|
+
}) : intl.formatMessage({
|
|
256
|
+
id: 'runboxLegacy.overlay.message.connecting'
|
|
257
|
+
})))), runboxUrl ? React.createElement(RunboxBodyIframe, {
|
|
258
|
+
src: runboxUrl + '/?folder=/mnt/elice/workspace',
|
|
259
|
+
title: "material-runbox-legacy",
|
|
260
|
+
onLoad: () => setRunboxUrlLoaded(true),
|
|
261
|
+
allow: "clipboard-read; clipboard-write; camera *; microphone *"
|
|
262
|
+
}) : null);
|
|
336
263
|
};
|
|
337
264
|
//
|
|
338
265
|
//
|
|
339
266
|
//
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}), renderRunboxBody()]
|
|
344
|
-
});
|
|
267
|
+
return React.createElement(React.Fragment, null, renderRunboxHeader(), React.createElement(Vspace, {
|
|
268
|
+
height: 0.5
|
|
269
|
+
}), renderRunboxBody());
|
|
345
270
|
};
|
|
346
271
|
|
|
347
272
|
export { MaterialRunboxLegacyStatus, MaterialRunboxLegacyContent as default };
|
|
@@ -2,21 +2,21 @@ import { base } from '@elice/design-tokens';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { MaterialRunboxLegacyStatus } from './MaterialRunboxLegacyContent.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const RunboxHeader = styled.div.withConfig({
|
|
6
6
|
componentId: "sc-18a3wux-0"
|
|
7
7
|
})(["flex:0 0 2.5rem;display:flex;justify-content:flex-end;align-items:center;padding:0 0.5rem;"]);
|
|
8
|
-
|
|
8
|
+
const RunboxBody = styled.div.withConfig({
|
|
9
9
|
componentId: "sc-18a3wux-1"
|
|
10
10
|
})(["position:relative;flex:1;"]);
|
|
11
|
-
|
|
11
|
+
const RunboxBodyOverlay = styled.div.withConfig({
|
|
12
12
|
componentId: "sc-18a3wux-2"
|
|
13
13
|
})(["position:absolute;top:0;left:0;display:flex;justify-content:center;align-items:center;flex:1;width:100%;height:100%;background:rgba(255,255,255,0.8);&[aria-hidden='true']{display:none;}"]);
|
|
14
|
-
|
|
14
|
+
const RunboxBodyIframe = styled.iframe.withConfig({
|
|
15
15
|
componentId: "sc-18a3wux-3"
|
|
16
16
|
})(["width:100%;height:100%;border:none;"]);
|
|
17
|
-
|
|
17
|
+
const RunboxStatusLight = styled.span.withConfig({
|
|
18
18
|
componentId: "sc-18a3wux-4"
|
|
19
|
-
})(["display:block;width:0.5rem;height:0.5rem;border-radius:50%;background-color:", ";"],
|
|
19
|
+
})(["display:block;width:0.5rem;height:0.5rem;border-radius:50%;background-color:", ";"], props => {
|
|
20
20
|
switch (props.status) {
|
|
21
21
|
case MaterialRunboxLegacyStatus.Loading:
|
|
22
22
|
case MaterialRunboxLegacyStatus.Connecting:
|
|
@@ -1,96 +1,63 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { postOrgRunnerRoomMaterialRunboxJoin, postOrgMaterialRunboxRunboxRunningCancel } from '@elice/api-client';
|
|
5
3
|
import { useMaterialConfig } from '@elice/material-shared-utils';
|
|
6
4
|
import MaterialRunboxLegacyStdioWrapper from './MaterialRunboxLegacyStdioWrapper.js';
|
|
7
5
|
import { WSMaterialRunboxLegacyRunnerRoom } from './websocket.js';
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
20
|
-
isRunboxJoinError = _React$useState4[0],
|
|
21
|
-
setRunboxJoinError = _React$useState4[1];
|
|
22
|
-
var _React$useState5 = React.useState(false),
|
|
23
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
24
|
-
isRunboxRunningCanceling = _React$useState6[0],
|
|
25
|
-
setRunboxRunningCanceling = _React$useState6[1];
|
|
7
|
+
const MaterialRunboxLegacyRunnerRoomWrapper = ({
|
|
8
|
+
materialRunboxId
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
apiWsOriginUrl
|
|
12
|
+
} = useMaterialConfig();
|
|
13
|
+
const abortCtrlRef = React.useRef(new AbortController());
|
|
14
|
+
const [runboxRunningId, setRunboxRunningId] = React.useState();
|
|
15
|
+
const [isRunboxJoinError, setRunboxJoinError] = React.useState(false);
|
|
16
|
+
const [isRunboxRunningCanceling, setRunboxRunningCanceling] = React.useState(false);
|
|
26
17
|
/**
|
|
27
18
|
* Resolve runner room token.
|
|
28
19
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
throw err;
|
|
47
|
-
}));
|
|
48
|
-
case 4:
|
|
49
|
-
case "end":
|
|
50
|
-
return _context.stop();
|
|
51
|
-
}
|
|
52
|
-
}, _callee);
|
|
53
|
-
})), [materialRunboxId]);
|
|
20
|
+
const resolveRunnerRoomToken = React.useCallback(async () => {
|
|
21
|
+
setRunboxJoinError(false);
|
|
22
|
+
abortCtrlRef.current.abort();
|
|
23
|
+
abortCtrlRef.current = new AbortController();
|
|
24
|
+
return postOrgRunnerRoomMaterialRunboxJoin({
|
|
25
|
+
materialRunboxId
|
|
26
|
+
}, {
|
|
27
|
+
signal: abortCtrlRef.current.signal
|
|
28
|
+
}).then(res => {
|
|
29
|
+
setRunboxJoinError(false);
|
|
30
|
+
setRunboxRunningId(res.runboxRunningId);
|
|
31
|
+
return res.roomToken;
|
|
32
|
+
}).catch(err => {
|
|
33
|
+
setRunboxJoinError(true);
|
|
34
|
+
throw err;
|
|
35
|
+
});
|
|
36
|
+
}, [materialRunboxId]);
|
|
54
37
|
/**
|
|
55
38
|
* Reconnect runbox.
|
|
56
39
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
case 2:
|
|
67
|
-
setRunboxRunningCanceling(true);
|
|
68
|
-
return _context2.abrupt("return", postOrgMaterialRunboxRunboxRunningCancel({
|
|
69
|
-
runboxRunningId: runboxRunningId
|
|
70
|
-
}).then(function () {
|
|
71
|
-
return setRunboxRunningCanceling(false);
|
|
72
|
-
}).catch(function () {
|
|
73
|
-
return setRunboxRunningCanceling(false);
|
|
74
|
-
}));
|
|
75
|
-
case 4:
|
|
76
|
-
case "end":
|
|
77
|
-
return _context2.stop();
|
|
78
|
-
}
|
|
79
|
-
}, _callee2);
|
|
80
|
-
})), [runboxRunningId]);
|
|
40
|
+
const reconnectRunnerRoomWebSocket = React.useCallback(async () => {
|
|
41
|
+
if (!runboxRunningId) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setRunboxRunningCanceling(true);
|
|
45
|
+
return postOrgMaterialRunboxRunboxRunningCancel({
|
|
46
|
+
runboxRunningId
|
|
47
|
+
}).then(() => setRunboxRunningCanceling(false)).catch(() => setRunboxRunningCanceling(false));
|
|
48
|
+
}, [runboxRunningId]);
|
|
81
49
|
//
|
|
82
50
|
//
|
|
83
51
|
//
|
|
84
|
-
return
|
|
52
|
+
return React.createElement(WSMaterialRunboxLegacyRunnerRoom.Provider, {
|
|
85
53
|
enable: !isRunboxRunningCanceling,
|
|
86
|
-
endpoint:
|
|
54
|
+
endpoint: `${apiWsOriginUrl}/runner_room`,
|
|
87
55
|
tokenProvider: resolveRunnerRoomToken,
|
|
88
|
-
connectionTimeout: 8000
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
56
|
+
connectionTimeout: 8000
|
|
57
|
+
}, React.createElement(MaterialRunboxLegacyStdioWrapper, {
|
|
58
|
+
isRunboxJoinError: isRunboxJoinError,
|
|
59
|
+
reconnectRunnerRoomWebSocket: reconnectRunnerRoomWebSocket
|
|
60
|
+
}));
|
|
94
61
|
};
|
|
95
62
|
|
|
96
63
|
export { MaterialRunboxLegacyRunnerRoomWrapper as default };
|