@elice/material-runbox-legacy 1.240718.0-trasncript.2 → 1.240718.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.js +20 -22
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacy.styled.js +1 -5
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.js +171 -250
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.js +6 -10
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.js +43 -80
- package/cjs/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.js +30 -63
- package/cjs/components/material-runbox-legacy/websocket.js +2 -2
- package/es/components/material-runbox-legacy/MaterialRunboxLegacy.js +20 -22
- package/es/components/material-runbox-legacy/MaterialRunboxLegacy.styled.js +1 -1
- package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.js +171 -246
- package/es/components/material-runbox-legacy/MaterialRunboxLegacyContent.styled.js +6 -6
- package/es/components/material-runbox-legacy/MaterialRunboxLegacyRunnerRoomWrapper.js +43 -76
- package/es/components/material-runbox-legacy/MaterialRunboxLegacyStdioWrapper.js +30 -59
- package/es/components/material-runbox-legacy/websocket.js +2 -2
- package/package.json +12 -9
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -383
- package/cjs/components/material-runbox-legacy/index.js +0 -7
- package/cjs/components/material-runbox-legacy/locales/index.js +0 -13
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -374
- package/es/components/material-runbox-legacy/index.js +0 -1
- package/es/components/material-runbox-legacy/locales/index.js +0 -4
|
@@ -2,103 +2,66 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
5
|
var React = require('react');
|
|
8
6
|
var apiClient = require('@elice/api-client');
|
|
9
7
|
var materialSharedUtils = require('@elice/material-shared-utils');
|
|
10
8
|
var MaterialRunboxLegacyStdioWrapper = require('./MaterialRunboxLegacyStdioWrapper.js');
|
|
11
9
|
var websocket = require('./websocket.js');
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
24
|
-
runboxRunningId = _React$useState2[0],
|
|
25
|
-
setRunboxRunningId = _React$useState2[1];
|
|
26
|
-
var _React$useState3 = React__default.default.useState(false),
|
|
27
|
-
_React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
|
|
28
|
-
isRunboxJoinError = _React$useState4[0],
|
|
29
|
-
setRunboxJoinError = _React$useState4[1];
|
|
30
|
-
var _React$useState5 = React__default.default.useState(false),
|
|
31
|
-
_React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
|
|
32
|
-
isRunboxRunningCanceling = _React$useState6[0],
|
|
33
|
-
setRunboxRunningCanceling = _React$useState6[1];
|
|
11
|
+
const MaterialRunboxLegacyRunnerRoomWrapper = ({
|
|
12
|
+
materialRunboxId
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
apiWsOriginUrl
|
|
16
|
+
} = materialSharedUtils.useMaterialConfig();
|
|
17
|
+
const abortCtrlRef = React.useRef(new AbortController());
|
|
18
|
+
const [runboxRunningId, setRunboxRunningId] = React.useState();
|
|
19
|
+
const [isRunboxJoinError, setRunboxJoinError] = React.useState(false);
|
|
20
|
+
const [isRunboxRunningCanceling, setRunboxRunningCanceling] = React.useState(false);
|
|
34
21
|
/**
|
|
35
22
|
* Resolve runner room token.
|
|
36
23
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
throw err;
|
|
55
|
-
}));
|
|
56
|
-
case 4:
|
|
57
|
-
case "end":
|
|
58
|
-
return _context.stop();
|
|
59
|
-
}
|
|
60
|
-
}, _callee);
|
|
61
|
-
})), [materialRunboxId]);
|
|
24
|
+
const resolveRunnerRoomToken = React.useCallback(async () => {
|
|
25
|
+
setRunboxJoinError(false);
|
|
26
|
+
abortCtrlRef.current.abort();
|
|
27
|
+
abortCtrlRef.current = new AbortController();
|
|
28
|
+
return apiClient.postOrgRunnerRoomMaterialRunboxJoin({
|
|
29
|
+
materialRunboxId
|
|
30
|
+
}, {
|
|
31
|
+
signal: abortCtrlRef.current.signal
|
|
32
|
+
}).then(res => {
|
|
33
|
+
setRunboxJoinError(false);
|
|
34
|
+
setRunboxRunningId(res.runboxRunningId);
|
|
35
|
+
return res.roomToken;
|
|
36
|
+
}).catch(err => {
|
|
37
|
+
setRunboxJoinError(true);
|
|
38
|
+
throw err;
|
|
39
|
+
});
|
|
40
|
+
}, [materialRunboxId]);
|
|
62
41
|
/**
|
|
63
42
|
* Reconnect runbox.
|
|
64
43
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
case 2:
|
|
75
|
-
setRunboxRunningCanceling(true);
|
|
76
|
-
return _context2.abrupt("return", apiClient.postOrgMaterialRunboxRunboxRunningCancel({
|
|
77
|
-
runboxRunningId: runboxRunningId
|
|
78
|
-
}).then(function () {
|
|
79
|
-
return setRunboxRunningCanceling(false);
|
|
80
|
-
}).catch(function () {
|
|
81
|
-
return setRunboxRunningCanceling(false);
|
|
82
|
-
}));
|
|
83
|
-
case 4:
|
|
84
|
-
case "end":
|
|
85
|
-
return _context2.stop();
|
|
86
|
-
}
|
|
87
|
-
}, _callee2);
|
|
88
|
-
})), [runboxRunningId]);
|
|
44
|
+
const reconnectRunnerRoomWebSocket = React.useCallback(async () => {
|
|
45
|
+
if (!runboxRunningId) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setRunboxRunningCanceling(true);
|
|
49
|
+
return apiClient.postOrgMaterialRunboxRunboxRunningCancel({
|
|
50
|
+
runboxRunningId
|
|
51
|
+
}).then(() => setRunboxRunningCanceling(false)).catch(() => setRunboxRunningCanceling(false));
|
|
52
|
+
}, [runboxRunningId]);
|
|
89
53
|
//
|
|
90
54
|
//
|
|
91
55
|
//
|
|
92
|
-
return
|
|
56
|
+
return React.createElement(websocket.WSMaterialRunboxLegacyRunnerRoom.Provider, {
|
|
93
57
|
enable: !isRunboxRunningCanceling,
|
|
94
|
-
endpoint:
|
|
58
|
+
endpoint: `${apiWsOriginUrl}/runner_room`,
|
|
95
59
|
tokenProvider: resolveRunnerRoomToken,
|
|
96
|
-
connectionTimeout: 8000
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
60
|
+
connectionTimeout: 8000
|
|
61
|
+
}, React.createElement(MaterialRunboxLegacyStdioWrapper.default, {
|
|
62
|
+
isRunboxJoinError: isRunboxJoinError,
|
|
63
|
+
reconnectRunnerRoomWebSocket: reconnectRunnerRoomWebSocket
|
|
64
|
+
}));
|
|
102
65
|
};
|
|
103
66
|
|
|
104
67
|
exports.default = MaterialRunboxLegacyRunnerRoomWrapper;
|
|
@@ -2,53 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
5
|
var React = require('react');
|
|
8
6
|
var MaterialRunboxLegacyContent = require('./MaterialRunboxLegacyContent.js');
|
|
9
7
|
var websocket = require('./websocket.js');
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
|
|
25
|
-
wsUri = _React$useState4[0],
|
|
26
|
-
setWsUri = _React$useState4[1];
|
|
27
|
-
var _React$useState5 = React__default.default.useState(null),
|
|
28
|
-
_React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
|
|
29
|
-
runboxUrl = _React$useState6[0],
|
|
30
|
-
setRunboxUrl = _React$useState6[1];
|
|
31
|
-
var _React$useState7 = React__default.default.useState(false),
|
|
32
|
-
_React$useState8 = _rollupPluginBabelHelpers.slicedToArray(_React$useState7, 2),
|
|
33
|
-
isRunboxTerminated = _React$useState8[0],
|
|
34
|
-
setRunboxTerminated = _React$useState8[1];
|
|
35
|
-
var _WSMaterialRunboxLega = websocket.WSMaterialRunboxLegacyRunnerRoom.useControls(),
|
|
36
|
-
closeRunnerRoom = _WSMaterialRunboxLega.close;
|
|
37
|
-
var runnerRoomWsStatus = websocket.WSMaterialRunboxLegacyRunnerRoom.useReadyState();
|
|
9
|
+
const RECONNECT_DELAY = 500;
|
|
10
|
+
const MaterialRunboxLegacyStdioWrapper = ({
|
|
11
|
+
isRunboxJoinError,
|
|
12
|
+
reconnectRunnerRoomWebSocket
|
|
13
|
+
}) => {
|
|
14
|
+
const [roomToken, setRoomToken] = React.useState('');
|
|
15
|
+
const [wsUri, setWsUri] = React.useState('');
|
|
16
|
+
const [runboxUrl, setRunboxUrl] = React.useState(null);
|
|
17
|
+
const [isRunboxTerminated, setRunboxTerminated] = React.useState(false);
|
|
18
|
+
const {
|
|
19
|
+
close: closeRunnerRoom
|
|
20
|
+
} = websocket.WSMaterialRunboxLegacyRunnerRoom.useControls();
|
|
21
|
+
const runnerRoomWsStatus = websocket.WSMaterialRunboxLegacyRunnerRoom.useReadyState();
|
|
38
22
|
/**
|
|
39
23
|
* Reconnect runbox.
|
|
40
24
|
*/
|
|
41
|
-
|
|
25
|
+
const reconnect = () => {
|
|
42
26
|
setRunboxUrl(null);
|
|
43
27
|
setRunboxTerminated(false);
|
|
44
|
-
setTimeout(
|
|
45
|
-
return void reconnectRunnerRoomWebSocket();
|
|
46
|
-
}, RECONNECT_DELAY);
|
|
28
|
+
setTimeout(() => void reconnectRunnerRoomWebSocket(), RECONNECT_DELAY);
|
|
47
29
|
};
|
|
48
30
|
//
|
|
49
31
|
//
|
|
50
32
|
//
|
|
51
|
-
websocket.WSMaterialRunboxLegacyRunnerRoom.useMessage(
|
|
33
|
+
websocket.WSMaterialRunboxLegacyRunnerRoom.useMessage(message => {
|
|
52
34
|
switch (message.type) {
|
|
53
35
|
case 'ROOM_PREPARED':
|
|
54
36
|
setRoomToken(message.data.roomToken);
|
|
@@ -60,11 +42,13 @@ var MaterialRunboxLegacyStdioWrapper = function MaterialRunboxLegacyStdioWrapper
|
|
|
60
42
|
setRunboxTerminated(true);
|
|
61
43
|
break;
|
|
62
44
|
}
|
|
45
|
+
}, {
|
|
46
|
+
camelize: true
|
|
63
47
|
});
|
|
64
48
|
//
|
|
65
49
|
// Remove runbox url, when websocket is not open state.
|
|
66
50
|
//
|
|
67
|
-
|
|
51
|
+
React.useEffect(() => {
|
|
68
52
|
if (runnerRoomWsStatus !== WebSocket.OPEN) {
|
|
69
53
|
setRunboxUrl(null);
|
|
70
54
|
}
|
|
@@ -72,36 +56,19 @@ var MaterialRunboxLegacyStdioWrapper = function MaterialRunboxLegacyStdioWrapper
|
|
|
72
56
|
//
|
|
73
57
|
//
|
|
74
58
|
//
|
|
75
|
-
|
|
76
|
-
return
|
|
59
|
+
const isReady = Boolean(wsUri) && Boolean(roomToken);
|
|
60
|
+
return React.createElement(websocket.WSMaterialRunboxLegacyStdio.Provider, {
|
|
77
61
|
enable: isReady,
|
|
78
|
-
endpoint:
|
|
79
|
-
tokenProvider:
|
|
80
|
-
var _tokenProvider = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee() {
|
|
81
|
-
return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
|
|
82
|
-
while (1) switch (_context.prev = _context.next) {
|
|
83
|
-
case 0:
|
|
84
|
-
return _context.abrupt("return", roomToken);
|
|
85
|
-
case 1:
|
|
86
|
-
case "end":
|
|
87
|
-
return _context.stop();
|
|
88
|
-
}
|
|
89
|
-
}, _callee);
|
|
90
|
-
}));
|
|
91
|
-
function tokenProvider() {
|
|
92
|
-
return _tokenProvider.apply(this, arguments);
|
|
93
|
-
}
|
|
94
|
-
return tokenProvider;
|
|
95
|
-
}(),
|
|
62
|
+
endpoint: `${wsUri}/client/stdio`,
|
|
63
|
+
tokenProvider: async () => roomToken,
|
|
96
64
|
maxRetries: 5,
|
|
97
|
-
heartAttack: true
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
65
|
+
heartAttack: true
|
|
66
|
+
}, isReady ? React.createElement(MaterialRunboxLegacyContent.default, {
|
|
67
|
+
runboxUrl: runboxUrl,
|
|
68
|
+
isRunboxJoinError: isRunboxJoinError,
|
|
69
|
+
isRunboxTerminated: isRunboxTerminated,
|
|
70
|
+
reconnect: reconnect
|
|
71
|
+
}) : null);
|
|
105
72
|
};
|
|
106
73
|
|
|
107
74
|
exports.default = MaterialRunboxLegacyStdioWrapper;
|
|
@@ -6,11 +6,11 @@ var websocket = require('@elice/websocket');
|
|
|
6
6
|
* Websocket instance for material runbox runner room.
|
|
7
7
|
* - endpoint: `/runner_room`
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
const WSMaterialRunboxLegacyRunnerRoom = new websocket.EliceWebSocketReact();
|
|
10
10
|
/**
|
|
11
11
|
* Websocket instance for material runbox stdio.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
const WSMaterialRunboxLegacyStdio = new websocket.EliceWebSocketReact();
|
|
14
14
|
|
|
15
15
|
exports.WSMaterialRunboxLegacyRunnerRoom = WSMaterialRunboxLegacyRunnerRoom;
|
|
16
16
|
exports.WSMaterialRunboxLegacyStdio = WSMaterialRunboxLegacyStdio;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { config } from '@elice/api-client';
|
|
3
3
|
import { Flex, Spinner } from '@elice/blocks';
|
|
4
4
|
import { IntlComponentBuilder, RawEliceIntlProvider } from '@elice/intl';
|
|
@@ -8,32 +8,30 @@ import messageKo from './locales/ko.json.js';
|
|
|
8
8
|
import MaterialRunboxLegacyRunnerRoomWrapper from './MaterialRunboxLegacyRunnerRoomWrapper.js';
|
|
9
9
|
import { StyledMaterialRunboxLegacy } from './MaterialRunboxLegacy.styled.js';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const MaterialRunboxLegacy = ({
|
|
12
|
+
materialRunboxId,
|
|
13
|
+
__intl
|
|
14
|
+
}) => {
|
|
15
|
+
const isReady = useMaterialConfigApiClientUpdate(config.init);
|
|
15
16
|
if (!isReady) {
|
|
16
|
-
return
|
|
17
|
+
return React.createElement(Flex, {
|
|
17
18
|
justify: "center",
|
|
18
19
|
align: "center",
|
|
19
20
|
width: "100%",
|
|
20
|
-
height: "100%"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
21
|
+
height: "100%"
|
|
22
|
+
}, React.createElement(Spinner, {
|
|
23
|
+
size: "small"
|
|
24
|
+
}));
|
|
25
25
|
}
|
|
26
|
-
return
|
|
27
|
-
value: __intl
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, materialRunboxId)
|
|
36
|
-
});
|
|
26
|
+
return React.createElement(RawEliceIntlProvider, {
|
|
27
|
+
value: __intl
|
|
28
|
+
}, React.createElement(StyledMaterialRunboxLegacy, {
|
|
29
|
+
key: materialRunboxId
|
|
30
|
+
}, React.createElement(RawEliceIntlProvider, {
|
|
31
|
+
value: __intl
|
|
32
|
+
}, React.createElement(MaterialRunboxLegacyRunnerRoomWrapper, {
|
|
33
|
+
materialRunboxId: materialRunboxId
|
|
34
|
+
}))));
|
|
37
35
|
};
|
|
38
36
|
var MaterialRunboxLegacy$1 = new IntlComponentBuilder(MaterialRunboxLegacy).add('en', messageEn).add('ko', messageKo).addAsync('th', import('./locales/th.json.js')).addAsync('ja', import('./locales/ja.json.js')).build();
|
|
39
37
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const StyledMaterialRunboxLegacy = styled.div.withConfig({
|
|
4
4
|
componentId: "sc-w139i8-0"
|
|
5
5
|
})(["display:flex;flex-direction:column;padding-top:0.5rem;width:100%;height:100%;background-color:#fff;"]);
|
|
6
6
|
|