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