@elice/material-runbox 1.230328.0 → 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 (84) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +404 -0
  2. package/cjs/assets/queue.gif.js +8 -0
  3. package/cjs/assets/runbox_logo.png.js +8 -0
  4. package/cjs/assets/terminated.png.js +8 -0
  5. package/cjs/components/material-runbox/MaterialRunbox.d.ts +7 -3
  6. package/cjs/components/material-runbox/MaterialRunbox.js +148 -30
  7. package/cjs/components/material-runbox/MaterialRunboxBody.d.ts +4 -0
  8. package/cjs/components/material-runbox/MaterialRunboxBody.js +27 -0
  9. package/cjs/components/material-runbox/MaterialRunboxFooter.d.ts +4 -0
  10. package/cjs/components/material-runbox/MaterialRunboxFooter.js +57 -0
  11. package/cjs/components/material-runbox/MaterialRunboxHeader.d.ts +4 -0
  12. package/cjs/components/material-runbox/MaterialRunboxHeader.js +139 -0
  13. package/cjs/components/material-runbox/context.d.ts +11 -0
  14. package/cjs/components/material-runbox/context.js +12 -0
  15. package/cjs/components/material-runbox/hooks/index.d.ts +2 -0
  16. package/cjs/components/material-runbox/hooks/useMaterialRunboxApi.d.ts +14 -0
  17. package/cjs/components/material-runbox/hooks/useMaterialRunboxApi.js +46 -0
  18. package/cjs/components/material-runbox/hooks/useRunboxControl.d.ts +11 -0
  19. package/cjs/components/material-runbox/hooks/useRunboxControl.js +99 -0
  20. package/cjs/components/material-runbox/runtime/Runtime.d.ts +21 -0
  21. package/cjs/components/material-runbox/runtime/Runtime.js +58 -0
  22. package/cjs/components/material-runbox/runtime/RuntimeOverlayAssigned.d.ts +4 -0
  23. package/cjs/components/material-runbox/runtime/RuntimeOverlayAssigned.js +48 -0
  24. package/cjs/components/material-runbox/runtime/RuntimeOverlayQueued.d.ts +4 -0
  25. package/cjs/components/material-runbox/runtime/RuntimeOverlayQueued.js +63 -0
  26. package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.d.ts +7 -0
  27. package/cjs/components/material-runbox/runtime/RuntimeOverlayTerminated.js +144 -0
  28. package/cjs/index.js +1 -1
  29. package/es/_virtual/_rollupPluginBabelHelpers.js +392 -0
  30. package/es/assets/queue.gif.js +4 -0
  31. package/es/assets/runbox_logo.png.js +4 -0
  32. package/es/assets/terminated.png.js +4 -0
  33. package/es/components/material-runbox/MaterialRunbox.d.ts +7 -3
  34. package/es/components/material-runbox/MaterialRunbox.js +146 -32
  35. package/es/components/material-runbox/MaterialRunboxBody.d.ts +4 -0
  36. package/es/components/material-runbox/MaterialRunboxBody.js +18 -0
  37. package/es/components/material-runbox/MaterialRunboxFooter.d.ts +4 -0
  38. package/es/components/material-runbox/MaterialRunboxFooter.js +48 -0
  39. package/es/components/material-runbox/MaterialRunboxHeader.d.ts +4 -0
  40. package/es/components/material-runbox/MaterialRunboxHeader.js +130 -0
  41. package/es/components/material-runbox/context.d.ts +11 -0
  42. package/es/components/material-runbox/context.js +8 -0
  43. package/es/components/material-runbox/hooks/index.d.ts +2 -0
  44. package/es/components/material-runbox/hooks/useMaterialRunboxApi.d.ts +14 -0
  45. package/es/components/material-runbox/hooks/useMaterialRunboxApi.js +42 -0
  46. package/es/components/material-runbox/hooks/useRunboxControl.d.ts +11 -0
  47. package/es/components/material-runbox/hooks/useRunboxControl.js +95 -0
  48. package/es/components/material-runbox/runtime/Runtime.d.ts +21 -0
  49. package/es/components/material-runbox/runtime/Runtime.js +50 -0
  50. package/es/components/material-runbox/runtime/RuntimeOverlayAssigned.d.ts +4 -0
  51. package/es/components/material-runbox/runtime/RuntimeOverlayAssigned.js +40 -0
  52. package/es/components/material-runbox/runtime/RuntimeOverlayQueued.d.ts +4 -0
  53. package/es/components/material-runbox/runtime/RuntimeOverlayQueued.js +55 -0
  54. package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.d.ts +7 -0
  55. package/es/components/material-runbox/runtime/RuntimeOverlayTerminated.js +136 -0
  56. package/package.json +23 -24
  57. package/cjs/components/material-runbox/MaterialRunbox.styled.d.ts +0 -1
  58. package/cjs/components/material-runbox/MaterialRunbox.styled.js +0 -15
  59. package/cjs/components/material-runbox/MaterialRunboxContent.d.ts +0 -18
  60. package/cjs/components/material-runbox/MaterialRunboxContent.js +0 -305
  61. package/cjs/components/material-runbox/MaterialRunboxContent.styled.d.ts +0 -8
  62. package/cjs/components/material-runbox/MaterialRunboxContent.styled.js +0 -50
  63. package/cjs/components/material-runbox/MaterialRunboxRunnerRoomWrapper.d.ts +0 -6
  64. package/cjs/components/material-runbox/MaterialRunboxRunnerRoomWrapper.js +0 -72
  65. package/cjs/components/material-runbox/MaterialRunboxStdioWrapper.d.ts +0 -7
  66. package/cjs/components/material-runbox/MaterialRunboxStdioWrapper.js +0 -80
  67. package/cjs/components/material-runbox/locales.d.ts +0 -15
  68. package/cjs/components/material-runbox/locales.js +0 -35
  69. package/cjs/components/material-runbox/websocket.d.ts +0 -10
  70. package/cjs/components/material-runbox/websocket.js +0 -20
  71. package/es/components/material-runbox/MaterialRunbox.styled.d.ts +0 -1
  72. package/es/components/material-runbox/MaterialRunbox.styled.js +0 -7
  73. package/es/components/material-runbox/MaterialRunboxContent.d.ts +0 -18
  74. package/es/components/material-runbox/MaterialRunboxContent.js +0 -297
  75. package/es/components/material-runbox/MaterialRunboxContent.styled.d.ts +0 -8
  76. package/es/components/material-runbox/MaterialRunboxContent.styled.js +0 -38
  77. package/es/components/material-runbox/MaterialRunboxRunnerRoomWrapper.d.ts +0 -6
  78. package/es/components/material-runbox/MaterialRunboxRunnerRoomWrapper.js +0 -66
  79. package/es/components/material-runbox/MaterialRunboxStdioWrapper.d.ts +0 -7
  80. package/es/components/material-runbox/MaterialRunboxStdioWrapper.js +0 -74
  81. package/es/components/material-runbox/locales.d.ts +0 -15
  82. package/es/components/material-runbox/locales.js +0 -30
  83. package/es/components/material-runbox/websocket.d.ts +0 -10
  84. package/es/components/material-runbox/websocket.js +0 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-runbox",
