@blocklet/launcher-workflow 2.5.0 → 2.5.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.
- package/es/components/launch-serverless/allocate.js +6 -5
- package/es/components/launch-serverless/shared/common-components.js +4 -298
- package/es/components/launch-serverless/shared/success-display.js +429 -0
- package/es/components/launch-serverless/start-app.js +25 -102
- package/es/locales/en.js +7 -1
- package/es/locales/zh.js +7 -1
- package/es/util.js +1 -1
- package/lib/components/launch-serverless/allocate.js +6 -5
- package/lib/components/launch-serverless/shared/common-components.js +2 -299
- package/lib/components/launch-serverless/shared/success-display.js +440 -0
- package/lib/components/launch-serverless/start-app.js +24 -98
- package/lib/locales/en.js +7 -1
- package/lib/locales/zh.js +7 -1
- package/lib/util.js +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = AppSuccessDisplay;
|
|
7
|
+
var _Img = _interopRequireDefault(require("@arcblock/ux/lib/Img"));
|
|
8
|
+
var _util = require("@blocklet/launcher-util/es/util");
|
|
9
|
+
var _ContentCopy = _interopRequireDefault(require("@mui/icons-material/ContentCopy"));
|
|
10
|
+
var _Dashboard = _interopRequireDefault(require("@mui/icons-material/Dashboard"));
|
|
11
|
+
var _OpenInNew = _interopRequireDefault(require("@mui/icons-material/OpenInNew"));
|
|
12
|
+
var _TaskAlt = _interopRequireDefault(require("@mui/icons-material/TaskAlt"));
|
|
13
|
+
var _material = require("@mui/material");
|
|
14
|
+
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
15
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
16
|
+
var _ahooks = require("ahooks");
|
|
17
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
var _ufo = require("ufo");
|
|
20
|
+
var _locale = require("../../../contexts/locale");
|
|
21
|
+
var _request = _interopRequireDefault(require("../../../contexts/request"));
|
|
22
|
+
var _useSerialPolling = _interopRequireDefault(require("../../../hooks/use-serial-polling"));
|
|
23
|
+
var _util2 = require("../../../util");
|
|
24
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
26
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
31
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
|
+
function AppSuccessDisplay(_ref) {
|
|
33
|
+
var _launchSession$appInf, _launchSession$blockl, _launchSession$appInf2, _launchSession$metada, _state$blockletInfo;
|
|
34
|
+
let {
|
|
35
|
+
accessibleUrl,
|
|
36
|
+
sessionId,
|
|
37
|
+
blockletInfo,
|
|
38
|
+
urls,
|
|
39
|
+
launchSession
|
|
40
|
+
} = _ref;
|
|
41
|
+
const theme = (0, _material.useTheme)();
|
|
42
|
+
const {
|
|
43
|
+
t
|
|
44
|
+
} = (0, _locale.useLocaleContext)();
|
|
45
|
+
const {
|
|
46
|
+
api
|
|
47
|
+
} = (0, _request.default)();
|
|
48
|
+
const [state, setState] = (0, _ahooks.useSetState)({
|
|
49
|
+
accessibleUrls: [accessibleUrl],
|
|
50
|
+
checkingBlockletStatus: true,
|
|
51
|
+
blockletInfo,
|
|
52
|
+
accessibleUrl,
|
|
53
|
+
hasTryStart: false,
|
|
54
|
+
error: null
|
|
55
|
+
});
|
|
56
|
+
const showUrl = (0, _react.useMemo)(() => {
|
|
57
|
+
return localStorage.getItem('show-url') === 'true';
|
|
58
|
+
}, []);
|
|
59
|
+
const checkLaunchSession = async () => {
|
|
60
|
+
try {
|
|
61
|
+
const newBlockletInfo = await (0, _util2.checkBlockletAccessible)(state.accessibleUrl);
|
|
62
|
+
if (!newBlockletInfo) {
|
|
63
|
+
console.warn('the blocklet is not ready or accessible url is not correct, retry getting accessible url');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
setState({
|
|
67
|
+
blockletInfo: newBlockletInfo
|
|
68
|
+
});
|
|
69
|
+
if (newBlockletInfo.status === 'running') {
|
|
70
|
+
setState({
|
|
71
|
+
blockletInfo: newBlockletInfo,
|
|
72
|
+
checkingBlockletStatus: false
|
|
73
|
+
});
|
|
74
|
+
} else if (newBlockletInfo.status === 'starting') {
|
|
75
|
+
if (!state.hasTryStart) {
|
|
76
|
+
setState(prev => {
|
|
77
|
+
if (Date.now() - prev.startTime > 30 * 1000) {
|
|
78
|
+
api.post("/launches/".concat(sessionId, "/start"));
|
|
79
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
80
|
+
hasTryStart: true
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return prev;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
} else if (newBlockletInfo.status === 'stopped') {
|
|
87
|
+
api.post("/launches/".concat(sessionId, "/start"));
|
|
88
|
+
setState({
|
|
89
|
+
hasTryStart: true
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
console.warn('the blocklet is not installed!', newBlockletInfo.status, newBlockletInfo);
|
|
93
|
+
setState({
|
|
94
|
+
error: 'installFailed',
|
|
95
|
+
checkingBlockletStatus: false
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
setState({
|
|
99
|
+
retryRequestCount: 0
|
|
100
|
+
});
|
|
101
|
+
} catch (error) {
|
|
102
|
+
setState(prev => {
|
|
103
|
+
if (prev.retryRequestCount < 5) {
|
|
104
|
+
console.warn('check launch session occurred error, retry', prev.retryRequestCount, error);
|
|
105
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
106
|
+
retryRequestCount: prev.retryRequestCount + 1
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
110
|
+
error: 'installFailed',
|
|
111
|
+
retryRequestCount: 0
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
console.error(error);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// 串行检查,确保前一个请求完成后等待指定时间再发起下一个
|
|
119
|
+
(0, _useSerialPolling.default)({
|
|
120
|
+
isEnabled: state.checkingBlockletStatus,
|
|
121
|
+
interval: 3000,
|
|
122
|
+
onPoll: checkLaunchSession
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// 获取应用基本信息
|
|
126
|
+
const appName = (blockletInfo === null || blockletInfo === void 0 ? void 0 : blockletInfo.appName) || t('startApp.unknownApp');
|
|
127
|
+
const appVersion = (blockletInfo === null || blockletInfo === void 0 ? void 0 : blockletInfo.version) || ((_launchSession$appInf = launchSession.appInfo) === null || _launchSession$appInf === void 0 ? void 0 : _launchSession$appInf.version) || ((_launchSession$blockl = launchSession.blockletMeta) === null || _launchSession$blockl === void 0 ? void 0 : _launchSession$blockl.version) || '';
|
|
128
|
+
const appLogo = (blockletInfo === null || blockletInfo === void 0 ? void 0 : blockletInfo.appLogo) || ((_launchSession$appInf2 = launchSession.appInfo) === null || _launchSession$appInf2 === void 0 ? void 0 : _launchSession$appInf2.appLogo) || '';
|
|
129
|
+
const description = (blockletInfo === null || blockletInfo === void 0 ? void 0 : blockletInfo.appDescription) || ((_launchSession$metada = launchSession.metadata) === null || _launchSession$metada === void 0 ? void 0 : _launchSession$metada.description);
|
|
130
|
+
(0, _react.useEffect)(() => {
|
|
131
|
+
const stepActive = document.querySelector('.step-active');
|
|
132
|
+
if (stepActive) {
|
|
133
|
+
stepActive.classList.add('step-checked');
|
|
134
|
+
}
|
|
135
|
+
}, []);
|
|
136
|
+
(0, _react.useEffect)(() => {
|
|
137
|
+
const checkUrls = urls.filter(url => !state.accessibleUrls.includes(url));
|
|
138
|
+
checkUrls.forEach(url => {
|
|
139
|
+
(0, _util2.checkUrlAccessible)(url, 10 * 60 * 1000).then(res => {
|
|
140
|
+
if (res) {
|
|
141
|
+
setState(prev => {
|
|
142
|
+
const accessible = [...prev.accessibleUrls, url];
|
|
143
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
144
|
+
accessibleUrls: accessible
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}, [state.accessibleUrls, urls, setState]);
|
|
151
|
+
const appUrl = state.accessibleUrls[0] || urls[0];
|
|
152
|
+
const started = ((_state$blockletInfo = state.blockletInfo) === null || _state$blockletInfo === void 0 ? void 0 : _state$blockletInfo.status) === 'running';
|
|
153
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
154
|
+
sx: {
|
|
155
|
+
width: '100%',
|
|
156
|
+
maxWidth: 800,
|
|
157
|
+
margin: '0 auto',
|
|
158
|
+
p: {
|
|
159
|
+
xs: 0,
|
|
160
|
+
sm: 3
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
164
|
+
textAlign: "center",
|
|
165
|
+
mb: 4,
|
|
166
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
167
|
+
sx: {
|
|
168
|
+
width: 80,
|
|
169
|
+
height: 80,
|
|
170
|
+
borderRadius: '50%',
|
|
171
|
+
backgroundColor: started ? (0, _material.alpha)(theme.palette.success.main, 0.2) : (0, _material.alpha)(theme.palette.warning.main, 0.1),
|
|
172
|
+
display: 'flex',
|
|
173
|
+
alignItems: 'center',
|
|
174
|
+
justifyContent: 'center',
|
|
175
|
+
margin: '0 auto 16px',
|
|
176
|
+
transition: 'all 0.3s ease'
|
|
177
|
+
},
|
|
178
|
+
children: started ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_TaskAlt.default, {
|
|
179
|
+
sx: {
|
|
180
|
+
fontSize: 40,
|
|
181
|
+
color: 'success.main'
|
|
182
|
+
}
|
|
183
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
|
|
184
|
+
sx: {
|
|
185
|
+
color: (0, _material.alpha)(theme.palette.warning.main, 0.8)
|
|
186
|
+
},
|
|
187
|
+
size: 40
|
|
188
|
+
})
|
|
189
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
190
|
+
variant: "h3",
|
|
191
|
+
component: "h1",
|
|
192
|
+
fontWeight: "bold",
|
|
193
|
+
gutterBottom: true,
|
|
194
|
+
children: started ? "\uD83C\uDF89 ".concat(t('startApp.started')) : "\uD83D\uDE80 ".concat(t('startApp.starting'))
|
|
195
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
196
|
+
variant: "body1",
|
|
197
|
+
color: "text.secondary",
|
|
198
|
+
children: started ? t('startApp.startedDescription') : t('startApp.startingDescription')
|
|
199
|
+
})]
|
|
200
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
201
|
+
sx: {
|
|
202
|
+
p: 3,
|
|
203
|
+
mb: 3,
|
|
204
|
+
borderRadius: 2,
|
|
205
|
+
border: '1px solid',
|
|
206
|
+
borderColor: 'divider',
|
|
207
|
+
backgroundColor: 'background.paper'
|
|
208
|
+
},
|
|
209
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
210
|
+
display: "flex",
|
|
211
|
+
alignItems: "center",
|
|
212
|
+
gap: 2,
|
|
213
|
+
mb: 2,
|
|
214
|
+
flexWrap: "wrap",
|
|
215
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
216
|
+
flex: 1,
|
|
217
|
+
display: "flex",
|
|
218
|
+
alignItems: "center",
|
|
219
|
+
gap: 2,
|
|
220
|
+
children: [appLogo ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Img.default, {
|
|
221
|
+
src: (0, _ufo.joinURL)(appUrl, appLogo),
|
|
222
|
+
alt: appName,
|
|
223
|
+
width: 48,
|
|
224
|
+
height: 48,
|
|
225
|
+
style: {
|
|
226
|
+
borderRadius: 10,
|
|
227
|
+
overflow: 'hidden'
|
|
228
|
+
}
|
|
229
|
+
}, appUrl) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
230
|
+
flex: 1,
|
|
231
|
+
textAlign: "left",
|
|
232
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
233
|
+
variant: "h6",
|
|
234
|
+
color: "text.hint",
|
|
235
|
+
mb: 1,
|
|
236
|
+
children: t('startApp.projectName')
|
|
237
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
238
|
+
variant: "body1",
|
|
239
|
+
fontWeight: "medium",
|
|
240
|
+
children: appName
|
|
241
|
+
})]
|
|
242
|
+
})]
|
|
243
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
244
|
+
flex: 1,
|
|
245
|
+
display: "flex",
|
|
246
|
+
alignItems: "center",
|
|
247
|
+
gap: 2,
|
|
248
|
+
minWidth: {
|
|
249
|
+
xs: '100%',
|
|
250
|
+
sm: 'auto'
|
|
251
|
+
},
|
|
252
|
+
children: [appVersion ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
253
|
+
flex: 1,
|
|
254
|
+
textAlign: "left",
|
|
255
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
256
|
+
variant: "h6",
|
|
257
|
+
color: "text.hint",
|
|
258
|
+
mb: 1,
|
|
259
|
+
children: t('startApp.version')
|
|
260
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
|
|
261
|
+
label: "v".concat(appVersion),
|
|
262
|
+
size: "small",
|
|
263
|
+
color: "primary",
|
|
264
|
+
variant: "outlined"
|
|
265
|
+
})]
|
|
266
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
267
|
+
flex: 1,
|
|
268
|
+
textAlign: "left",
|
|
269
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
270
|
+
variant: "h6",
|
|
271
|
+
color: "text.hint",
|
|
272
|
+
mb: 1,
|
|
273
|
+
children: t('startApp.status')
|
|
274
|
+
}), started ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
|
|
275
|
+
label: t('startApp.running'),
|
|
276
|
+
size: "small",
|
|
277
|
+
color: "success"
|
|
278
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
|
|
279
|
+
label: t('startApp.startingText'),
|
|
280
|
+
size: "small",
|
|
281
|
+
color: "warning",
|
|
282
|
+
sx: {
|
|
283
|
+
animation: 'pulse 2s infinite',
|
|
284
|
+
'@keyframes pulse': {
|
|
285
|
+
'0%': {
|
|
286
|
+
opacity: 0.85
|
|
287
|
+
},
|
|
288
|
+
'50%': {
|
|
289
|
+
opacity: 0.7
|
|
290
|
+
},
|
|
291
|
+
'100%': {
|
|
292
|
+
opacity: 0.85
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
})]
|
|
297
|
+
})]
|
|
298
|
+
})]
|
|
299
|
+
}), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
300
|
+
variant: "body2",
|
|
301
|
+
color: "text.secondary",
|
|
302
|
+
textAlign: "left",
|
|
303
|
+
children: description
|
|
304
|
+
}), showUrl && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
305
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
306
|
+
variant: "h6",
|
|
307
|
+
color: "text.hint",
|
|
308
|
+
textAlign: "left",
|
|
309
|
+
children: t('startApp.visitUrl')
|
|
310
|
+
}), urls.map(url => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
311
|
+
display: "flex",
|
|
312
|
+
alignItems: "center",
|
|
313
|
+
mt: 1,
|
|
314
|
+
gap: 1,
|
|
315
|
+
sx: {
|
|
316
|
+
backgroundColor: 'divider',
|
|
317
|
+
borderRadius: 1,
|
|
318
|
+
py: 0.5,
|
|
319
|
+
px: 1.5,
|
|
320
|
+
flex: 1
|
|
321
|
+
},
|
|
322
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
323
|
+
sx: {
|
|
324
|
+
width: 8,
|
|
325
|
+
height: 8,
|
|
326
|
+
borderRadius: '50%',
|
|
327
|
+
backgroundColor: state.accessibleUrls.includes(url) ? 'success.main' : 'error.main'
|
|
328
|
+
}
|
|
329
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
330
|
+
variant: "body2",
|
|
331
|
+
textAlign: "left",
|
|
332
|
+
sx: {
|
|
333
|
+
flex: 1,
|
|
334
|
+
fontSize: '0.875rem',
|
|
335
|
+
wordBreak: 'break-all'
|
|
336
|
+
},
|
|
337
|
+
children: url
|
|
338
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
339
|
+
size: "small",
|
|
340
|
+
onClick: () => navigator.clipboard.writeText(url),
|
|
341
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ContentCopy.default, {
|
|
342
|
+
sx: {
|
|
343
|
+
fontSize: 16
|
|
344
|
+
}
|
|
345
|
+
})
|
|
346
|
+
})]
|
|
347
|
+
}, url))]
|
|
348
|
+
})]
|
|
349
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
350
|
+
display: "flex",
|
|
351
|
+
flexDirection: "column",
|
|
352
|
+
gap: 2,
|
|
353
|
+
mt: 4,
|
|
354
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
355
|
+
display: "flex",
|
|
356
|
+
flexDirection: "column",
|
|
357
|
+
gap: 2,
|
|
358
|
+
alignItems: "center",
|
|
359
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
360
|
+
display: "flex",
|
|
361
|
+
gap: 2,
|
|
362
|
+
margin: "0 auto",
|
|
363
|
+
flexDirection: {
|
|
364
|
+
xs: 'column-reverse',
|
|
365
|
+
md: 'row'
|
|
366
|
+
},
|
|
367
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
368
|
+
variant: "outlined",
|
|
369
|
+
sx: {
|
|
370
|
+
minWidth: 220
|
|
371
|
+
},
|
|
372
|
+
color: "primary",
|
|
373
|
+
onClick: () => window.open((0, _ufo.joinURL)((0, _util.getBaseURL)(), "/api/launches/".concat(sessionId, "/redirect/dashboard?appUrl=").concat(appUrl, "&appDid=").concat(blockletInfo.appPid, "&ownerDid=").concat(blockletInfo.ownerDid)), '_blank'),
|
|
374
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dashboard.default, {
|
|
375
|
+
sx: {
|
|
376
|
+
fontSize: 24,
|
|
377
|
+
color: 'primary.main'
|
|
378
|
+
}
|
|
379
|
+
}),
|
|
380
|
+
children: t('startApp.dashboard')
|
|
381
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
382
|
+
variant: "contained",
|
|
383
|
+
color: started ? 'primary' : 'inherit',
|
|
384
|
+
disabled: !started,
|
|
385
|
+
sx: {
|
|
386
|
+
minWidth: 220,
|
|
387
|
+
opacity: started ? 1 : 0.7,
|
|
388
|
+
transform: started ? 'scale(1)' : 'scale(0.98)',
|
|
389
|
+
transition: 'all 0.4s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
390
|
+
background: started ? undefined : "linear-gradient(45deg, ".concat((0, _material.alpha)(theme.palette.primary.main, 0.1), ", ").concat((0, _material.alpha)(theme.palette.primary.main, 0.2), ")"),
|
|
391
|
+
'&:disabled': {
|
|
392
|
+
color: theme.palette.text.secondary
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
onClick: () => started && window.open((0, _ufo.joinURL)((0, _util.getBaseURL)(), "/api/launches/".concat(sessionId, "/redirect/app?appUrl=").concat(appUrl, "&appDid=").concat(blockletInfo.appPid, "&ownerDid=").concat(blockletInfo.ownerDid)), '_blank'),
|
|
396
|
+
startIcon: started ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_OpenInNew.default, {
|
|
397
|
+
sx: {
|
|
398
|
+
fontSize: 24,
|
|
399
|
+
color: 'inherit'
|
|
400
|
+
}
|
|
401
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_OpenInNew.default, {
|
|
402
|
+
sx: {
|
|
403
|
+
fontSize: 24,
|
|
404
|
+
color: 'inherit',
|
|
405
|
+
opacity: 0.5
|
|
406
|
+
}
|
|
407
|
+
}),
|
|
408
|
+
children: started ? t('startApp.visitApp') : t('startApp.preparing')
|
|
409
|
+
})]
|
|
410
|
+
})
|
|
411
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
412
|
+
variant: "body2",
|
|
413
|
+
color: "text.secondary",
|
|
414
|
+
sx: {
|
|
415
|
+
margin: '0 auto',
|
|
416
|
+
fontWeight: 400,
|
|
417
|
+
cursor: 'pointer',
|
|
418
|
+
display: 'flex',
|
|
419
|
+
alignItems: 'center',
|
|
420
|
+
gap: 0.5,
|
|
421
|
+
opacity: 0.8
|
|
422
|
+
},
|
|
423
|
+
onClick: () => window.open((0, _util.getSubscriptionLink)(launchSession.subscriptionId), '_blank'),
|
|
424
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_OpenInNew.default, {
|
|
425
|
+
sx: {
|
|
426
|
+
fontSize: 14,
|
|
427
|
+
color: 'inherit'
|
|
428
|
+
}
|
|
429
|
+
}), t('startApp.subscription')]
|
|
430
|
+
})]
|
|
431
|
+
})]
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
AppSuccessDisplay.propTypes = {
|
|
435
|
+
launchSession: _propTypes.default.object.isRequired,
|
|
436
|
+
urls: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
437
|
+
accessibleUrl: _propTypes.default.string.isRequired,
|
|
438
|
+
sessionId: _propTypes.default.string.isRequired,
|
|
439
|
+
blockletInfo: _propTypes.default.object.isRequired
|
|
440
|
+
};
|
|
@@ -15,6 +15,7 @@ var _useSerialPolling = _interopRequireDefault(require("../../hooks/use-serial-p
|
|
|
15
15
|
var _util = require("../../util");
|
|
16
16
|
var _baseServerlessLayout = _interopRequireDefault(require("./shared/base-serverless-layout"));
|
|
17
17
|
var _commonComponents = require("./shared/common-components");
|
|
18
|
+
var _successDisplay = _interopRequireDefault(require("./shared/success-display"));
|
|
18
19
|
var _loadingDisplayLayout = _interopRequireDefault(require("./shared/loading-display-layout"));
|
|
19
20
|
var _retryErrorMessage = _interopRequireDefault(require("./shared/retry-error-message"));
|
|
20
21
|
var _useWorkflowProgress = _interopRequireDefault(require("./shared/use-workflow-progress"));
|
|
@@ -58,26 +59,20 @@ function StartApp(_ref) {
|
|
|
58
59
|
const actions = (0, _react.useMemo)(() => {
|
|
59
60
|
// 基础步骤时间
|
|
60
61
|
const steps = [{
|
|
61
|
-
message: t('startApp.waiting.starting'),
|
|
62
|
-
time: 5
|
|
63
|
-
}, {
|
|
64
|
-
message: t('startApp.waiting.parsing'),
|
|
65
|
-
time: 1
|
|
66
|
-
}, {
|
|
67
62
|
message: t('startApp.waiting.initializing'),
|
|
68
|
-
time:
|
|
63
|
+
time: 1
|
|
69
64
|
}, {
|
|
70
65
|
message: t('startApp.waiting.initializingOwner'),
|
|
71
|
-
time:
|
|
66
|
+
time: 1
|
|
72
67
|
}, {
|
|
73
68
|
message: t('startApp.waiting.creatingSecurityRules'),
|
|
74
|
-
time:
|
|
69
|
+
time: 1
|
|
75
70
|
}, {
|
|
76
71
|
message: t('startApp.waiting.assigningDomain'),
|
|
77
|
-
time:
|
|
72
|
+
time: 1
|
|
78
73
|
}, {
|
|
79
74
|
message: t('startApp.waiting.waitingForDomain'),
|
|
80
|
-
time:
|
|
75
|
+
time: 1
|
|
81
76
|
}];
|
|
82
77
|
|
|
83
78
|
// 计算总时间
|
|
@@ -98,7 +93,7 @@ function StartApp(_ref) {
|
|
|
98
93
|
var _window$blockletMeta;
|
|
99
94
|
const components = ((_window$blockletMeta = window.blockletMeta) === null || _window$blockletMeta === void 0 ? void 0 : _window$blockletMeta.components) || [];
|
|
100
95
|
const additionalTime = (0, _commonComponents.calculateEstimatedTime)(components);
|
|
101
|
-
return actions.reduce((acc, action) => acc + action.time, 0) + additionalTime;
|
|
96
|
+
return actions.reduce((acc, action) => acc + action.time, 0) + Math.ceil(additionalTime * 0.4);
|
|
102
97
|
}, [actions]);
|
|
103
98
|
const {
|
|
104
99
|
time,
|
|
@@ -124,8 +119,11 @@ function StartApp(_ref) {
|
|
|
124
119
|
};
|
|
125
120
|
const checkOneAccessibleUrl = async urls => {
|
|
126
121
|
try {
|
|
127
|
-
const [accessibleUrl] = await (0, _util.waitingForRaceAccessible)(urls);
|
|
128
|
-
return
|
|
122
|
+
const [accessibleUrl, blockletInfo] = await (0, _util.waitingForRaceAccessible)(urls);
|
|
123
|
+
return {
|
|
124
|
+
accessibleUrl,
|
|
125
|
+
blockletInfo
|
|
126
|
+
};
|
|
129
127
|
} catch (error) {
|
|
130
128
|
console.error(error);
|
|
131
129
|
return null;
|
|
@@ -154,85 +152,6 @@ function StartApp(_ref) {
|
|
|
154
152
|
}
|
|
155
153
|
return urls;
|
|
156
154
|
}, [state, setState]);
|
|
157
|
-
const checkLaunchSession = async () => {
|
|
158
|
-
try {
|
|
159
|
-
const {
|
|
160
|
-
accessibleUrl
|
|
161
|
-
} = state;
|
|
162
|
-
if (!accessibleUrl) {
|
|
163
|
-
console.warn('the accessible url is not ready, retry getting accessible url');
|
|
164
|
-
setState({
|
|
165
|
-
checkingAccessible: true,
|
|
166
|
-
checkingBlockletStatus: false
|
|
167
|
-
});
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
const blockletInfo = await (0, _util.checkBlockletAccessible)(accessibleUrl);
|
|
171
|
-
if (!blockletInfo) {
|
|
172
|
-
console.warn('the blocklet is not ready or accessible url is not correct, retry getting accessible url');
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
setState({
|
|
176
|
-
blockletInfo
|
|
177
|
-
});
|
|
178
|
-
if (blockletInfo.status === 'running') {
|
|
179
|
-
setState({
|
|
180
|
-
blockletInfo,
|
|
181
|
-
starting: false,
|
|
182
|
-
started: true,
|
|
183
|
-
checkingBlockletStatus: false,
|
|
184
|
-
checkingAccessible: false,
|
|
185
|
-
isLoading: false
|
|
186
|
-
});
|
|
187
|
-
} else if (blockletInfo.status === 'starting') {
|
|
188
|
-
if (!state.hasTryStart) {
|
|
189
|
-
setState(prev => {
|
|
190
|
-
if (Date.now() - prev.startTime > estimatedTime * 1000) {
|
|
191
|
-
api.post("/launches/".concat(sessionId, "/start"));
|
|
192
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
193
|
-
hasTryStart: true
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
return prev;
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
} else if (blockletInfo.status === 'stopped') {
|
|
200
|
-
api.post("/launches/".concat(sessionId, "/start"));
|
|
201
|
-
} else {
|
|
202
|
-
console.warn('the blocklet is not installed!', blockletInfo.status, blockletInfo);
|
|
203
|
-
setState({
|
|
204
|
-
error: 'installFailed',
|
|
205
|
-
starting: false,
|
|
206
|
-
checkingBlockletStatus: false
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
setState({
|
|
210
|
-
retryRequestCount: 0
|
|
211
|
-
});
|
|
212
|
-
} catch (error) {
|
|
213
|
-
setState(prev => {
|
|
214
|
-
if (prev.retryRequestCount < 5) {
|
|
215
|
-
console.warn('check launch session occurred error, retry', prev.retryRequestCount, error);
|
|
216
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
217
|
-
retryRequestCount: prev.retryRequestCount + 1
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
221
|
-
error: 'installFailed',
|
|
222
|
-
starting: false,
|
|
223
|
-
retryRequestCount: 0
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
console.error(error);
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
// 串行检查,确保前一个请求完成后等待指定时间再发起下一个
|
|
231
|
-
(0, _useSerialPolling.default)({
|
|
232
|
-
isEnabled: state.checkingBlockletStatus,
|
|
233
|
-
interval: CHECK_INTERVAL,
|
|
234
|
-
onPoll: checkLaunchSession
|
|
235
|
-
});
|
|
236
155
|
|
|
237
156
|
// 检查可用性 url
|
|
238
157
|
const checkAccessibleUrls = async () => {
|
|
@@ -248,12 +167,19 @@ function StartApp(_ref) {
|
|
|
248
167
|
});
|
|
249
168
|
return;
|
|
250
169
|
}
|
|
251
|
-
const
|
|
170
|
+
const {
|
|
171
|
+
accessibleUrl,
|
|
172
|
+
blockletInfo
|
|
173
|
+
} = await checkOneAccessibleUrl(urls);
|
|
252
174
|
setState(prev => {
|
|
253
175
|
const obj = accessibleUrl ? _objectSpread(_objectSpread({}, prev), {}, {
|
|
176
|
+
starting: false,
|
|
177
|
+
started: true,
|
|
178
|
+
isLoading: false,
|
|
254
179
|
checkingAccessible: false,
|
|
255
|
-
checkingBlockletStatus:
|
|
256
|
-
accessibleUrl
|
|
180
|
+
checkingBlockletStatus: false,
|
|
181
|
+
accessibleUrl,
|
|
182
|
+
blockletInfo
|
|
257
183
|
}) : prev;
|
|
258
184
|
if (Date.now() - prev.startTime > estimatedTime * 1000 && !prev.hasTryStart) {
|
|
259
185
|
api.post("/launches/".concat(sessionId, "/start"));
|
|
@@ -269,7 +195,7 @@ function StartApp(_ref) {
|
|
|
269
195
|
};
|
|
270
196
|
(0, _useSerialPolling.default)({
|
|
271
197
|
isEnabled: state.checkingAccessible,
|
|
272
|
-
interval:
|
|
198
|
+
interval: CHECK_INTERVAL,
|
|
273
199
|
onPoll: checkAccessibleUrls
|
|
274
200
|
});
|
|
275
201
|
(0, _react.useEffect)(() => {
|
|
@@ -409,7 +335,7 @@ function StartApp(_ref) {
|
|
|
409
335
|
currentAction: getCurrentAction(displayProgress),
|
|
410
336
|
error: null,
|
|
411
337
|
onRetry: null
|
|
412
|
-
}), showSuccess && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
338
|
+
}), showSuccess && /*#__PURE__*/(0, _jsxRuntime.jsx)(_successDisplay.default, {
|
|
413
339
|
accessibleUrl: state.accessibleUrl,
|
|
414
340
|
sessionId: sessionId,
|
|
415
341
|
blockletInfo: state.blockletInfo,
|
package/lib/locales/en.js
CHANGED
|
@@ -97,13 +97,17 @@ var _default = exports.default = {
|
|
|
97
97
|
},
|
|
98
98
|
startApp: {
|
|
99
99
|
pageTitle: 'Start Blocklet',
|
|
100
|
-
starting: 'Starting Blocklet...',
|
|
101
100
|
started: 'Blocklet is ready to use!',
|
|
102
101
|
startedDescription: 'Your blocklet has been successfully started and is now ready to use.',
|
|
102
|
+
starting: 'Blocklet is starting up',
|
|
103
|
+
startingDescription: 'Your blocklet is starting up and will be ready shortly. Please wait a moment.',
|
|
104
|
+
startingTitle: 'Almost there!',
|
|
105
|
+
startingWaitMessage: 'Your blocklet is starting and will be accessible in a moment. You can access the management panel to monitor the progress.',
|
|
103
106
|
startFailed: 'Start Blocklet Failed',
|
|
104
107
|
installFailed: 'Install Blocklet Failed',
|
|
105
108
|
visit: 'Visit Blocklet',
|
|
106
109
|
dashboard: 'View Blocklet Dashboard',
|
|
110
|
+
managementPanel: 'Management Panel',
|
|
107
111
|
subscription: 'Manage Subscription',
|
|
108
112
|
unknownApp: 'Unknown Blocklet',
|
|
109
113
|
appInfo: 'Blocklet Information',
|
|
@@ -112,9 +116,11 @@ var _default = exports.default = {
|
|
|
112
116
|
status: 'Status',
|
|
113
117
|
version: 'Version',
|
|
114
118
|
running: 'Running',
|
|
119
|
+
startingText: 'Starting',
|
|
115
120
|
projectName: 'Project Name',
|
|
116
121
|
visitUrl: 'Visit URL',
|
|
117
122
|
visitApp: 'Visit Blocklet',
|
|
123
|
+
preparing: 'Preparing...',
|
|
118
124
|
waiting: {
|
|
119
125
|
starting: 'Starting blocklet...',
|
|
120
126
|
parsing: 'Parsing blocklet metadata...',
|
package/lib/locales/zh.js
CHANGED
|
@@ -96,13 +96,17 @@ var _default = exports.default = {
|
|
|
96
96
|
},
|
|
97
97
|
startApp: {
|
|
98
98
|
pageTitle: '启动 Blocklet',
|
|
99
|
-
starting: '正在启动 Blocklet...',
|
|
100
99
|
started: 'Blocklet 启动成功',
|
|
101
100
|
startedDescription: '您的 Blocklet 已成功启动并准备就绪,现在可以开始使用了。',
|
|
101
|
+
starting: 'Blocklet 正在启动',
|
|
102
|
+
startingDescription: '您的 Blocklet 正在启动中,很快就可以使用了,请稍等片刻。',
|
|
103
|
+
startingTitle: '即将完成!',
|
|
104
|
+
startingWaitMessage: '您的 Blocklet 正在启动中,稍后即可访问。您可以先进入管理面板查看启动进度。',
|
|
102
105
|
startFailed: '启动 Blocklet 失败',
|
|
103
106
|
installFailed: '安装 Blocklet 失败',
|
|
104
107
|
visit: '访问 Blocklet',
|
|
105
108
|
dashboard: '查看 Blocklet 仪表盘',
|
|
109
|
+
managementPanel: '管理面板',
|
|
106
110
|
subscription: '管理订阅',
|
|
107
111
|
unknownApp: '未知 Blocklet',
|
|
108
112
|
appInfo: 'Blocklet 信息',
|
|
@@ -111,9 +115,11 @@ var _default = exports.default = {
|
|
|
111
115
|
status: '状态',
|
|
112
116
|
version: '版本',
|
|
113
117
|
running: '运行中',
|
|
118
|
+
startingText: '启动中',
|
|
114
119
|
projectName: '项目名称',
|
|
115
120
|
visitUrl: '访问地址',
|
|
116
121
|
visitApp: '访问 Blocklet',
|
|
122
|
+
preparing: '准备中...',
|
|
117
123
|
waiting: {
|
|
118
124
|
starting: '正在启动 Blocklet...',
|
|
119
125
|
parsing: '正在解析 Blocklet 元数据...',
|