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