3
- "version": "1.230328.0",
3
+ "version": "1.230418.0",
4
4
  "description": "User view and editing components of Elice material runbox",
5
5
  "repository": "https://git.elicer.io/elice/frontend/library/elice-material",
6
6
  "license": "UNLICENSED",
@@ -29,42 +29,41 @@
29
29
  "clean": "del-cli \"es/*\" \"cjs/*\" \"dist/*\""
30
30
  },
31
31
  "peerDependencies": {
32
- "@elice/api-client": "1.230306.1",
33
- "@elice/blocks": "^1.220803.0",
34
- "@elice/design-tokens": "^1.220803.0",
35
- "@elice/icons": "^1.220803.0",
36
- "@elice/markdown": "^1.220803.0",
37
32
  "@elice/material-shared-types": "*",
38
33
  "@elice/material-shared-utils": "*",
39
- "@elice/types": "^1.230306.0",
40
- "@elice/websocket": "^1.220803.0",
34
+ "@elice/openapi-client-material-runbox": "^1.230417.0",
35
+ "@elice/runbox-client": "^1.230412.0",
36
+ "@emotion/react": "^11.10.5",
37
+ "@emotion/styled": "^11.10.5",
38
+ "@mui/icons-material": "^5.10.16",
39
+ "@mui/lab": "^5.0.0-alpha.112",
40
+ "@mui/material": "^5.10.16",
41
+ "notistack": "^3.0.0",
41
42
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
42
43
  "react-intl": "^5.0.0",
43
- "react-use": "^17.0.0",
44
- "styled-components": "^5.2.0"
44
+ "react-use": "^17.0.0"
45
45
  },
46
46
  "dependencies": {
47
+ "@tanstack/react-query": "^4.29.3",
47
48
  "classnames": "^2.2.0",
48
49
  "tslib": "^2.3.1"
49
50
  },
