@elice/material-runbox-legacy 1.230418.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +3 -0
  2. package/cjs/_virtual/_rollupPluginBabelHelpers.js +393 -0
  3. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.d.ts +7 -0
  4. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.js +44 -0
  5. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.styled.d.ts +1 -0
  6. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.styled.js +15 -0
  7. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.d.ts +18 -0
  8. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.js +311 -0
  9. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.d.ts +8 -0
  10. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.js +47 -0
  11. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.d.ts +6 -0
  12. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.js +102 -0
  13. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.d.ts +7 -0
  14. package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.js +107 -0
  15. package/cjs/components/material-runbox-legacy/index.d.ts +2 -0
  16. package/cjs/components/material-runbox-legacy/locales.d.ts +15 -0
  17. package/cjs/components/material-runbox-legacy/locales.js +35 -0
  18. package/cjs/components/material-runbox-legacy/websocket.d.ts +10 -0
  19. package/cjs/components/material-runbox-legacy/websocket.js +18 -0
  20. package/cjs/index.d.ts +1 -0
  21. package/cjs/index.js +9 -0
  22. package/es/_virtual/_rollupPluginBabelHelpers.js +382 -0
  23. package/es/components/material-runbox-legacy/MaterialRunboxLegacy.d.ts +7 -0
  24. package/es/components/material-runbox-legacy/MaterialRunboxLegacy.js +37 -0
  25. package/es/components/material-runbox-legacy/MaterialRunboxLegacy.styled.d.ts +1 -0
  26. package/es/components/material-runbox-legacy/MaterialRunboxLegacy.styled.js +7 -0
  27. package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.d.ts +18 -0
  28. package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.js +303 -0
  29. package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.d.ts +8 -0
  30. package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.js +35 -0
  31. package/es/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.d.ts +6 -0
  32. package/es/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.js +94 -0
  33. package/es/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.d.ts +7 -0
  34. package/es/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.js +99 -0
  35. package/es/components/material-runbox-legacy/index.d.ts +2 -0
  36. package/es/components/material-runbox-legacy/locales.d.ts +15 -0
  37. package/es/components/material-runbox-legacy/locales.js +30 -0
  38. package/es/components/material-runbox-legacy/websocket.d.ts +10 -0
  39. package/es/components/material-runbox-legacy/websocket.js +13 -0
  40. package/es/index.d.ts +1 -0
  41. package/es/index.js +1 -0
  42. package/package.json +70 -0
