@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
|
@@ -46,16 +46,16 @@ function Allocate(_ref) {
|
|
|
46
46
|
// 基础步骤时间
|
|
47
47
|
const steps = [{
|
|
48
48
|
message: t('launch.waiting.starting'),
|
|
49
|
-
time:
|
|
49
|
+
time: 1
|
|
50
50
|
}, {
|
|
51
51
|
message: t('launch.waiting.securing'),
|
|
52
|
-
time:
|
|
52
|
+
time: 1
|
|
53
53
|
}, {
|
|
54
54
|
message: t('launch.waiting.prepare'),
|
|
55
|
-
time:
|
|
55
|
+
time: 1
|
|
56
56
|
}, {
|
|
57
57
|
message: t('launch.waiting.waiting'),
|
|
58
|
-
time:
|
|
58
|
+
time: 1.5
|
|
59
59
|
}, {
|
|
60
60
|
message: t('launch.waiting.done'),
|
|
61
61
|
time: 0.5
|
|
@@ -151,7 +151,8 @@ function Allocate(_ref) {
|
|
|
151
151
|
const timers = Object.values(timerRef.current); // eslint-disable-line react-hooks/exhaustive-deps
|
|
152
152
|
timers.forEach(timer => clearTimeout(timer));
|
|
153
153
|
};
|
|
154
|
-
}, [
|
|
154
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
155
|
+
|
|
155
156
|
const handleRetry = async () => {
|
|
156
157
|
try {
|
|
157
158
|
var _state$launchSession;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ActionCardBox = ActionCardBox;
|
|
7
|
-
exports.AppSuccessDisplay = AppSuccessDisplay;
|
|
8
7
|
exports.ErrorDisplay = ErrorDisplay;
|
|
9
8
|
exports.LoadingContainer = LoadingContainer;
|
|
10
9
|
exports.ProductIntroCarousel = ProductIntroCarousel;
|
|
@@ -14,20 +13,11 @@ exports.calculateEstimatedTime = void 0;
|
|
|
14
13
|
exports.proxyUrl = proxyUrl;
|
|
15
14
|
exports.useDisplayProgress = useDisplayProgress;
|
|
16
15
|
exports.useFormatTime = exports.useElapsedTime = void 0;
|
|
17
|
-
var _Img = _interopRequireDefault(require("@arcblock/ux/lib/Img"));
|
|
18
|
-
var _util = require("@blocklet/launcher-util/es/util");
|
|
19
|
-
var _ContentCopy = _interopRequireDefault(require("@mui/icons-material/ContentCopy"));
|
|
20
|
-
var _Dashboard = _interopRequireDefault(require("@mui/icons-material/Dashboard"));
|
|
21
|
-
var _OpenInNew = _interopRequireDefault(require("@mui/icons-material/OpenInNew"));
|
|
22
|
-
var _TaskAlt = _interopRequireDefault(require("@mui/icons-material/TaskAlt"));
|
|
23
16
|
var _material = require("@mui/material");
|
|
24
|
-
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
25
|
-
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
26
17
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
28
19
|
var _ufo = require("ufo");
|
|
29
20
|
var _locale = require("../../../contexts/locale");
|
|
30
|
-
var _util2 = require("../../../util");
|
|
31
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
32
22
|
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); }
|
|
33
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -37,8 +27,8 @@ function proxyUrl(url) {
|
|
|
37
27
|
}
|
|
38
28
|
return "".concat(window.location.origin, "/.well-known/service/proxy?url=").concat(url);
|
|
39
29
|
}
|
|
40
|
-
const COMPONENT_BASE_TIME =
|
|
41
|
-
const SIZE_TIME_RATIO = 0.
|
|
30
|
+
const COMPONENT_BASE_TIME = 1; // 每个组件基础处理时间 1s
|
|
31
|
+
const SIZE_TIME_RATIO = 0.1; // 每 1MB 增加 0.2s
|
|
42
32
|
// 计算预估安装时间
|
|
43
33
|
const calculateEstimatedTime = exports.calculateEstimatedTime = function calculateEstimatedTime() {
|
|
44
34
|
let components = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -312,291 +302,4 @@ function ErrorDisplay(_ref6) {
|
|
|
312
302
|
ErrorDisplay.propTypes = {
|
|
313
303
|
error: _propTypes.default.string,
|
|
314
304
|
onRetry: _propTypes.default.func
|
|
315
|
-
};
|
|
316
|
-
function AppSuccessDisplay(_ref7) {
|
|
317
|
-
var _launchSession$appInf, _launchSession$blockl, _launchSession$appInf2, _launchSession$metada;
|
|
318
|
-
let {
|
|
319
|
-
accessibleUrl,
|
|
320
|
-
sessionId,
|
|
321
|
-
blockletInfo,
|
|
322
|
-
urls,
|
|
323
|
-
launchSession
|
|
324
|
-
} = _ref7;
|
|
325
|
-
const theme = (0, _material.useTheme)();
|
|
326
|
-
const {
|
|
327
|
-
t
|
|
328
|
-
} = (0, _locale.useLocaleContext)();
|
|
329
|
-
const showUrl = (0, _react.useMemo)(() => {
|
|
330
|
-
return localStorage.getItem('show-url') === 'true';
|
|
331
|
-
}, []);
|
|
332
|
-
|
|
333
|
-
// 获取应用基本信息
|
|
334
|
-
const appName = (blockletInfo === null || blockletInfo === void 0 ? void 0 : blockletInfo.appName) || t('startApp.unknownApp');
|
|
335
|
-
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) || '';
|
|
336
|
-
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) || '';
|
|
337
|
-
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);
|
|
338
|
-
(0, _react.useEffect)(() => {
|
|
339
|
-
const stepActive = document.querySelector('.step-active');
|
|
340
|
-
if (stepActive) {
|
|
341
|
-
stepActive.classList.add('step-checked');
|
|
342
|
-
}
|
|
343
|
-
}, []);
|
|
344
|
-
const [accessibleUrls, setAccessibleUrls] = (0, _react.useState)([accessibleUrl]);
|
|
345
|
-
(0, _react.useEffect)(() => {
|
|
346
|
-
const checkUrls = urls.filter(url => !accessibleUrls.includes(url));
|
|
347
|
-
checkUrls.forEach(url => {
|
|
348
|
-
(0, _util2.checkUrlAccessible)(url, 10 * 60 * 1000).then(res => {
|
|
349
|
-
if (res) {
|
|
350
|
-
setAccessibleUrls(prev => {
|
|
351
|
-
const accessible = [...prev, url];
|
|
352
|
-
return urls.filter(item => accessible.includes(item));
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
}, [accessibleUrls, urls]);
|
|
358
|
-
const appUrl = accessibleUrls[0] || urls[0];
|
|
359
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
360
|
-
sx: {
|
|
361
|
-
width: '100%',
|
|
362
|
-
maxWidth: 800,
|
|
363
|
-
margin: '0 auto',
|
|
364
|
-
p: {
|
|
365
|
-
xs: 0,
|
|
366
|
-
sm: 3
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
370
|
-
textAlign: "center",
|
|
371
|
-
mb: 4,
|
|
372
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
373
|
-
sx: {
|
|
374
|
-
width: 80,
|
|
375
|
-
height: 80,
|
|
376
|
-
borderRadius: '50%',
|
|
377
|
-
backgroundColor: (0, _material.alpha)(theme.palette.success.main, 0.2),
|
|
378
|
-
display: 'flex',
|
|
379
|
-
alignItems: 'center',
|
|
380
|
-
justifyContent: 'center',
|
|
381
|
-
margin: '0 auto 16px'
|
|
382
|
-
},
|
|
383
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TaskAlt.default, {
|
|
384
|
-
sx: {
|
|
385
|
-
fontSize: 40,
|
|
386
|
-
color: 'success.main'
|
|
387
|
-
}
|
|
388
|
-
})
|
|
389
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
390
|
-
variant: "h3",
|
|
391
|
-
component: "h1",
|
|
392
|
-
fontWeight: "bold",
|
|
393
|
-
gutterBottom: true,
|
|
394
|
-
children: ["\uD83C\uDF89 ", t('startApp.started')]
|
|
395
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
396
|
-
variant: "body1",
|
|
397
|
-
color: "text.secondary",
|
|
398
|
-
children: t('startApp.startedDescription')
|
|
399
|
-
})]
|
|
400
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
401
|
-
sx: {
|
|
402
|
-
p: 3,
|
|
403
|
-
mb: 3,
|
|
404
|
-
borderRadius: 2,
|
|
405
|
-
border: '1px solid',
|
|
406
|
-
borderColor: 'divider',
|
|
407
|
-
backgroundColor: 'background.paper'
|
|
408
|
-
},
|
|
409
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
410
|
-
display: "flex",
|
|
411
|
-
alignItems: "center",
|
|
412
|
-
gap: 2,
|
|
413
|
-
mb: 2,
|
|
414
|
-
flexWrap: "wrap",
|
|
415
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
416
|
-
flex: 1,
|
|
417
|
-
display: "flex",
|
|
418
|
-
alignItems: "center",
|
|
419
|
-
gap: 2,
|
|
420
|
-
children: [appLogo ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Img.default, {
|
|
421
|
-
src: (0, _ufo.joinURL)(appUrl, appLogo),
|
|
422
|
-
alt: appName,
|
|
423
|
-
width: 48,
|
|
424
|
-
height: 48,
|
|
425
|
-
style: {
|
|
426
|
-
borderRadius: 10,
|
|
427
|
-
overflow: 'hidden'
|
|
428
|
-
}
|
|
429
|
-
}, appUrl) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
430
|
-
flex: 1,
|
|
431
|
-
textAlign: "left",
|
|
432
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
433
|
-
variant: "h6",
|
|
434
|
-
color: "text.hint",
|
|
435
|
-
mb: 1,
|
|
436
|
-
children: t('startApp.projectName')
|
|
437
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
438
|
-
variant: "body1",
|
|
439
|
-
fontWeight: "medium",
|
|
440
|
-
children: appName
|
|
441
|
-
})]
|
|
442
|
-
})]
|
|
443
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
444
|
-
flex: 1,
|
|
445
|
-
display: "flex",
|
|
446
|
-
alignItems: "center",
|
|
447
|
-
gap: 2,
|
|
448
|
-
minWidth: {
|
|
449
|
-
xs: '100%',
|
|
450
|
-
sm: 'auto'
|
|
451
|
-
},
|
|
452
|
-
children: [appVersion ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
453
|
-
flex: 1,
|
|
454
|
-
textAlign: "left",
|
|
455
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
456
|
-
variant: "h6",
|
|
457
|
-
color: "text.hint",
|
|
458
|
-
mb: 1,
|
|
459
|
-
children: t('startApp.version')
|
|
460
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
|
|
461
|
-
label: "v".concat(appVersion),
|
|
462
|
-
size: "small",
|
|
463
|
-
color: "primary",
|
|
464
|
-
variant: "outlined"
|
|
465
|
-
})]
|
|
466
|
-
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
467
|
-
flex: 1,
|
|
468
|
-
textAlign: "left",
|
|
469
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
470
|
-
variant: "h6",
|
|
471
|
-
color: "text.hint",
|
|
472
|
-
mb: 1,
|
|
473
|
-
children: t('startApp.status')
|
|
474
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
|
|
475
|
-
label: t('startApp.running'),
|
|
476
|
-
size: "small",
|
|
477
|
-
color: "success"
|
|
478
|
-
})]
|
|
479
|
-
})]
|
|
480
|
-
})]
|
|
481
|
-
}), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
482
|
-
variant: "body2",
|
|
483
|
-
color: "text.secondary",
|
|
484
|
-
textAlign: "left",
|
|
485
|
-
children: description
|
|
486
|
-
}), showUrl && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
487
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
488
|
-
variant: "h6",
|
|
489
|
-
color: "text.hint",
|
|
490
|
-
textAlign: "left",
|
|
491
|
-
children: t('startApp.visitUrl')
|
|
492
|
-
}), urls.map(url => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
493
|
-
display: "flex",
|
|
494
|
-
alignItems: "center",
|
|
495
|
-
mt: 1,
|
|
496
|
-
gap: 1,
|
|
497
|
-
sx: {
|
|
498
|
-
backgroundColor: 'divider',
|
|
499
|
-
borderRadius: 1,
|
|
500
|
-
py: 0.5,
|
|
501
|
-
px: 1.5,
|
|
502
|
-
flex: 1
|
|
503
|
-
},
|
|
504
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
505
|
-
sx: {
|
|
506
|
-
width: 8,
|
|
507
|
-
height: 8,
|
|
508
|
-
borderRadius: '50%',
|
|
509
|
-
backgroundColor: accessibleUrls.includes(url) ? 'success.main' : 'error.main'
|
|
510
|
-
}
|
|
511
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
512
|
-
variant: "body2",
|
|
513
|
-
textAlign: "left",
|
|
514
|
-
sx: {
|
|
515
|
-
flex: 1,
|
|
516
|
-
fontSize: '0.875rem',
|
|
517
|
-
wordBreak: 'break-all'
|
|
518
|
-
},
|
|
519
|
-
children: url
|
|
520
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
521
|
-
size: "small",
|
|
522
|
-
onClick: () => navigator.clipboard.writeText(url),
|
|
523
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ContentCopy.default, {
|
|
524
|
-
sx: {
|
|
525
|
-
fontSize: 16
|
|
526
|
-
}
|
|
527
|
-
})
|
|
528
|
-
})]
|
|
529
|
-
}, url))]
|
|
530
|
-
})]
|
|
531
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
532
|
-
display: "flex",
|
|
533
|
-
flexDirection: "column",
|
|
534
|
-
gap: 2,
|
|
535
|
-
mt: 4,
|
|
536
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
537
|
-
display: "flex",
|
|
538
|
-
gap: 2,
|
|
539
|
-
margin: "0 auto",
|
|
540
|
-
flexDirection: {
|
|
541
|
-
xs: 'column-reverse',
|
|
542
|
-
md: 'row'
|
|
543
|
-
},
|
|
544
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
545
|
-
variant: "outlined",
|
|
546
|
-
sx: {
|
|
547
|
-
minWidth: 220
|
|
548
|
-
},
|
|
549
|
-
color: "primary",
|
|
550
|
-
onClick: () => window.open((0, _ufo.joinURL)((0, _util.getBaseURL)(), "/api/launches/".concat(sessionId, "/redirect/dashboard?appUrl=").concat(appUrl)), '_blank'),
|
|
551
|
-
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dashboard.default, {
|
|
552
|
-
sx: {
|
|
553
|
-
fontSize: 24,
|
|
554
|
-
color: 'primary.main'
|
|
555
|
-
}
|
|
556
|
-
}),
|
|
557
|
-
children: t('startApp.dashboard')
|
|
558
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
559
|
-
variant: "contained",
|
|
560
|
-
color: "primary",
|
|
561
|
-
sx: {
|
|
562
|
-
minWidth: 220
|
|
563
|
-
},
|
|
564
|
-
onClick: () => window.open((0, _ufo.joinURL)((0, _util.getBaseURL)(), "/api/launches/".concat(sessionId, "/redirect/app?appUrl=").concat(appUrl)), '_blank'),
|
|
565
|
-
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_OpenInNew.default, {
|
|
566
|
-
sx: {
|
|
567
|
-
fontSize: 24,
|
|
568
|
-
color: 'inherit'
|
|
569
|
-
}
|
|
570
|
-
}),
|
|
571
|
-
children: t('startApp.visitApp')
|
|
572
|
-
})]
|
|
573
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
574
|
-
variant: "body2",
|
|
575
|
-
color: "text.secondary",
|
|
576
|
-
sx: {
|
|
577
|
-
margin: '0 auto',
|
|
578
|
-
fontWeight: 400,
|
|
579
|
-
cursor: 'pointer',
|
|
580
|
-
display: 'flex',
|
|
581
|
-
alignItems: 'center',
|
|
582
|
-
gap: 0.5,
|
|
583
|
-
opacity: 0.8
|
|
584
|
-
},
|
|
585
|
-
onClick: () => window.open((0, _util.getSubscriptionLink)(launchSession.subscriptionId), '_blank'),
|
|
586
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_OpenInNew.default, {
|
|
587
|
-
sx: {
|
|
588
|
-
fontSize: 14,
|
|
589
|
-
color: 'inherit'
|
|
590
|
-
}
|
|
591
|
-
}), t('startApp.subscription')]
|
|
592
|
-
})]
|
|
593
|
-
})]
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
AppSuccessDisplay.propTypes = {
|
|
597
|
-
launchSession: _propTypes.default.object.isRequired,
|
|
598
|
-
urls: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
599
|
-
accessibleUrl: _propTypes.default.string.isRequired,
|
|
600
|
-
sessionId: _propTypes.default.string.isRequired,
|
|
601
|
-
blockletInfo: _propTypes.default.object.isRequired
|
|
602
305
|
};
|