50
51
  "devDependencies": {
51
- "@elice/api-client": "1.230306.1",
52
- "@elice/blocks": "^1.220803.0",
53
- "@elice/design-tokens": "^1.220803.0",
54
- "@elice/icons": "^1.220803.0",
55
- "@elice/icons-legacy": "npm:@elice/icons@0.220803.1",
56
- "@elice/markdown": "^1.220803.0",
57
- "@elice/material-shared-types": "1.230328.0",
58
- "@elice/material-shared-utils": "1.230328.0",
59
- "@elice/types": "^1.230306.0",
60
- "@elice/websocket": "^1.220803.0",
52
+ "@elice/material-shared-types": "1.230418.0",
53
+ "@elice/material-shared-utils": "1.230418.0",
54
+ "@elice/openapi-client-material-runbox": "^1.230417.0",
55
+ "@elice/runbox-client": "^1.230412.0",
56
+ "@emotion/react": "^11.10.5",
57
+ "@emotion/styled": "^11.10.5",
58
+ "@mui/icons-material": "^5.10.16",
59
+ "@mui/lab": "^5.0.0-alpha.112",
60
+ "@mui/material": "^5.10.16",
61
61
  "@types/classnames": "^2.3.1",
62
62
  "@types/react": "~17.0.9",
63
- "@types/styled-components": "^5.1.21",
63
+ "notistack": "^3.0.0",
64
64
  "react": "^17.0.2",
65
65
  "react-intl": "^5.20.10",
66
- "react-use": "^17.2.4",
67
- "styled-components": "^5.3.0"
66
+ "react-use": "^17.2.4"
68
67
  },
69
- "gitHead": "c24abeffe609385031a77c725bf6e92e47e94b56"
68
+ "gitHead": "06d5f856939bdbb6bffa9eba30f2fab56d66129b"
70
69
  }