@@ -0,0 +1,303 @@
1
+ import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React from 'react';
3
+ import { useIntl, FormattedMessage } from 'react-intl';
4
+ import { usePrevious } from 'react-use';
5
+ import { Flex, Hspace, Text, IconButton, Tooltip, Vspace, LaptopOrLarger, AntProgress, Box, Spinner, Notification } from '@elice/blocks';
6
+ import { eilShare, eilReset } from '@elice/icons';
7
+ import { WSMaterialRunboxLegacyStdio } from './websocket.js';
8
+ import { RunboxHeader, RunboxStatusLight, RunboxBody, RunboxBodyOverlay, RunboxBodyIframe } from './MaterialRunboxLegacyContent.styled.js';
9
+
10
+ var MaterialRunboxLegacyStatus;
11
+ (function (MaterialRunboxLegacyStatus) {
12
+ MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Idle"] = 0] = "Idle";
13
+ MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Connecting"] = 1] = "Connecting";
14
+ MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Loading"] = 2] = "Loading";
15
+ MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Done"] = 3] = "Done";
16
+ MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Disconnected"] = 4] = "Disconnected";
17
+ MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Terminated"] = 5] = "Terminated";
18
+ MaterialRunboxLegacyStatus[MaterialRunboxLegacyStatus["Error"] = 6] = "Error";
19
+ })(MaterialRunboxLegacyStatus || (MaterialRunboxLegacyStatus = {}));
20
+ var MaterialRunboxLegacyContent = function MaterialRunboxLegacyContent(_ref) {
21
+ var runboxUrl = _ref.runboxUrl,
22
+ isRunboxTerminated = _ref.isRunboxTerminated,
23
+ isRunboxJoinError = _ref.isRunboxJoinError,
24
+ reconnect = _ref.reconnect;
25
+ var intl = useIntl();
26
+ var _React$useState = React.useState(null),
27
+ _React$useState2 = _slicedToArray(_React$useState, 2),
28
+ runboxStats = _React$useState2[0],
29
+ setRunboxStats = _React$useState2[1];
30
+ var _React$useState3 = React.useState(false),
31
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
32
+ isRunboxUrlLoaded = _React$useState4[0],
33
+ setRunboxUrlLoaded = _React$useState4[1];
34
+ var isRunboxUrlLoadedPrev = usePrevious(isRunboxUrlLoaded);
35
+ var _React$useState5 = React.useState(MaterialRunboxLegacyStatus.Idle),
36
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
37
+ runboxStatus = _React$useState6[0],
38
+ setRunboxStatus = _React$useState6[1];
39
+ var isRunboxPreparing = runboxStatus !== MaterialRunboxLegacyStatus.Done && runboxStatus !== MaterialRunboxLegacyStatus.Terminated;
40
+ WSMaterialRunboxLegacyStdio.useMessage(function (message) {
41
+ if (message.type === 'stats') {
42
+ setRunboxStats(message.data);
43
+ }
44
+ }, {
45
+ camelize: true
46
+ });
47
+ var handleReconnect = function handleReconnect() {
48
+ setRunboxStats(null);
49
+ setRunboxUrlLoaded(false);
50
+ reconnect();
51
+ };
52
+ var handleShare = /*#__PURE__*/function () {
53
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
54
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
55
+ while (1) switch (_context.prev = _context.next) {
56
+ case 0:
57
+ if (runboxUrl) {
58
+ _context.next = 2;
59
+ break;
60
+ }
61
+ return _context.abrupt("return");
62
+ case 2:
63
+ _context.prev = 2;
64
+ _context.next = 5;
65
+ return navigator.clipboard.writeText(runboxUrl);
66
+ case 5:
67
+ Notification.success(intl.formatMessage({
68
+ id: 'runboxLegacy.share.success'
69
+ }));
70
+ _context.next = 11;
71
+ break;
72
+ case 8:
73
+ _context.prev = 8;
74
+ _context.t0 = _context["catch"](2);
75
+ alert(runboxUrl);
76
+ case 11:
77
+ case "end":
78
+ return _context.stop();
79
+ }
80
+ }, _callee, null, [[2, 8]]);
81
+ }));
82
+ return function handleShare() {
83
+ return _ref2.apply(this, arguments);
84
+ };
85
+ }();
86
+ //
87
+ // Change `isRunboxUrlLoaded` flag to false, when runbox url removed.
88
+ //
89
+ React.useEffect(function () {
90
+ if (!runboxUrl) {
91
+ setRunboxUrlLoaded(false);
92
+ }
93
+ }, [runboxUrl]);
94
+ //
95
+ // Determine runbox status.
96
+ //
97
+ React.useEffect(function () {
98
+ setRunboxStatus(function () {
99
+ switch (true) {
100
+ case isRunboxJoinError:
101
+ return MaterialRunboxLegacyStatus.Error;
102
+ case !runboxUrl && isRunboxTerminated:
103
+ return MaterialRunboxLegacyStatus.Terminated;
104
+ case !runboxUrl && !isRunboxTerminated && isRunboxUrlLoadedPrev:
105
+ return MaterialRunboxLegacyStatus.Disconnected;
106
+ case !runboxUrl && !isRunboxTerminated && !isRunboxUrlLoadedPrev:
107
+ return MaterialRunboxLegacyStatus.Connecting;
108
+ case Boolean(runboxUrl) && !isRunboxUrlLoaded:
109
+ return MaterialRunboxLegacyStatus.Loading;
110
+ case Boolean(runboxUrl) && isRunboxUrlLoaded:
111
+ return MaterialRunboxLegacyStatus.Done;
112
+ default:
113
+ return MaterialRunboxLegacyStatus.Idle;
114
+ }
115
+ }());
116
+ }, [isRunboxJoinError, isRunboxTerminated, isRunboxUrlLoaded, isRunboxUrlLoadedPrev, runboxUrl]);
117
+ /**
118
+ * Runbox status message shown at header.
119
+ */
120
+ var renderRunboxStatusMessage = function renderRunboxStatusMessage() {
121
+ switch (runboxStatus) {
122
+ case MaterialRunboxLegacyStatus.Idle:
123
+ return React.createElement(FormattedMessage, {
124
+ id: "runboxLegacy.status.idle"
125
+ });
126
+ case MaterialRunboxLegacyStatus.Connecting:
127
+ return React.createElement(FormattedMessage, {
128
+ id: "runboxLegacy.status.connecting"
129
+ });
130
+ case MaterialRunboxLegacyStatus.Loading:
131
+ return React.createElement(FormattedMessage, {
132
+ id: "runboxLegacy.status.loading"
133
+ });
134
+ case MaterialRunboxLegacyStatus.Done:
135
+ return React.createElement(FormattedMessage, {
136
+ id: "runboxLegacy.status.done"
137
+ });
138
+ case MaterialRunboxLegacyStatus.Disconnected:
139
+ return React.createElement(FormattedMessage, {
140
+ id: "runboxLegacy.status.disconnected"
141
+ });
142
+ case MaterialRunboxLegacyStatus.Terminated:
143
+ return React.createElement(FormattedMessage, {
144
+ id: "runboxLegacy.status.terminated"
145
+ });
146
+ }
147
+ };
148
+ /**
149
+ * Header of runbox.
150
+ */
151
+ var renderRunboxHeader = function renderRunboxHeader() {
152
+ var runboxStatsInfo = runboxStats ? React.createElement(LaptopOrLarger, null, React.createElement(Flex, null, React.createElement(Flex, {
153
+ align: "center"
154
+ }, React.createElement(Text, {
155
+ size: "tiny",
156
+ lineHeight: 1.5,
157
+ role: "gray7",
158
+ bold: true
159
+ }, "CPU:\xA0"), React.createElement(Flex, {
160
+ align: "center",
161
+ width: "30px"
162
+ }, React.createElement(AntProgress, {
163
+ type: "line",
164
+ percent: runboxStats.cpu.percent,
165
+ status: 'active',
166
+ showInfo: false
167
+ })), React.createElement(Text, {
168
+ size: "tiny",
169
+ lineHeight: 1.5,
170
+ role: "gray5"
171
+ }, "\xA0", "".concat(runboxStats.cpu.percent.toFixed(0), "%"))), React.createElement(Hspace, {
172
+ width: 1
173
+ }), React.createElement(Flex, {
174
+ align: "center"
175
+ }, React.createElement(Text, {
176
+ size: "tiny",
177
+ lineHeight: 1.5,
178
+ role: "gray7",
179
+ bold: true
180
+ }, "MEM:\xA0"), React.createElement(Flex, {
181
+ align: "center",
182
+ width: "30px"
183
+ }, React.createElement(AntProgress, {
184
+ percent: runboxStats.memory.currentBytes / runboxStats.memory.limitBytes * 100,
185
+ status: 'active',
186
+ showInfo: false
187
+ })), React.createElement(Text, {
188
+ size: "tiny",
189
+ lineHeight: 1.5,
190
+ role: "gray5"
191
+ }, "\xA0", "".concat((runboxStats.memory.currentBytes / 1024 / 1024).toFixed(0), "M / ").concat((runboxStats.memory.limitBytes / 1024 / 1024).toFixed(0), "M"))), React.createElement(Hspace, {
192
+ width: 1
193
+ }), React.createElement(Text, {
194
+ size: "tiny",
195
+ lineHeight: 1.5,
196
+ role: "gray7",
197
+ bold: true
198
+ }, "DISK:\xA0"), React.createElement(Text, {
199
+ size: "tiny",
200
+ lineHeight: 1.5,
201
+ role: "gray5"
202
+ }, "Read ".concat((runboxStats.block.rxBytes / 1024 / 1024).toFixed(0), "M Write ").concat((runboxStats.block.txBytes / 1024 / 1024).toFixed(0), "M")), React.createElement(Hspace, {
203
+ width: 1
204
+ }), React.createElement(Text, {
205
+ size: "tiny",
206
+ lineHeight: 1.5,
207
+ role: "gray7",
208
+ bold: true
209
+ }, "NET:\xA0"), React.createElement(Text, {
210
+ size: "tiny",
211
+ lineHeight: 1.5,
212
+ role: "gray5"
213
+ }, "\u2193".concat((runboxStats.network.rxBytes / 1024 / 1024).toFixed(0), "M \u2191").concat((runboxStats.network.txBytes / 1024 / 1024).toFixed(0), "M")), React.createElement(Hspace, {
214
+ width: 1
215
+ }))) : null;
216
+ return React.createElement(RunboxHeader, null, runboxStatsInfo, React.createElement(Flex, {
217
+ align: "center"
218
+ }, React.createElement(RunboxStatusLight, {
219
+ status: runboxStatus
220
+ }), React.createElement(Hspace, {
221
+ width: 0.5
222
+ }), React.createElement(Text, {
223
+ size: "small"
224
+ }, renderRunboxStatusMessage())), React.createElement(Hspace, {
225
+ width: 1
226
+ }), React.createElement(IconButton, {
227
+ icon: eilShare,
228
+ role: "greyfb",
229
+ size: "small",
230
+ border: true,
231
+ disabled: isRunboxPreparing,
232
+ onClick: handleShare
233
+ }), React.createElement(Hspace, {
234
+ width: 0.5
235
+ }), React.createElement(Tooltip, {
236
+ title: isRunboxPreparing ? intl.formatMessage({
237
+ id: 'runboxLegacy.reloadButton.tooltip'
238
+ }) : undefined
239
+ }, React.createElement("span", null, React.createElement(IconButton, {
240
+ icon: eilReset,
241
+ iconSpin: isRunboxPreparing,
242
+ role: "greyfb",
243
+ size: "small",
244
+ border: true,
245
+ disabled: isRunboxPreparing,
246
+ onClick: handleReconnect
247
+ }))));
248
+ };
249
+ /**
250
+ * Body of runbox.
251
+ */
252
+ var renderRunboxBody = function renderRunboxBody() {
253
+ if (runboxStatus === MaterialRunboxLegacyStatus.Terminated) {
254
+ return React.createElement(RunboxBody, null, React.createElement(RunboxBodyOverlay, null, React.createElement(Box, null, React.createElement(Text, {
255
+ size: "small",
256
+ preWrap: true,
257
+ lineHeight: 1.5,
258
+ textAlign: "center"
259
+ }, React.createElement(FormattedMessage, {
260
+ id: "runboxLegacy.overlay.message.terminated"
261
+ })))));
262
+ }
263
+ if (runboxStatus === MaterialRunboxLegacyStatus.Error) {
264
+ return React.createElement(RunboxBody, null, React.createElement(RunboxBodyOverlay, null, React.createElement(Box, null, React.createElement(Text, {
265
+ size: "small",
266
+ preWrap: true,
267
+ lineHeight: 1.5,
268
+ textAlign: "center"
269
+ }, React.createElement(FormattedMessage, {
270
+ id: "runboxLegacy.overlay.message.error"
271
+ })))));
272
+ }
273
+ return React.createElement(RunboxBody, null, React.createElement(RunboxBodyOverlay, {
274
+ "aria-hidden": !isRunboxPreparing
275
+ }, React.createElement(Box, null, React.createElement(Spinner, null), React.createElement(Vspace, {
276
+ height: 1
277
+ }), React.createElement(Text, {
278
+ size: "small",
279
+ preWrap: true,
280
+ lineHeight: 1.5,
281
+ textAlign: "center"
282
+ }, runboxStatus === MaterialRunboxLegacyStatus.Disconnected ? React.createElement(FormattedMessage, {
283
+ id: "runboxLegacy.overlay.message.disconnected"
284
+ }) : React.createElement(FormattedMessage, {
285
+ id: "runboxLegacy.overlay.message.connecting"
286
+ })))), runboxUrl ? React.createElement(RunboxBodyIframe, {
287
+ src: runboxUrl + '/?folder=/mnt/elice/workspace',
288
+ title: "material-runbox-legacy",
289
+ onLoad: function onLoad() {
290
+ return setRunboxUrlLoaded(true);
291
+ },
292
+ allow: "clipboard-read; clipboard-write; camera *; microphone *"
293
+ }) : null);
294
+ };
295
+ //
296
+ //
297
+ //
298
+ return React.createElement(React.Fragment, null, renderRunboxHeader(), React.createElement(Vspace, {
299
+ height: 0.5
300
+ }), renderRunboxBody());
301
+ };
302
+
303
+ export { MaterialRunboxLegacyStatus, MaterialRunboxLegacyContent as default };
@@ -0,0 +1,8 @@
1
+ import { MaterialRunboxLegacyStatus } from './MaterialRunboxLegacyContent';
2
+ export declare const RunboxHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const RunboxBody: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export declare const RunboxBodyOverlay: import("styled-components").StyledComponent<"div", any, {}, never>;
5
+ export declare const RunboxBodyIframe: import("styled-components").StyledComponent<"iframe", any, {}, never>;
6
+ export declare const RunboxStatusLight: import("styled-components").StyledComponent<"span", any, {
7
+ status: MaterialRunboxLegacyStatus;
8
+ }, never>;
@@ -0,0 +1,35 @@
1
+ import { base } from '@elice/design-tokens';
2
+ import styled from 'styled-components';
3
+ import { MaterialRunboxLegacyStatus } from './MaterialRunboxLegacyContent.js';
4
+
5
+ var RunboxHeader = styled.div.withConfig({
6
+ componentId: "sc-18a3wux-0"
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({
9
+ componentId: "sc-18a3wux-1"
10
+ })(["position:relative;flex:1;"]);
11
+ var RunboxBodyOverlay = styled.div.withConfig({
12
+ componentId: "sc-18a3wux-2"
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({
15
+ componentId: "sc-18a3wux-3"
16
+ })(["width:100%;height:100%;border:none;"]);
17
+ var RunboxStatusLight = styled.span.withConfig({
18
+ componentId: "sc-18a3wux-4"
19
+ })(["display:block;width:0.5rem;height:0.5rem;border-radius:50%;background-color:", ";"], function (props) {
20
+ switch (props.status) {
21
+ case MaterialRunboxLegacyStatus.Loading:
22
+ case MaterialRunboxLegacyStatus.Connecting:
23
+ return base.color.yellow3;
24
+ case MaterialRunboxLegacyStatus.Disconnected:
25
+ return base.color.red7;
26
+ case MaterialRunboxLegacyStatus.Done:
27
+ return base.color.green7;
28
+ case MaterialRunboxLegacyStatus.Idle:
29
+ case MaterialRunboxLegacyStatus.Terminated:
30
+ default:
31
+ return base.color.white;
32
+ }
33
+ });
34
+
35
+ export { RunboxBody, RunboxBodyIframe, RunboxBodyOverlay, RunboxHeader, RunboxStatusLight };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface MaterialRunboxLegacyRunnerRoomWrapperProps {
3
+ materialRunboxId: number;
4
+ }
5
+ declare const MaterialRunboxLegacyRunnerRoomWrapper: React.FC<MaterialRunboxLegacyRunnerRoomWrapperProps>;
6
+ export default MaterialRunboxLegacyRunnerRoomWrapper;
@@ -0,0 +1,94 @@
1
+ import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React from 'react';
3
+ import { postOrgMaterialRunboxRunboxRunningCancel, postOrgRunnerRoomMaterialRunboxJoin } from '@elice/api-client';
4
+ import { useMaterialConfig } from '@elice/material-shared-utils';
5
+ import MaterialRunboxLegacyStdioWrapper from './MaterialRunboxLegacyStdioWrapper.js';
6
+ import { WSMaterialRunboxLegacyRunnerRoom } from './websocket.js';
7
+
8
+ var MaterialRunboxLegacyRunnerRoomWrapper = function MaterialRunboxLegacyRunnerRoomWrapper(_ref) {
9
+ var materialRunboxId = _ref.materialRunboxId;
10
+ var _useMaterialConfig = useMaterialConfig(),
11
+ apiWsOriginUrl = _useMaterialConfig.apiWsOriginUrl;
12
+ var abortCtrlRef = React.useRef(new AbortController());
13
+ var _React$useState = React.useState(),
14
+ _React$useState2 = _slicedToArray(_React$useState, 2),
15
+ runboxRunningId = _React$useState2[0],
16
+ setRunboxRunningId = _React$useState2[1];
17
+ var _React$useState3 = React.useState(false),
18
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
19
+ isRunboxJoinError = _React$useState4[0],
20
+ setRunboxJoinError = _React$useState4[1];
21
+ var _React$useState5 = React.useState(false),
22
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
23
+ isRunboxRunningCanceling = _React$useState6[0],
24
+ setRunboxRunningCanceling = _React$useState6[1];
25
+ /**
26
+ * Resolve runner room token.
27
+ */
28
+ var resolveRunnerRoomToken = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
29
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
30
+ while (1) switch (_context.prev = _context.next) {
31
+ case 0:
32
+ setRunboxJoinError(false);
33
+ abortCtrlRef.current.abort();
34
+ abortCtrlRef.current = new AbortController();
35
+ return _context.abrupt("return", postOrgRunnerRoomMaterialRunboxJoin({
36
+ materialRunboxId: materialRunboxId
37
+ }, {
38
+ signal: abortCtrlRef.current.signal
39
+ }).then(function (res) {
40
+ setRunboxJoinError(false);
41
+ setRunboxRunningId(res.runboxRunningId);
42
+ return res.roomToken;
43
+ }).catch(function (err) {
44
+ setRunboxJoinError(true);
45
+ throw err;
46
+ }));
47
+ case 4:
48
+ case "end":
49
+ return _context.stop();
50
+ }
51
+ }, _callee);
52
+ })), [materialRunboxId]);
53
+ /**
54
+ * Reconnect runbox.
55
+ */
56
+ var reconnectRunnerRoomWebSocket = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
57
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
58
+ while (1) switch (_context2.prev = _context2.next) {
59
+ case 0:
60
+ if (runboxRunningId) {
61
+ _context2.next = 2;
62
+ break;
63
+ }
64
+ return _context2.abrupt("return");
65
+ case 2:
66
+ setRunboxRunningCanceling(true);
67
+ return _context2.abrupt("return", postOrgMaterialRunboxRunboxRunningCancel({
68
+ runboxRunningId: runboxRunningId
69
+ }).then(function () {
70
+ return setRunboxRunningCanceling(false);
71
+ }).catch(function () {
72
+ return setRunboxRunningCanceling(false);
73
+ }));
74
+ case 4:
75
+ case "end":
76
+ return _context2.stop();
77
+ }
78
+ }, _callee2);
79
+ })), [runboxRunningId]);
80
+ //
81
+ //
82
+ //
83
+ return React.createElement(WSMaterialRunboxLegacyRunnerRoom.Provider, {
84
+ enable: !isRunboxRunningCanceling,
85
+ endpoint: "".concat(apiWsOriginUrl, "/runner_room"),
86
+ tokenProvider: resolveRunnerRoomToken,
87
+ connectionTimeout: 8000
88
+ }, React.createElement(MaterialRunboxLegacyStdioWrapper, {
89
+ isRunboxJoinError: isRunboxJoinError,
90
+ reconnectRunnerRoomWebSocket: reconnectRunnerRoomWebSocket
91
+ }));
92
+ };
93
+
94
+ export { MaterialRunboxLegacyRunnerRoomWrapper as default };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface MaterialRunboxLegacyStdioWrapperProps {
3
+ isRunboxJoinError: boolean;
4
+ reconnectRunnerRoomWebSocket: () => Promise<void>;
5
+ }
6
+ declare const MaterialRunboxLegacyStdioWrapper: React.FC<MaterialRunboxLegacyStdioWrapperProps>;
7
+ export default MaterialRunboxLegacyStdioWrapper;
@@ -0,0 +1,99 @@
1
+ import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React from 'react';
3
+ import MaterialRunboxLegacyContent from './MaterialRunboxLegacyContent.js';
4
+ import { WSMaterialRunboxLegacyRunnerRoom, WSMaterialRunboxLegacyStdio } from './websocket.js';
5
+
6
+ var RECONNECT_DELAY = 500;
7
+ var MaterialRunboxLegacyStdioWrapper = function MaterialRunboxLegacyStdioWrapper(_ref) {
8
+ var isRunboxJoinError = _ref.isRunboxJoinError,
9
+ reconnectRunnerRoomWebSocket = _ref.reconnectRunnerRoomWebSocket;
10
+ var _React$useState = React.useState(''),
11
+ _React$useState2 = _slicedToArray(_React$useState, 2),
12
+ roomToken = _React$useState2[0],
13
+ setRoomToken = _React$useState2[1];
14
+ var _React$useState3 = React.useState(''),
15
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
16
+ wsUri = _React$useState4[0],
17
+ setWsUri = _React$useState4[1];
18
+ var _React$useState5 = React.useState(null),
19
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
20
+ runboxUrl = _React$useState6[0],
21
+ setRunboxUrl = _React$useState6[1];
22
+ var _React$useState7 = React.useState(false),
23
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
24
+ isRunboxTerminated = _React$useState8[0],
25
+ setRunboxTerminated = _React$useState8[1];
26
+ var _WSMaterialRunboxLega = WSMaterialRunboxLegacyRunnerRoom.useControls(),
27
+ closeRunnerRoom = _WSMaterialRunboxLega.close;
28
+ var runnerRoomWsStatus = WSMaterialRunboxLegacyRunnerRoom.useReadyState();
29
+ /**
30
+ * Reconnect runbox.
31
+ */
32
+ var reconnect = function reconnect() {
33
+ setRunboxUrl(null);
34
+ setRunboxTerminated(false);
35
+ setTimeout(function () {
36
+ return void reconnectRunnerRoomWebSocket();
37
+ }, RECONNECT_DELAY);
38
+ };
39
+ //
40
+ //
41
+ //
42
+ WSMaterialRunboxLegacyRunnerRoom.useMessage(function (message) {
43
+ switch (message.type) {
44
+ case 'ROOM_PREPARED':
45
+ setRoomToken(message.data.roomToken);
46
+ setWsUri(message.data.forwarder.wsUri);
47
+ setRunboxUrl(message.data.forwarder.httpUri);
48
+ break;
49
+ case 'EXECUTE_DONE':
50
+ closeRunnerRoom();
51
+ setRunboxTerminated(true);
52
+ break;
53
+ }
54
+ }, {
55
+ camelize: true
56
+ });
57
+ //
58
+ // Remove runbox url, when websocket is not open state.
59
+ //
60
+ React.useEffect(function () {
61
+ if (runnerRoomWsStatus !== WebSocket.OPEN) {
62
+ setRunboxUrl(null);
63
+ }
64
+ }, [runnerRoomWsStatus]);
65
+ //
66
+ //
67
+ //
68
+ var isReady = Boolean(wsUri) && Boolean(roomToken);
69
+ return React.createElement(WSMaterialRunboxLegacyStdio.Provider, {
70
+ enable: isReady,
71
+ endpoint: "".concat(wsUri, "/client/stdio"),
72
+ tokenProvider: function () {
73
+ var _tokenProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
74
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
75
+ while (1) switch (_context.prev = _context.next) {
76
+ case 0:
77
+ return _context.abrupt("return", roomToken);
78
+ case 1:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }, _callee);
83
+ }));
84
+ function tokenProvider() {
85
+ return _tokenProvider.apply(this, arguments);
86
+ }
87
+ return tokenProvider;
88
+ }(),
89
+ maxRetries: 5,
90
+ heartAttack: true
91
+ }, isReady ? React.createElement(MaterialRunboxLegacyContent, {
92
+ runboxUrl: runboxUrl,
93
+ isRunboxJoinError: isRunboxJoinError,
94
+ isRunboxTerminated: isRunboxTerminated,
95
+ reconnect: reconnect
96
+ }) : null);
97
+ };
98
+
99
+ export { MaterialRunboxLegacyStdioWrapper as default };
@@ -0,0 +1,2 @@
1
+ export { default as MaterialRunboxLegacy } from './MaterialRunboxLegacy';
2
+ export type { MaterialRunboxLegacyProps } from './MaterialRunboxLegacy';
@@ -0,0 +1,15 @@
1
+ export declare const en: {
2
+ 'runboxLegacy.status.idle': string;
3
+ 'runboxLegacy.status.connecting': string;
4
+ 'runboxLegacy.status.loading': string;
5
+ 'runboxLegacy.status.done': string;
6
+ 'runboxLegacy.status.disconnected': string;
7
+ 'runboxLegacy.status.terminated': string;
8
+ 'runboxLegacy.reloadButton.tooltip': string;
9
+ 'runboxLegacy.overlay.message.terminated': string;
10
+ 'runboxLegacy.overlay.message.error': string;
11
+ 'runboxLegacy.overlay.message.disconnected': string;
12
+ 'runboxLegacy.overlay.message.connecting': string;
13
+ 'runboxLegacy.share.success': string;
14
+ };
15
+ export declare const ko: typeof en;
@@ -0,0 +1,30 @@
1
+ var en = {
2
+ 'runboxLegacy.status.idle': 'Prepare notebook',
3
+ 'runboxLegacy.status.connecting': 'Connecting notebook',
4
+ 'runboxLegacy.status.loading': 'Loading notebook',
5
+ 'runboxLegacy.status.done': 'Connected',
6
+ 'runboxLegacy.status.disconnected': 'Disconnected',
7
+ 'runboxLegacy.status.terminated': 'Terminated',
8
+ 'runboxLegacy.reloadButton.tooltip': 'Reconnecting',
9
+ 'runboxLegacy.overlay.message.terminated': 'The connection has been terminated.\nTo reconnect, click the refresh button at the top.',
10
+ 'runboxLegacy.overlay.message.error': 'An error occurred connecting to the notebook server.\nClose all open notebook windows, please try again in a few minutes.',
11
+ 'runboxLegacy.overlay.message.disconnected': 'Reconnection is being attempted.\nIf the connection is delayed, check the network environment.',
12
+ 'runboxLegacy.overlay.message.connecting': 'Connecting.\nThis may take up to 5 minutes.',
13
+ 'runboxLegacy.share.success': 'Copied share URL to clipboard.'
14
+ };
15
+ var ko = {
16
+ 'runboxLegacy.status.idle': '준비 중...',
17
+ 'runboxLegacy.status.connecting': '페이지 연결 중...',
18
+ 'runboxLegacy.status.loading': '페이지 로드 중...',
19
+ 'runboxLegacy.status.done': '연결됨',
20
+ 'runboxLegacy.status.disconnected': '연결 끊김',
21
+ 'runboxLegacy.status.terminated': '종료됨',
22
+ 'runboxLegacy.reloadButton.tooltip': '재연결 중',
23
+ 'runboxLegacy.overlay.message.terminated': '연결이 종료되었습니다.\n다시 연결하시려면 상단의 새로고침 버튼을 눌려주세요.',
24
+ 'runboxLegacy.overlay.message.error': '노트북 서버에 연결 중 오류가 발생했습니다.\n열려 있는 모든 노트북 창을 닫고, 몇 분 뒤에 다시 시도해 주십시오.',
25
+ 'runboxLegacy.overlay.message.disconnected': '재연결 시도 중 입니다.\n연결이 지연될 시에는 네트워크 환경을 확인해주세요.',
26
+ 'runboxLegacy.overlay.message.connecting': '연결 중 입니다.\n최대 5분까지 소요될 수 있습니다.',
27
+ 'runboxLegacy.share.success': '공유 URL이 클립보드에 복사되었습니다.'
28
+ };
29
+
30
+ export { en, ko };
@@ -0,0 +1,10 @@
1
+ import { EliceWebSocketReact } from '@elice/websocket';
2
+ /**
3
+ * Websocket instance for material runbox runner room.
4
+ * - endpoint: `/runner_room`
5
+ */
6
+ export declare const WSMaterialRunboxLegacyRunnerRoom: EliceWebSocketReact;
7
+ /**
8
+ * Websocket instance for material runbox stdio.
9
+ */
10
+ export declare const WSMaterialRunboxLegacyStdio: EliceWebSocketReact;
@@ -0,0 +1,13 @@
1
+ import { EliceWebSocketReact } from '@elice/websocket';
2
+
3
+ /**
4
+ * Websocket instance for material runbox runner room.
5
+ * - endpoint: `/runner_room`
6
+ */
7
+ var WSMaterialRunboxLegacyRunnerRoom = new EliceWebSocketReact();
8
+ /**
9
+ * Websocket instance for material runbox stdio.
10
+ */
11
+ var WSMaterialRunboxLegacyStdio = new EliceWebSocketReact();
12
+
13
+ export { WSMaterialRunboxLegacyRunnerRoom, WSMaterialRunboxLegacyStdio };
package/es/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './components/material-runbox-legacy';
package/es/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default as MaterialRunboxLegacy } from './components/material-runbox-legacy/MaterialRunboxLegacy.js';