@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.
Files changed (21) hide show
  1. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.js +20 -22
  2. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.styled.js +1 -5
  3. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.js +171 -250
  4. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.js +6 -10
  5. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.js +43 -80
  6. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.js +30 -63
  7. package/cjs/components/material-runbox-legacy/websocket.js +2 -2
  8. package/es/components/material-runbox-legacy/MaterialRunboxLegacy.js +20 -22
  9. package/es/components/material-runbox-legacy/MaterialRunboxLegacy.styled.js +1 -1
  10. package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.js +171 -246
  11. package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.js +6 -6
  12. package/es/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.js +43 -76
  13. package/es/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.js +30 -59
  14. package/es/components/material-runbox-legacy/websocket.js +2 -2
  15. package/package.json +12 -9
  16. package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -383
  17. package/cjs/components/material-runbox-legacy/index.js +0 -7
  18. package/cjs/components/material-runbox-legacy/locales/index.js +0 -13
  19. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -374
  20. package/es/components/material-runbox-legacy/index.js +0 -1
  21. 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
- 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) {
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
- var handleReconnect = function handleReconnect() {
39
+ const handleReconnect = () => {
47
40
  setRunboxStats(null);
48
41
  setRunboxUrlLoaded(false);
49
42
  reconnect();
50
43
  };
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
- }();
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(function () {
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(function () {
97
- setRunboxStatus(function () {
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
- var renderRunboxStatusMessage = function renderRunboxStatusMessage() {
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
- 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
- });
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
- var renderRunboxBody = function renderRunboxBody() {
223
+ const renderRunboxBody = () => {
275
224
  if (runboxStatus === MaterialRunboxLegacyStatus.Terminated) {
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
- });
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 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
- });
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 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
- });
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 jsxs(Fragment, {
341
- children: [renderRunboxHeader(), jsx(Vspace, {
342
- height: 0.5
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
- var RunboxHeader = styled.div.withConfig({
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
- var RunboxBody = styled.div.withConfig({
8
+ const RunboxBody = styled.div.withConfig({
9
9
  componentId: "sc-18a3wux-1"
10
10
  })(["position:relative;flex:1;"]);
11
- var RunboxBodyOverlay = styled.div.withConfig({
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
- var RunboxBodyIframe = styled.iframe.withConfig({
14
+ const RunboxBodyIframe = styled.iframe.withConfig({
15
15
  componentId: "sc-18a3wux-3"
16
16
  })(["width:100%;height:100%;border:none;"]);
17
- var RunboxStatusLight = styled.span.withConfig({
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:", ";"], function (props) {
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
- 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];
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
- 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]);
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
- 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]);
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 jsx(WSMaterialRunboxLegacyRunnerRoom.Provider, {
52
+ return React.createElement(WSMaterialRunboxLegacyRunnerRoom.Provider, {
85
53
  enable: !isRunboxRunningCanceling,
86
- endpoint: "".concat(apiWsOriginUrl, "/runner_room"),
54
+ endpoint: `${apiWsOriginUrl}/runner_room`,
87
55
  tokenProvider: resolveRunnerRoomToken,
88
- connectionTimeout: 8000,
89
- children: jsx(MaterialRunboxLegacyStdioWrapper, {
90
- isRunboxJoinError: isRunboxJoinError,
91
- reconnectRunnerRoomWebSocket: reconnectRunnerRoomWebSocket
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 };