@@ -1 +0,0 @@
1
- export declare const StyledMaterialRunbox: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var styled = require('styled-components');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
10
-
11
- const StyledMaterialRunbox = styled__default["default"].div.withConfig({
12
- componentId: "sc-2frgib-0"
13
- })(["display:flex;flex-direction:column;padding-top:0.5rem;width:100%;height:100%;background-color:#fff;"]);
14
-
15
- exports.StyledMaterialRunbox = StyledMaterialRunbox;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- export declare enum MaterialRunboxStatus {
3
- Idle = 0,
4
- Connecting = 1,
5
- Loading = 2,
6
- Done = 3,
7
- Disconnected = 4,
8
- Terminated = 5,
9
- Error = 6
10
- }
11
- interface MaterialRunboxContentProps {
12
- runboxUrl: string | null;
13
- isRunboxTerminated: boolean;
14
- isRunboxJoinError: boolean;
15
- reconnect: () => void;
16
- }
17
- declare const MaterialRunboxContent: React.FC<MaterialRunboxContentProps>;
18
- export default MaterialRunboxContent;
@@ -1,305 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var reactIntl = require('react-intl');
7
- var reactUse = require('react-use');
8
- var blocks = require('@elice/blocks');
9
- var icons = require('@elice/icons');
10
- var websocket = require('./websocket.js');
11
- var MaterialRunboxContent_styled = require('./MaterialRunboxContent.styled.js');
12
-
13
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
-
15
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
16
-
17
- /* eslint-disable @typescript-eslint/naming-convention */
18
- exports.MaterialRunboxStatus = void 0;
19
-
20
- (function (MaterialRunboxStatus) {
21
- MaterialRunboxStatus[MaterialRunboxStatus["Idle"] = 0] = "Idle";
22
- MaterialRunboxStatus[MaterialRunboxStatus["Connecting"] = 1] = "Connecting";
23
- MaterialRunboxStatus[MaterialRunboxStatus["Loading"] = 2] = "Loading";
24
- MaterialRunboxStatus[MaterialRunboxStatus["Done"] = 3] = "Done";
25
- MaterialRunboxStatus[MaterialRunboxStatus["Disconnected"] = 4] = "Disconnected";
26
- MaterialRunboxStatus[MaterialRunboxStatus["Terminated"] = 5] = "Terminated";
27
- MaterialRunboxStatus[MaterialRunboxStatus["Error"] = 6] = "Error";
28
- })(exports.MaterialRunboxStatus || (exports.MaterialRunboxStatus = {}));
29
-
30
- const MaterialRunboxContent = ({
31
- runboxUrl,
32
- isRunboxTerminated,
33
- isRunboxJoinError,
34
- reconnect
35
- }) => {
36
- const intl = reactIntl.useIntl();
37
- const [runboxStats, setRunboxStats] = React__default["default"].useState(null);
38
- const [isRunboxUrlLoaded, setRunboxUrlLoaded] = React__default["default"].useState(false);
39
- const isRunboxUrlLoadedPrev = reactUse.usePrevious(isRunboxUrlLoaded);
40
- const [runboxStatus, setRunboxStatus] = React__default["default"].useState(exports.MaterialRunboxStatus.Idle);
41
- const isRunboxPreparing = runboxStatus !== exports.MaterialRunboxStatus.Done && runboxStatus !== exports.MaterialRunboxStatus.Terminated;
42
- websocket.WSMaterialRunboxStdio.useMessage(message => {
43
- if (message.type === 'stats') {
44
- setRunboxStats(message.data);
45
- }
46
- }, {
47
- camelize: true
48
- });
49
-
50
- const handleReconnect = () => {
51
- setRunboxStats(null);
52
- setRunboxUrlLoaded(false);
53
- reconnect();
54
- };
55
-
56
- const handleShare = async () => {
57
- if (!runboxUrl) {
58
- return;
59
- }
60
-
61
- try {
62
- await navigator.clipboard.writeText(runboxUrl);
63
- blocks.Notification.success(intl.formatMessage({
64
- id: 'runbox.share.success'
65
- }));
66
- } catch (e) {
67
- alert(runboxUrl);
68
- }
69
- }; //
70
- // Change `isRunboxUrlLoaded` flag to false, when runbox url removed.
71
- //
72
-
73
-
74
- React__default["default"].useEffect(() => {
75
- if (!runboxUrl) {
76
- setRunboxUrlLoaded(false);
77
- }
78
- }, [runboxUrl]); //
79
- // Determine runbox status.
80
- //
81
-
82
- React__default["default"].useEffect(() => {
83
- setRunboxStatus((() => {
84
- switch (true) {
85
- case isRunboxJoinError:
86
- return exports.MaterialRunboxStatus.Error;
87
-
88
- case !runboxUrl && isRunboxTerminated:
89
- return exports.MaterialRunboxStatus.Terminated;
90
-
91
- case !runboxUrl && !isRunboxTerminated && isRunboxUrlLoadedPrev:
92
- return exports.MaterialRunboxStatus.Disconnected;
93
-
94
- case !runboxUrl && !isRunboxTerminated && !isRunboxUrlLoadedPrev:
95
- return exports.MaterialRunboxStatus.Connecting;
96
-
97
- case Boolean(runboxUrl) && !isRunboxUrlLoaded:
98
- return exports.MaterialRunboxStatus.Loading;
99
-
100
- case Boolean(runboxUrl) && isRunboxUrlLoaded:
101
- return exports.MaterialRunboxStatus.Done;
102
-
103
- default:
104
- return exports.MaterialRunboxStatus.Idle;
105
- }
106
- })());
107
- }, [isRunboxJoinError, isRunboxTerminated, isRunboxUrlLoaded, isRunboxUrlLoadedPrev, runboxUrl]);
108
- /**
109
- * Runbox status message shown at header.
110
- */
111
-
112
- const renderRunboxStatusMessage = () => {
113
- switch (runboxStatus) {
114
- case exports.MaterialRunboxStatus.Idle:
115
- return React__default["default"].createElement(reactIntl.FormattedMessage, {
116
- id: "runbox.status.idle"
117
- });
118
-
119
- case exports.MaterialRunboxStatus.Connecting:
120
- return React__default["default"].createElement(reactIntl.FormattedMessage, {
121
- id: "runbox.status.connecting"
122
- });
123
-
124
- case exports.MaterialRunboxStatus.Loading:
125
- return React__default["default"].createElement(reactIntl.FormattedMessage, {
126
- id: "runbox.status.loading"
127
- });
128
-
129
- case exports.MaterialRunboxStatus.Done:
130
- return React__default["default"].createElement(reactIntl.FormattedMessage, {
131
- id: "runbox.status.done"
132
- });
133
-
134
- case exports.MaterialRunboxStatus.Disconnected:
135
- return React__default["default"].createElement(reactIntl.FormattedMessage, {
136
- id: "runbox.status.disconnected"
137
- });
138
-
139
- case exports.MaterialRunboxStatus.Terminated:
140
- return React__default["default"].createElement(reactIntl.FormattedMessage, {
141
- id: "runbox.status.terminated"
142
- });
143
- }
144
- };
145
- /**
146
- * Header of runbox.
147
- */
148
-
149
-
150
- const renderRunboxHeader = () => {
151
- const runboxStatsInfo = runboxStats ? React__default["default"].createElement(blocks.LaptopOrLarger, null, React__default["default"].createElement(blocks.Flex, null, React__default["default"].createElement(blocks.Flex, {
152
- align: "center"
153
- }, React__default["default"].createElement(blocks.Text, {
154
- size: "tiny",
155
- lineHeight: 1.5,
156
- role: "gray7",
157
- bold: true
158
- }, "CPU:\u00A0"), React__default["default"].createElement(blocks.Flex, {
159
- align: "center",
160
- width: "30px"
161
- }, React__default["default"].createElement(blocks.AntProgress, {
162
- type: "line",
163
- percent: runboxStats.cpu.percent,
164
- status: 'active',
165
- showInfo: false
166
- })), React__default["default"].createElement(blocks.Text, {
167
- size: "tiny",
168
- lineHeight: 1.5,
169
- role: "gray5"
170
- }, "\u00A0", `${runboxStats.cpu.percent.toFixed(0)}%`)), React__default["default"].createElement(blocks.Hspace, {
171
- width: 1
172
- }), React__default["default"].createElement(blocks.Flex, {
173
- align: "center"
174
- }, React__default["default"].createElement(blocks.Text, {
175
- size: "tiny",
176
- lineHeight: 1.5,
177
- role: "gray7",
178
- bold: true
179
- }, "MEM:\u00A0"), React__default["default"].createElement(blocks.Flex, {
180
- align: "center",
181
- width: "30px"
182
- }, React__default["default"].createElement(blocks.AntProgress, {
183
- percent: runboxStats.memory.currentBytes / runboxStats.memory.limitBytes * 100,
184
- status: 'active',
185
- showInfo: false
186
- })), React__default["default"].createElement(blocks.Text, {
187
- size: "tiny",
188
- lineHeight: 1.5,
189
- role: "gray5"
190
- }, "\u00A0", `${(runboxStats.memory.currentBytes / 1024 / 1024).toFixed(0)}M / ${(runboxStats.memory.limitBytes / 1024 / 1024).toFixed(0)}M`)), React__default["default"].createElement(blocks.Hspace, {
191
- width: 1
192
- }), React__default["default"].createElement(blocks.Text, {
193
- size: "tiny",
194
- lineHeight: 1.5,
195
- role: "gray7",
196
- bold: true
197
- }, "DISK:\u00A0"), React__default["default"].createElement(blocks.Text, {
198
- size: "tiny",
199
- lineHeight: 1.5,
200
- role: "gray5"
201
- }, `Read ${(runboxStats.block.rxBytes / 1024 / 1024).toFixed(0)}M Write ${(runboxStats.block.txBytes / 1024 / 1024).toFixed(0)}M`), React__default["default"].createElement(blocks.Hspace, {
202
- width: 1
203
- }), React__default["default"].createElement(blocks.Text, {
204
- size: "tiny",
205
- lineHeight: 1.5,
206
- role: "gray7",
207
- bold: true
208
- }, "NET:\u00A0"), React__default["default"].createElement(blocks.Text, {
209
- size: "tiny",
210
- lineHeight: 1.5,
211
- role: "gray5"
212
- }, `↓${(runboxStats.network.rxBytes / 1024 / 1024).toFixed(0)}M ↑${(runboxStats.network.txBytes / 1024 / 1024).toFixed(0)}M`), React__default["default"].createElement(blocks.Hspace, {
213
- width: 1
214
- }))) : null;
215
- return React__default["default"].createElement(MaterialRunboxContent_styled.RunboxHeader, null, runboxStatsInfo, React__default["default"].createElement(blocks.Flex, {
216
- align: "center"
217
- }, React__default["default"].createElement(MaterialRunboxContent_styled.RunboxStatusLight, {
218
- status: runboxStatus
219
- }), React__default["default"].createElement(blocks.Hspace, {
220
- width: 0.5
221
- }), React__default["default"].createElement(blocks.Text, {
222
- size: "small"
223
- }, renderRunboxStatusMessage())), React__default["default"].createElement(blocks.Hspace, {
224
- width: 1
225
- }), React__default["default"].createElement(blocks.IconButton, {
226
- icon: icons.eilShare,
227
- role: "greyfb",
228
- size: "small",
229
- border: true,
230
- disabled: isRunboxPreparing,
231
- onClick: handleShare
232
- }), React__default["default"].createElement(blocks.Hspace, {
233
- width: 0.5
234
- }), React__default["default"].createElement(blocks.Tooltip, {
235
- title: isRunboxPreparing ? intl.formatMessage({
236
- id: 'runbox.reloadButton.tooltip'
237
- }) : undefined
238
- }, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.IconButton, {
239
- icon: icons.eilReset,
240
- iconSpin: isRunboxPreparing,
241
- role: "greyfb",
242
- size: "small",
243
- border: true,
244
- disabled: isRunboxPreparing,
245
- onClick: handleReconnect
246
- }))));
247
- };
248
- /**
249
- * Body of runbox.
250
- */
251
-
252
-
253
- const renderRunboxBody = () => {
254
- if (runboxStatus === exports.MaterialRunboxStatus.Terminated) {
255
- return React__default["default"].createElement(MaterialRunboxContent_styled.RunboxBody, null, React__default["default"].createElement(MaterialRunboxContent_styled.RunboxBodyOverlay, null, React__default["default"].createElement(blocks.Box, null, React__default["default"].createElement(blocks.Text, {
256
- size: "small",
257
- preWrap: true,
258
- lineHeight: 1.5,
259
- textAlign: "center"
260
- }, React__default["default"].createElement(reactIntl.FormattedMessage, {
261
- id: "runbox.overlay.message.terminated"
262
- })))));
263
- }
264
-
265
- if (runboxStatus === exports.MaterialRunboxStatus.Error) {
266
- return React__default["default"].createElement(MaterialRunboxContent_styled.RunboxBody, null, React__default["default"].createElement(MaterialRunboxContent_styled.RunboxBodyOverlay, null, React__default["default"].createElement(blocks.Box, null, React__default["default"].createElement(blocks.Text, {
267
- size: "small",
268
- preWrap: true,
269
- lineHeight: 1.5,
270
- textAlign: "center"
271
- }, React__default["default"].createElement(reactIntl.FormattedMessage, {
272
- id: "runbox.overlay.message.error"
273
- })))));
274
- }
275
-
276
- return React__default["default"].createElement(MaterialRunboxContent_styled.RunboxBody, null, React__default["default"].createElement(MaterialRunboxContent_styled.RunboxBodyOverlay, {
277
- "aria-hidden": !isRunboxPreparing
278
- }, React__default["default"].createElement(blocks.Box, null, React__default["default"].createElement(blocks.Spinner, null), React__default["default"].createElement(blocks.Vspace, {
279
- height: 1
280
- }), React__default["default"].createElement(blocks.Text, {
281
- size: "small",
282
- preWrap: true,
283
- lineHeight: 1.5,
284
- textAlign: "center"
285
- }, runboxStatus === exports.MaterialRunboxStatus.Disconnected ? React__default["default"].createElement(reactIntl.FormattedMessage, {
286
- id: "runbox.overlay.message.disconnected"
287
- }) : React__default["default"].createElement(reactIntl.FormattedMessage, {
288
- id: "runbox.overlay.message.connecting"
289
- })))), runboxUrl ? React__default["default"].createElement(MaterialRunboxContent_styled.RunboxBodyIframe, {
290
- src: runboxUrl + '/?folder=/mnt/elice/workspace',
291
- title: "material-runbox",
292
- onLoad: () => setRunboxUrlLoaded(true),
293
- allow: "clipboard-read; clipboard-write; camera *; microphone *"
294
- }) : null);
295
- }; //
296
- //
297
- //
298
-
299
-
300
- return React__default["default"].createElement(React__default["default"].Fragment, null, renderRunboxHeader(), React__default["default"].createElement(blocks.Vspace, {
301
- height: 0.5
302
- }), renderRunboxBody());
303
- };
304
-
305
- exports["default"] = MaterialRunboxContent;
@@ -1,8 +0,0 @@
1
- import { MaterialRunboxStatus } from './MaterialRunboxContent';
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: MaterialRunboxStatus;
8
- }, never>;
@@ -1,50 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var designTokens = require('@elice/design-tokens');
6
- var styled = require('styled-components');
7
- var MaterialRunboxContent = require('./MaterialRunboxContent.js');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
12
-
13
- const RunboxHeader = styled__default["default"].div.withConfig({
14
- componentId: "sc-c53ntk-0"
15
- })(["flex:0 0 2.5rem;display:flex;justify-content:flex-end;align-items:center;padding:0 0.5rem;"]);
16
- const RunboxBody = styled__default["default"].div.withConfig({
17
- componentId: "sc-c53ntk-1"
18
- })(["position:relative;flex:1;"]);
19
- const RunboxBodyOverlay = styled__default["default"].div.withConfig({
20
- componentId: "sc-c53ntk-2"
21
- })(["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;}"]);
22
- const RunboxBodyIframe = styled__default["default"].iframe.withConfig({
23
- componentId: "sc-c53ntk-3"
24
- })(["width:100%;height:100%;border:none;"]);
25
- const RunboxStatusLight = styled__default["default"].span.withConfig({
26
- componentId: "sc-c53ntk-4"
27
- })(["display:block;width:0.5rem;height:0.5rem;border-radius:50%;background-color:", ";"], props => {
28
- switch (props.status) {
29
- case MaterialRunboxContent.MaterialRunboxStatus.Loading:
30
- case MaterialRunboxContent.MaterialRunboxStatus.Connecting:
31
- return designTokens.base.color.yellow3;
32
-
33
- case MaterialRunboxContent.MaterialRunboxStatus.Disconnected:
34
- return designTokens.base.color.red7;
35
-
36
- case MaterialRunboxContent.MaterialRunboxStatus.Done:
37
- return designTokens.base.color.green7;
38
-
39
- case MaterialRunboxContent.MaterialRunboxStatus.Idle:
40
- case MaterialRunboxContent.MaterialRunboxStatus.Terminated:
41
- default:
42
- return designTokens.base.color.white;
43
- }
44
- });
45
-
46
- exports.RunboxBody = RunboxBody;
47
- exports.RunboxBodyIframe = RunboxBodyIframe;
48
- exports.RunboxBodyOverlay = RunboxBodyOverlay;
49
- exports.RunboxHeader = RunboxHeader;
50
- exports.RunboxStatusLight = RunboxStatusLight;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- export interface MaterialRunboxRunnerRoomWrapperProps {
3
- materialRunboxId: number;
4
- }
5
- declare const MaterialRunboxRunnerRoomWrapper: React.FC<MaterialRunboxRunnerRoomWrapperProps>;
6
- export default MaterialRunboxRunnerRoomWrapper;
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var apiClient = require('@elice/api-client');
5
- var materialSharedUtils = require('@elice/material-shared-utils');
6
- var MaterialRunboxStdioWrapper = require('./MaterialRunboxStdioWrapper.js');
7
- var websocket = require('./websocket.js');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
-
13
- const MaterialRunboxRunnerRoomWrapper = ({
14
- materialRunboxId
15
- }) => {
16
- const {
17
- apiWsOriginUrl
18
- } = materialSharedUtils.useMaterialConfig();
19
- const abortCtrlRef = React__default["default"].useRef(new AbortController());
20
- const [runboxRunningId, setRunboxRunningId] = React__default["default"].useState();
21
- const [isRunboxJoinError, setRunboxJoinError] = React__default["default"].useState(false);
22
- const [isRunboxRunningCanceling, setRunboxRunningCanceling] = React__default["default"].useState(false);
23
- /**
24
- * Resolve runner room token.
25
- */
26
-
27
- const resolveRunnerRoomToken = React__default["default"].useCallback(async () => {
28
- setRunboxJoinError(false);
29
- abortCtrlRef.current.abort();
30
- abortCtrlRef.current = new AbortController();
31
- return apiClient.postOrgRunnerRoomMaterialRunboxJoin({
32
- materialRunboxId
33
- }, {
34
- signal: abortCtrlRef.current.signal
35
- }).then(res => {
36
- setRunboxJoinError(false);
37
- setRunboxRunningId(res.runboxRunningId);
38
- return res.roomToken;
39
- }).catch(err => {
40
- setRunboxJoinError(true);
41
- throw err;
42
- });
43
- }, [materialRunboxId]);
44
- /**
45
- * Reconnect runbox.
46
- */
47
-
48
- const reconnectRunnerRoomWebSocket = React__default["default"].useCallback(async () => {
49
- if (!runboxRunningId) {
50
- return;
51
- }
52
-
53
- setRunboxRunningCanceling(true);
54
- return apiClient.postOrgMaterialRunboxRunboxRunningCancel({
55
- runboxRunningId
56
- }).then(() => setRunboxRunningCanceling(false)).catch(() => setRunboxRunningCanceling(false));
57
- }, [runboxRunningId]); //
58
- //
59
- //
60
-
61
- return React__default["default"].createElement(websocket.WSMaterialRunboxRunnerRoom.Provider, {
62
- enable: !isRunboxRunningCanceling,
63
- endpoint: `${apiWsOriginUrl}/runner_room`,
64
- tokenProvider: resolveRunnerRoomToken,
65
- connectionTimeout: 8000
66
- }, React__default["default"].createElement(MaterialRunboxStdioWrapper, {
67
- isRunboxJoinError: isRunboxJoinError,
68
- reconnectRunnerRoomWebSocket: reconnectRunnerRoomWebSocket
69
- }));
70
- };
71
-
72
- module.exports = MaterialRunboxRunnerRoomWrapper;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface MaterialRunboxStdioWrapperProps {
3
- isRunboxJoinError: boolean;
4
- reconnectRunnerRoomWebSocket: () => Promise<void>;
5
- }
6
- declare const MaterialRunboxStdioWrapper: React.FC<MaterialRunboxStdioWrapperProps>;
7
- export default MaterialRunboxStdioWrapper;
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var MaterialRunboxContent = require('./MaterialRunboxContent.js');
5
- var websocket = require('./websocket.js');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
-
11
- const RECONNECT_DELAY = 500;
12
-
13
- const MaterialRunboxStdioWrapper = ({
14
- isRunboxJoinError,
15
- reconnectRunnerRoomWebSocket
16
- }) => {
17
- const [roomToken, setRoomToken] = React__default["default"].useState('');
18
- const [wsUri, setWsUri] = React__default["default"].useState('');
19
- const [runboxUrl, setRunboxUrl] = React__default["default"].useState(null);
20
- const [isRunboxTerminated, setRunboxTerminated] = React__default["default"].useState(false);
21
- const {
22
- close: closeRunnerRoom
23
- } = websocket.WSMaterialRunboxRunnerRoom.useControls();
24
- const runnerRoomWsStatus = websocket.WSMaterialRunboxRunnerRoom.useReadyState();
25
- /**
26
- * Reconnect runbox.
27
- */
28
-
29
- const reconnect = () => {
30
- setRunboxUrl(null);
31
- setRunboxTerminated(false);
32
- setTimeout(() => void reconnectRunnerRoomWebSocket(), RECONNECT_DELAY);
33
- }; //
34
- //
35
- //
36
-
37
-
38
- websocket.WSMaterialRunboxRunnerRoom.useMessage(message => {
39
- switch (message.type) {
40
- case 'ROOM_PREPARED':
41
- setRoomToken(message.data.roomToken);
42
- setWsUri(message.data.forwarder.wsUri);
43
- setRunboxUrl(message.data.forwarder.httpUri);
44
- break;
45
-
46
- case 'EXECUTE_DONE':
47
- closeRunnerRoom();
48
- setRunboxTerminated(true);
49
- break;
50
- }
51
- }, {
52
- camelize: true
53
- }); //
54
- // Remove runbox url, when websocket is not open state.
55
- //
56
-
57
- React__default["default"].useEffect(() => {
58
- if (runnerRoomWsStatus !== WebSocket.OPEN) {
59
- setRunboxUrl(null);
60
- }
61
- }, [runnerRoomWsStatus]); //
62
- //
63
- //
64
-
65
- const isReady = Boolean(wsUri) && Boolean(roomToken);
66
- return React__default["default"].createElement(websocket.WSMaterialRunboxStdio.Provider, {
67
- enable: isReady,
68
- endpoint: `${wsUri}/client/stdio`,
69
- tokenProvider: async () => roomToken,
70
- maxRetries: 5,
71
- heartAttack: true
72
- }, isReady ? React__default["default"].createElement(MaterialRunboxContent["default"], {
73
- runboxUrl: runboxUrl,
74
- isRunboxJoinError: isRunboxJoinError,
75
- isRunboxTerminated: isRunboxTerminated,
76
- reconnect: reconnect
77
- }) : null);
78
- };
79
-
80
- module.exports = MaterialRunboxStdioWrapper;
@@ -1,15 +0,0 @@
1
- export declare const en: {
2
- 'runbox.status.idle': string;
3
- 'runbox.status.connecting': string;
4
- 'runbox.status.loading': string;
5
- 'runbox.status.done': string;
6
- 'runbox.status.disconnected': string;
7
- 'runbox.status.terminated': string;
8
- 'runbox.reloadButton.tooltip': string;
9
- 'runbox.overlay.message.terminated': string;
10
- 'runbox.overlay.message.error': string;
11
- 'runbox.overlay.message.disconnected': string;
12
- 'runbox.overlay.message.connecting': string;
13
- 'runbox.share.success': string;
14
- };
15
- export declare const ko: typeof en;