@abtnode/blocklet-services 1.16.41-beta-20250319-034744-5c62f533 → 1.16.41-beta-20250321-223009-25dace48
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/api/libs/email.js +78 -58
- package/api/libs/open-graph/template.js +2 -3
- package/api/services/kyc/index.js +1 -0
- package/api/socket/channel/did.js +2 -1
- package/dist/assets/{access-control-DyHt8ppX.js → access-control-DhtMFrrc.js} +1 -1
- package/dist/assets/{add-component-core-DOdhiJes.js → add-component-core-duRCoSri.js} +1 -1
- package/dist/assets/{add-resource-CGPM0kPR.js → add-resource-BFCxRUjw.js} +1 -1
- package/dist/assets/analytics-BzYDejNJ.js +11 -0
- package/dist/assets/ar-BYhFX1RC.js +3 -0
- package/dist/assets/{audit-logs-D1W37Cj4.js → audit-logs-Boixygak.js} +1 -1
- package/dist/assets/{branding-DR3Jnq-d.js → branding-DRuzH-TI.js} +2 -2
- package/dist/assets/{bundle-avatar-Eqwd2qUG.js → bundle-avatar-ByTSTw6q.js} +1 -1
- package/dist/assets/{complete-BzSPyjUA.js → complete-Dcrfpetb.js} +1 -1
- package/dist/assets/{component--_f-xKi7.js → component-BQWq8U2p.js} +1 -1
- package/dist/assets/{config-BDpdqYom.js → config-Ho-e6TmS.js} +1 -1
- package/dist/assets/{config-navigation-BrXS6Zm4.js → config-navigation-CiIrM1Fo.js} +3 -3
- package/dist/assets/{config-space-BZu4nd7t.js → config-space-C0DOvHCl.js} +1 -1
- package/dist/assets/{confirm-CCmbVvGp.js → confirm-Bk48-qWj.js} +1 -1
- package/dist/assets/{connect-Bgm2clKz.js → connect-C3MWBgHk.js} +1 -1
- package/dist/assets/{connect-C1EdscR7.js → connect-TboxsI7I.js} +1 -1
- package/dist/assets/{connect-to-CAjdR1Vi.js → connect-to-BKKH2Cvc.js} +1 -1
- package/dist/assets/{dashboard-C2dbiNOp.js → dashboard-C07uhZlB.js} +3 -3
- package/dist/assets/de-BGb-B8X8.js +3 -0
- package/dist/assets/{delete-confirm-CVo1ye7X.js → delete-confirm-BMM7KvBu.js} +1 -1
- package/dist/assets/domain-D7OtVpWm.js +9 -0
- package/dist/assets/domain-action-card-CgDTJRIU.js +29 -0
- package/dist/assets/domains-C4ORv-aP.js +1 -0
- package/dist/assets/{email-BHF0jLjs.js → email-CQ7-0SMy.js} +1 -1
- package/dist/assets/es-7qfy0ZFR.js +3 -0
- package/dist/assets/{exchange-passport-C6TpmUyM.js → exchange-passport-Dz30tcA6.js} +1 -1
- package/dist/assets/{form-text-input-C8x5debf.js → form-text-input-BnAspRzv.js} +1 -1
- package/dist/assets/fr-D45_Vbdp.js +3 -0
- package/dist/assets/{fuel-DQMzXBHQ.js → fuel-iMiQT_Y0.js} +1 -1
- package/dist/assets/hi-DZgSSG0g.js +1 -0
- package/dist/assets/{home-CfRR-l78.js → home-A4FborU_.js} +1 -1
- package/dist/assets/id-ClLYhQcd.js +3 -0
- package/dist/assets/{iframe-C0FAfo1V.js → iframe-CrXg6lQs.js} +1 -1
- package/dist/assets/{index-BsMTGy4m.js → index-B67Mm1i9.js} +1 -1
- package/dist/assets/{index-BVjGveR4.js → index-BP3Y-5Lk.js} +1 -1
- package/dist/assets/{index-DojJOk-8.js → index-BTiNa1bp.js} +1 -1
- package/dist/assets/{index-D2qwAqco.js → index-BXjJechq.js} +1 -1
- package/dist/assets/{index-Db8S8FOW.js → index-BakF-08E.js} +1 -1
- package/dist/assets/{index-KP4WZslk.js → index-Bs92gDoG.js} +1 -1
- package/dist/assets/{index-CYdNDqQ1.js → index-CBS4EwIH.js} +6 -6
- package/dist/assets/{index-DJJGXGi6.js → index-CtLsy_jW.js} +1 -1
- package/dist/assets/index-D2FJkd1U.js +6 -0
- package/dist/assets/{index-D8WxMgot.js → index-D58h54sQ.js} +3 -3
- package/dist/assets/{index-BL64rJ3g.js → index-D5oVpOhg.js} +1 -1
- package/dist/assets/{index-Dal_0cM6.js → index-DJCrE6Wk.js} +1 -1
- package/dist/assets/{index-Dv43WFu_.js → index-Di80FuhU.js} +5 -5
- package/dist/assets/{index-Bv_udrJr.js → index-DmZVGf4-.js} +1 -1
- package/dist/assets/{index-Hc4fe8tE.js → index-DwGRFFPu.js} +1 -1
- package/dist/assets/{analytics-BRjS4mY-.js → index-ZhFE0VPc.js} +29 -39
- package/dist/assets/{invitation-CDtK_Uyv.js → invitation-CIPRNDhh.js} +1 -1
- package/dist/assets/{invite-DSQnWK9o.js → invite-CA2lONVP.js} +1 -1
- package/dist/assets/{issue-passport-Bb_7kKPQ.js → issue-passport-D_79TMoj.js} +1 -1
- package/dist/assets/{item-C1U0HVPR.js → item-CSshCCU4.js} +2 -2
- package/dist/assets/ja-Bt-ViiAE.js +3 -0
- package/dist/assets/ko-BEKHcSck.js +3 -0
- package/dist/assets/{layout-Bkn9nC3f.js → layout-DfxD4-7B.js} +1 -1
- package/dist/assets/{list-BIXoIHH2.js → list-YzyHuFx0.js} +1 -1
- package/dist/assets/{localization-Cf41fenL.js → localization-DXr2qb5k.js} +1 -1
- package/dist/assets/{log-CuiY798z.js → log-DwhEj58A.js} +1 -1
- package/dist/assets/{login-Ds2aHi-M.js → login-aikPs5C4.js} +1 -1
- package/dist/assets/{login-oauth-callback-DAKHXtVv.js → login-oauth-callback-BQ3BcD5g.js} +1 -1
- package/dist/assets/{logo-uploader-DQCS5qZW.js → logo-uploader-BiPAPqlc.js} +3 -3
- package/dist/assets/{lost-passport-DdbK0_Yc.js → lost-passport-CdpQ1c6a.js} +1 -1
- package/dist/assets/{overview-DFNGZZos.js → overview-CEq2dp-I.js} +1 -1
- package/dist/assets/{preferences-Dx29Tgc2.js → preferences-D5E_lTTa.js} +1 -1
- package/dist/assets/{profile-embed-C_yYlnVt.js → profile-embed-C5ZGYP34.js} +1 -1
- package/dist/assets/pt-B0dqFDL5.js +1 -0
- package/dist/assets/{publish-resource-CPSJ7Gd2.js → publish-resource-CHXi7gR6.js} +1 -1
- package/dist/assets/{relative-time-xM8Zc84I.js → relative-time-BMk6-Cz4.js} +1 -1
- package/dist/assets/ru-CQaxksxw.js +1 -0
- package/dist/assets/{setup-CkUck5w6.js → setup-5CzEE7u_.js} +3 -3
- package/dist/assets/{start-CRCAeTDI.js → start-bvp0eBWn.js} +1 -1
- package/dist/assets/{status-D8ugfvVU.js → status-CvHaULR6.js} +1 -1
- package/dist/assets/{step-actions-C83ykph7.js → step-actions-BQ7v9BTH.js} +1 -1
- package/dist/assets/{studio-Cb_GlvSi.js → studio-uVz4gu18.js} +1 -1
- package/dist/assets/{switch-control-CJ1duVKM.js → switch-control-DD9yYD7L.js} +1 -1
- package/dist/assets/{th-KPXdcBJ0.js → th-CjA3_x5X.js} +1 -1
- package/dist/assets/{traffic-DjeUj5sV.js → traffic-D-ugFE9e.js} +1 -1
- package/dist/assets/{transfer-B_MO7Mf7.js → transfer-Bx1MySon.js} +1 -1
- package/dist/assets/{unsubscribe-ajBobtwD.js → unsubscribe-B9kFqlcu.js} +1 -1
- package/dist/assets/{user-center-D62gRjAl.js → user-center-Di3tptHr.js} +1 -1
- package/dist/assets/{util-CohOBosL.js → util-CzeZDYqJ.js} +1 -1
- package/dist/assets/{vendor-arcblock-E5QJEgSK.js → vendor-arcblock-CZsH3o1m.js} +1 -1
- package/dist/assets/vi-CEplaB_p.js +1 -0
- package/dist/assets/wrap-locale-RuOaicAg.js +1 -0
- package/dist/assets/zh-CDegQD7Y.js +4 -0
- package/dist/assets/zh-tw-BunOPLC9.js +3 -0
- package/dist/index.html +2 -2
- package/dist/service-worker.js +1 -1
- package/package.json +21 -21
- package/dist/assets/ar-A7PXaQSB.js +0 -3
- package/dist/assets/de-DQLOqs4x.js +0 -3
- package/dist/assets/domain-BQkRhwGe.js +0 -9
- package/dist/assets/domain-action-card-Dlgq4rsm.js +0 -29
- package/dist/assets/domains-DaOwHgX-.js +0 -1
- package/dist/assets/es-Wyib4tkS.js +0 -3
- package/dist/assets/fr-CTdi8lPh.js +0 -3
- package/dist/assets/hi-Dk3MVpw6.js +0 -1
- package/dist/assets/id-BqyOVEFD.js +0 -3
- package/dist/assets/index-CmyG8bip.js +0 -5
- package/dist/assets/ja-BIiN349J.js +0 -3
- package/dist/assets/ko-D9z_sjE3.js +0 -3
- package/dist/assets/pt-DbNy95wU.js +0 -1
- package/dist/assets/ru-BEliZjDL.js +0 -1
- package/dist/assets/vi-ChkGdSKU.js +0 -1
- package/dist/assets/wrap-locale-lZatlhee.js +0 -1
- package/dist/assets/zh-DDAGRLEd.js +0 -4
- package/dist/assets/zh-tw-DIWT2k6_.js +0 -3
package/api/libs/email.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { Joi } = require('@arcblock/validator');
|
|
2
2
|
const { render } = require('@react-email/components');
|
|
3
|
-
const { emailConfigSchema } = require('@blocklet/sdk/lib/validators/email');
|
|
4
3
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
5
|
-
const
|
|
4
|
+
const { getEmailServiceProvider } = require('@abtnode/auth/lib/email');
|
|
5
|
+
const { sendEmailWithLauncher } = require('@abtnode/auth/lib/launcher');
|
|
6
6
|
|
|
7
7
|
const logger = require('./logger')('blocklet-services:notification');
|
|
8
8
|
const { NotificationEmail } = require('../emails/pages/notification');
|
|
@@ -15,7 +15,7 @@ const validateEmail = schemaEmail.validateAsync.bind(schemaEmail);
|
|
|
15
15
|
async function sendEmail(
|
|
16
16
|
receiver,
|
|
17
17
|
notification,
|
|
18
|
-
{ teamDid, node, locale, unsubscribeToken = '', userInfo = {}, raw = false }
|
|
18
|
+
{ teamDid, node, locale, unsubscribeToken = '', userInfo = {}, raw = false, launcher = false }
|
|
19
19
|
) {
|
|
20
20
|
if (!receiver) {
|
|
21
21
|
throw new Error('receiver is required');
|
|
@@ -30,68 +30,88 @@ async function sendEmail(
|
|
|
30
30
|
logger.warn(`Failed to get blocklet: ${teamDid}`);
|
|
31
31
|
throw new Error(`Failed to get blocklet: ${teamDid}`);
|
|
32
32
|
}
|
|
33
|
-
const config = blocklet.settings?.notification?.email || {};
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const provider = getEmailServiceProvider(blocklet);
|
|
35
|
+
logger.debug('service.sendEmail', { teamDid, provider, raw, launcher });
|
|
36
|
+
if (!provider || (provider === 'launcher' && !launcher)) {
|
|
37
|
+
throw new Error('Email Service is not available.');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
if (provider === 'service') {
|
|
41
|
+
const config = blocklet.settings?.notification?.email;
|
|
42
|
+
const info = getBlockletInfo(blocklet);
|
|
43
|
+
const logo = `${info.appUrl}/.well-known/service/blocklet/logo-rect?imageFilter=convert&f=png`;
|
|
44
|
+
|
|
45
|
+
const appInfo = notification.appInfo || {
|
|
46
|
+
logo,
|
|
47
|
+
description: info.description,
|
|
48
|
+
title: info.name,
|
|
49
|
+
version: info.version,
|
|
50
|
+
url: info.appUrl,
|
|
51
|
+
};
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
const subject = `${
|
|
54
|
+
notification.title ||
|
|
55
|
+
{ zh: '您收到了一个通知', en: 'You have received a notification' }[locale] ||
|
|
56
|
+
'You have received a notification'
|
|
57
|
+
}`;
|
|
58
|
+
|
|
59
|
+
const html = render(
|
|
60
|
+
NotificationEmail({
|
|
61
|
+
subject,
|
|
62
|
+
appInfo,
|
|
63
|
+
...notification,
|
|
64
|
+
locale,
|
|
65
|
+
raw,
|
|
66
|
+
unsubscribeToken,
|
|
67
|
+
userInfo: {
|
|
68
|
+
...userInfo,
|
|
69
|
+
email: receiver,
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const emailData = {
|
|
75
|
+
from: `"${appInfo.title}" <${config.from}>`,
|
|
76
|
+
to: receiver,
|
|
77
|
+
title: notification.title,
|
|
64
78
|
subject,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
locale,
|
|
68
|
-
raw,
|
|
69
|
-
unsubscribeToken,
|
|
70
|
-
userInfo: {
|
|
71
|
-
...userInfo,
|
|
72
|
-
email: receiver,
|
|
73
|
-
},
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
const emailData = {
|
|
77
|
-
from: `"${appInfo.title}" <${value.from}>`,
|
|
78
|
-
to: receiver,
|
|
79
|
-
title: notification.title,
|
|
80
|
-
subject,
|
|
81
|
-
html,
|
|
82
|
-
replyTo: value.from,
|
|
83
|
-
};
|
|
84
|
-
if (process.env.NODE_ENV === 'test') {
|
|
85
|
-
return {
|
|
86
|
-
messageId: 'test-message-id',
|
|
87
|
-
accepted: [emailData.to],
|
|
88
|
-
rejected: [],
|
|
89
|
-
response: 'Test environment - Email skipped',
|
|
79
|
+
html,
|
|
80
|
+
replyTo: config.from,
|
|
90
81
|
};
|
|
82
|
+
|
|
83
|
+
if (process.env.NODE_ENV === 'test') {
|
|
84
|
+
return {
|
|
85
|
+
messageId: 'test-message-id',
|
|
86
|
+
accepted: [emailData.to],
|
|
87
|
+
rejected: [],
|
|
88
|
+
response: 'Test environment - Email skipped',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const transporter = cache.getTransport({ did: teamDid, config });
|
|
92
|
+
const result = await transporter.sendMail(emailData);
|
|
93
|
+
return result;
|
|
91
94
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
|
|
96
|
+
if (provider === 'launcher') {
|
|
97
|
+
if (!blocklet.controller) {
|
|
98
|
+
throw new Error('Launcher info not available.');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const info = await node.getNodeInfo({ useCache: true });
|
|
102
|
+
const result = await sendEmailWithLauncher(info.sk, blocklet.controller, {
|
|
103
|
+
receiver,
|
|
104
|
+
notification,
|
|
105
|
+
options: { locale, raw },
|
|
106
|
+
});
|
|
107
|
+
if (result.error) {
|
|
108
|
+
throw new Error(result.error);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
throw new Error('Unknown email provider.');
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
module.exports = {
|
|
@@ -200,8 +200,7 @@ const getCoverTemplate = ({ width, height, logo, logoRounded, color, title, desc
|
|
|
200
200
|
</div>`;
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
-
const getBannerTemplate = ({ width, height,
|
|
204
|
-
const textColor = getTextColor(color.start);
|
|
203
|
+
const getBannerTemplate = ({ width, height, logo, logoRounded, background, title }, fn) => {
|
|
205
204
|
return fn`<div
|
|
206
205
|
style="
|
|
207
206
|
width: ${width}px;
|
|
@@ -225,7 +224,7 @@ const getBannerTemplate = ({ width, height, color, logo, logoRounded, background
|
|
|
225
224
|
<h2
|
|
226
225
|
style="
|
|
227
226
|
font-size: 72px;
|
|
228
|
-
color:
|
|
227
|
+
color: #eee;
|
|
229
228
|
font-weight: 500;
|
|
230
229
|
font-family: Arial, sans-serif;
|
|
231
230
|
text-align: left;
|
|
@@ -458,13 +458,14 @@ const sendToMail = async ({ sender, receiver, notification, options, node, pushO
|
|
|
458
458
|
|
|
459
459
|
const notifications = parseNotification({ id, ...rest }, senderInfo);
|
|
460
460
|
|
|
461
|
-
const { locale = 'en' } = options || {};
|
|
461
|
+
const { locale = 'en', raw = false } = options || {};
|
|
462
462
|
const results = await Promise.allSettled(
|
|
463
463
|
receivers.map((email) => {
|
|
464
464
|
return sendEmail(email, notifications[0], {
|
|
465
465
|
teamDid: sender.appDid,
|
|
466
466
|
node,
|
|
467
467
|
locale,
|
|
468
|
+
raw,
|
|
468
469
|
...(unsubscribeToken ? { unsubscribeToken } : {}),
|
|
469
470
|
...(userInfo ? { userInfo } : {}),
|
|
470
471
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as E,j as e,a3 as c,bj as h,bz as L,bn as N,bA as g,E as I,a9 as b}from"./vendor-mui-core-O22FPGM4.js";import{r as m}from"./vendor-react-DoD83n6N.js";import{u as j,p as o,V as O}from"./vendor-ux-did-connect-D75Zatzm.js";import{A as y}from"./config-C3tQWDAE.js";import{P}from"./page-header-DyeTxe1U.js";import{o as R,f as T,e as Y}from"./index-
|
|
1
|
+
import{e as E,j as e,a3 as c,bj as h,bz as L,bn as N,bA as g,E as I,a9 as b}from"./vendor-mui-core-O22FPGM4.js";import{r as m}from"./vendor-react-DoD83n6N.js";import{u as j,p as o,V as O}from"./vendor-ux-did-connect-D75Zatzm.js";import{A as y}from"./config-C3tQWDAE.js";import{P}from"./page-header-DyeTxe1U.js";import{o as R,f as T,e as Y}from"./index-CBS4EwIH.js";import{S as v}from"./layout-DfxD4-7B.js";import{S as D}from"./step-actions-BQ7v9BTH.js";import{S as H}from"./button-BqyvGZC-.js";import"./vendor-utils-CbeKtci8.js";import"./vendor-hooks-CYyfK9g3.js";import"./lottie-web-B6s7dDoL.js";import"./vendor-arcblock-CZsH3o1m.js";import"./content-layout--DV54O6i.js";function C({onNext:a}){const S=E(),{t:n,locale:p}=j(),[i,l]=m.useState(!1),[f,d]=m.useState(""),{blocklet:r}=R();m.useEffect(()=>{var s;const t=T.findServiceFromMeta(r.meta,o.NODE_SERVICES.AUTH);d(((s=t==null?void 0:t.config)==null?void 0:s.whoCanAccess)||o.WHO_CAN_ACCESS.ALL)},[r]);const u=async t=>{let s=o.ACCESS_POLICY_PUBLIC;t===o.WHO_CAN_ACCESS.ALL?s=o.ACCESS_POLICY_PUBLIC:t===o.WHO_CAN_ACCESS.INVITED?s=o.ACCESS_POLICY_INVITED_ONLY:t===o.WHO_CAN_ACCESS.OWNER?s=o.ACCESS_POLICY_OWNER_ONLY:t===o.WHO_CAN_ACCESS.ADMIN&&(s=o.ACCESS_POLICY_ADMIN_ONLY);try{l(!0),await Y.updateBlockletSecurityRule({input:{did:r.meta.did,data:{id:o.SECURITY_RULE_DEFAULT_ID,accessPolicyId:s}}}),l(!1)}catch(A){l(!1),O.error(A.message)}},x=async t=>{i||(d(t.target.value),await u(t.target.value))},_={marginRight:4,fontSize:18,verticalAlign:"text-bottom",color:S.palette.text.secondary};return e.jsxs(W,{children:[e.jsx(c,{className:"header",children:e.jsx(P,{title:n("blocklet.config.access.title"),subTitle:n("blocklet.config.access.description")})}),e.jsx(h,{component:"fieldset",children:e.jsx(L,{name:"inherit",value:f,onChange:x,children:y.map(t=>e.jsxs(c,{sx:{mb:2},children:[e.jsx(N,{value:t.value,control:e.jsx(g,{size:"small",color:"primary"}),label:e.jsxs("span",{children:[e.jsx(t.icon,{style:_}),t.title[p]]})}),e.jsx(c,{className:"tip",children:t.description[p]})]},t.value))})}),e.jsx(D,{mt:8,disabled:i,blocklet:r,onStartNow:()=>a("complete"),children:e.jsx(H,{loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:n("setup.continue")})})]})}C.propTypes={onNext:I.func};C.defaultProps={onNext:()=>{}};const W=b(v)`
|
|
2
2
|
height: 100%;
|
|
3
3
|
overflow-y: auto;
|
|
4
4
|
.header {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a1 as ks,j as o,E as A,a2 as mt,a9 as Ge,a3 as J,T as ge,t as Vt,bn as wi,bO as Ei,I as Os,bC as Is,bP as Rs,z as Cs,be as Ll,b2 as Ps,bl as Nl,M as Tr,bv as Al,bw as Dl,bx as Ml,br as Fl,ac as _s,L as Bl,b1 as $l,b0 as Ul,ai as Si,a4 as Ls,a6 as Wl,ad as tt,e as ir,bE as zl,x as or,R as Ns,V as As,am as Ds,bK as Ms,af as ql,aa as qt,bd as jo,A as ko,Z as Vl,P as Kl,G as Gl,v as Hl,$ as Xl,D as Yl,K as Oo,bp as Ql}from"./vendor-mui-core-O22FPGM4.js";import{r as M,g as Ti,f as Jl,k as Zl,a as ji,e as Ee,b as Ft,l as ec}from"./vendor-react-DoD83n6N.js";import{j as Fs,d as tc,S as nc,s as Bs,A as rc}from"./item-
|
|
1
|
+
import{a1 as ks,j as o,E as A,a2 as mt,a9 as Ge,a3 as J,T as ge,t as Vt,bn as wi,bO as Ei,I as Os,bC as Is,bP as Rs,z as Cs,be as Ll,b2 as Ps,bl as Nl,M as Tr,bv as Al,bw as Dl,bx as Ml,br as Fl,ac as _s,L as Bl,b1 as $l,b0 as Ul,ai as Si,a4 as Ls,a6 as Wl,ad as tt,e as ir,bE as zl,x as or,R as Ns,V as As,am as Ds,bK as Ms,af as ql,aa as qt,bd as jo,A as ko,Z as Vl,P as Kl,G as Gl,v as Hl,$ as Xl,D as Yl,K as Oo,bp as Ql}from"./vendor-mui-core-O22FPGM4.js";import{r as M,g as Ti,f as Jl,k as Zl,a as ji,e as Ee,b as Ft,l as ec}from"./vendor-react-DoD83n6N.js";import{j as Fs,d as tc,S as nc,s as Bs,A as rc}from"./item-CSshCCU4.js";import{r as $s,B as ut,ak as ki,P as Us,p as Ws,u as gt,i as Dt,a as ic,l as oc,aj as jr,aZ as sc,am as zs,bd as Io,ap as ac,V as Oi,C as lc,s as Gt,U as xr,aw as Ro,af as qs,be as gr,f as Ii,b2 as Vs,g as Ks,X as cc,bf as uc,ai as oi,bg as dc}from"./vendor-ux-did-connect-D75Zatzm.js";import{z as Pn,f as Mt,Z as hc,_ as fc,h as jt,$ as pc,D as mc,a0 as gc,a1 as vc,a2 as yc,C as kr,a3 as Gs,X as bc,a4 as xc,a5 as wc,a6 as Ec,a7 as cr,a8 as Co,a9 as Sc}from"./index-CBS4EwIH.js";import{j as Po,c as Tc,E as Or,e as jc,f as kc,g as Oc,L as Ic,S as Rc}from"./vendor-arcblock-CZsH3o1m.js";import{L as _o}from"./launch-result-message-WNYdod-D.js";import{P as Hs}from"./page-header-DyeTxe1U.js";import{b as ct,p as Cc,B as Pc,C as Lo,x as Jn,Y as Xs,a0 as _c,ab as Lc,G as Nc,J as Mr,w as Ri,W as Ac,ac as Dc,ad as Mc,ae as Fc,y as Gn,af as Bc,c as $c}from"./vendor-utils-CbeKtci8.js";import{u as Uc,C as Wc}from"./config-space-C0DOvHCl.js";import{R as Fr}from"./logo-uploader-BiPAPqlc.js";import{S as zc}from"./index-D5oVpOhg.js";import{s as Ys,h as qc,w as Vc,f as Kc,a as Gc,b as Hc,c as Xc,M as Yc}from"./index-oXEi5lCg.js";import{l as sr,f as Qc,a as Jc,e as Qs,w as Zc}from"./vendor-hooks-CYyfK9g3.js";import{g as eu}from"./get-safe-url-BvS0hy8W.js";import{p as tu}from"./index-DQKEK30u.js";import{r as nu}from"./Google-CBPWeaVC.js";import{I as No}from"./index-D5rqbUOM.js";import{u as ru}from"./session-CD9NaM-v.js";import{W as iu}from"./did-address-DIKoCoBp.js";import{_ as Js}from"./useLocalStorage-CtbpqE0c.js";import{f as Zs}from"./format-error-LAoTjvJe.js";import{a as Ao}from"./api-CvDkueg1.js";import{d as ou,a as su,v as au,e as lu}from"./util-CzeZDYqJ.js";import{u as ea}from"./use-mobile-Cb_97PZu.js";import{C as cu}from"./content-layout--DV54O6i.js";import{C as uu,D as du,a as hu}from"./connect-to-BKKH2Cvc.js";import{d as fu}from"./ArrowDropDown-ydRfHJ2x.js";import{d as pu}from"./ChevronLeft-CqDoHwdJ.js";import{d as mu}from"./ChevronRight-Bpkf9aqI.js";const dg="blocklet-add-component-registry",hg="server-add-registry",fg=e=>`resource-${e}-add-registry`;var Ci={},gu=ks;Object.defineProperty(Ci,"__esModule",{value:!0});var ta=Ci.default=void 0,vu=gu($s()),yu=o;ta=Ci.default=(0,vu.default)((0,yu.jsx)("path",{d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 13h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5"}),"Link");function na(e){const{info:t}=Pn();return M.useMemo(()=>{var n,r,i;return!e||!((n=e.docker)!=null&&n.image)||(r=e.docker)!=null&&r.image&&((i=e.docker)!=null&&i.runBaseScript)?!0:window.blocklet?window.blocklet.enableDocker&&window.blocklet.enableDockerNetwork:t.enableDocker&&t.enableDockerNetwork},[e,t])}function Pi({disabled:e,children:t,onConfirm:n}){return M.useEffect(()=>{if(e)return()=>{};const r=i=>{i.code==="Enter"&&(i.metaKey===!0||i.ctrlKey===!0)&&(i.preventDefault(),i.stopPropagation(),n())};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e,n]),t}Pi.propTypes={disabled:A.bool,children:A.any.isRequired,onConfirm:A.func.isRequired};Pi.defaultProps={disabled:!1};function _i({onContinue:e,nextDisabled:t,launching:n,texts:r,description:i}){const[s,a]=M.useState(!1),c=()=>a(f=>!f);return o.jsxs(o.Fragment,{children:[o.jsx(bu,{children:o.jsxs(Pi,{disabled:t,onConfirm:e,children:[o.jsx("div",{className:"eula-trigger",onClick:c,children:r.listenName}),o.jsx(ut,{disabled:t,color:"primary",variant:"contained",className:"next-button",onClick:e,children:n?o.jsxs(o.Fragment,{children:[o.jsx(mt,{size:14}),r.launchingText]}):r.buttonNext})]})}),o.jsx(ki,{open:s,title:r.listenName,onClose:()=>a(!1),children:i})]})}_i.propTypes={onContinue:A.func.isRequired,nextDisabled:A.bool,launching:A.bool,description:A.any,texts:A.object};_i.defaultProps={nextDisabled:!1,launching:!1,description:"",texts:{listenName:"",launchingText:"",buttonNext:""}};const bu=Ge.div`
|
|
2
2
|
margin: 0 auto;
|
|
3
3
|
display: flex;
|
|
4
4
|
justify-content: space-between;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as B,j as h}from"./vendor-mui-core-O22FPGM4.js";import{l as L,r}from"./vendor-react-DoD83n6N.js";import{x as W,C as O}from"./vendor-utils-CbeKtci8.js";import{u as A,ak as T}from"./vendor-ux-did-connect-D75Zatzm.js";import{k as w,u as _,r as F}from"./vendor-hooks-CYyfK9g3.js";import{A as K,S as $}from"./add-component-core-
|
|
1
|
+
import{t as B,j as h}from"./vendor-mui-core-O22FPGM4.js";import{l as L,r}from"./vendor-react-DoD83n6N.js";import{x as W,C as O}from"./vendor-utils-CbeKtci8.js";import{u as A,ak as T}from"./vendor-ux-did-connect-D75Zatzm.js";import{k as w,u as _,r as F}from"./vendor-hooks-CYyfK9g3.js";import{A as K,S as $}from"./add-component-core-duRCoSri.js";import{o as z,M as G}from"./index-CBS4EwIH.js";import"./lottie-web-B6s7dDoL.js";import"./item-CSshCCU4.js";import"./vendor-arcblock-CZsH3o1m.js";import"./format-error-LAoTjvJe.js";import"./Launch-XvyEoGhF.js";import"./Done-B8c93MpP.js";import"./DeleteOutline-D4DYIaUj.js";import"./delete-confirm-BMM7KvBu.js";import"./click-to-copy-Dc16fHKA.js";import"./shorten-label-DXrhdUJE.js";import"./confirm-Bk48-qWj.js";import"./session-CD9NaM-v.js";import"./get-safe-url-BvS0hy8W.js";import"./did-address-DIKoCoBp.js";import"./launch-result-message-WNYdod-D.js";import"./page-header-DyeTxe1U.js";import"./config-space-C0DOvHCl.js";import"./api-CvDkueg1.js";import"./logo-uploader-BiPAPqlc.js";import"./index-tUQxVYYQ.js";import"./index-D5oVpOhg.js";import"./Google-CBPWeaVC.js";import"./index-oXEi5lCg.js";import"./index-DQKEK30u.js";import"./index-D5rqbUOM.js";import"./useLocalStorage-CtbpqE0c.js";import"./util-CzeZDYqJ.js";import"./use-mobile-Cb_97PZu.js";import"./content-layout--DV54O6i.js";import"./connect-to-BKKH2Cvc.js";import"./ArrowDropDown-ydRfHJ2x.js";import"./ChevronLeft-CqDoHwdJ.js";import"./ChevronRight-Bpkf9aqI.js";function ke(){var d;const{t:f}=A(),{blocklet:i}=z(),{componentDid:s}=L(),g=B(e=>e.breakpoints.down("md")),o=new URL(window.location.href),C=o.searchParams.get("mode")==="dialog",c=o.searchParams.get("resourceType")||"",p=o.searchParams.get("resourceDid")||s,R=o.searchParams.get("store")||"",S=o.searchParams.get("showFromUrl")!=="false",y=o.searchParams.get("showResourcesSwitch")!=="false",E=o.searchParams.get("enableRunBackground")!=="false",P=o.searchParams.get("showCategory")!=="false",n=(d=i==null?void 0:i.meta)==null?void 0:d.did,m=R.split(",").filter(Boolean).map(e=>{try{return new URL(e.startsWith("http")?e:`https://${e}`).origin}catch(t){return console.error(t),null}}).filter(Boolean),[D,x]=r.useState(m.map(e=>({url:e,name:e.replace("https://","")}))),[U,b]=r.useState(null),[M,j]=r.useState("");r.useEffect(()=>{(async()=>{try{const e=await Promise.all(m.map(async t=>{const a=W(t,"/api/store.json"),{data:v}=await O.get(a);return{url:t,name:v.name}}));x(e||[])}catch(e){console.error(e)}})()},[m.join(",")]);const k=()=>{window.parent.postMessage({event:"resourceDialog.close",componentDid:s},"*")};r.useEffect(()=>{const e=G();return n&&e.connect(),()=>{n&&e.isConnected()&&e.disconnect()}},[n]),w(()=>{window.parent.postMessage({event:"resourceDialog.loaded",componentDid:s},"*")});const l=_(e=>{var t,a;((t=e.data)==null?void 0:t.event)==="resourceDialog.select"&&((a=e.data)==null?void 0:a.componentDid)===s&&(b(e.data.data),j(e.data.storeUrl))});w(()=>{window.addEventListener("message",l)}),F(()=>{window.removeEventListener("message",l)});const u=({inDialog:e=!0}={})=>h.jsx(K,{stores:D,selectedMeta:U,storeUrl:M,resourceType:c,resourceDid:p,mode:"embed",inDialog:e,storageKey:$(`${c}+${p}`),showResourcesSwitch:y,showFromUrl:S,enableRunBackground:E,showCategory:P});return C?h.jsx(T,{className:"resource-dialog",title:f("blocklet.publish.addResource"),maxWidth:!1,fullWidth:!1,PaperProps:{style:g?{width:"100%",height:window.innerHeight}:{maxWidth:1350,minWidth:930,width:"80%"}},onClose:(e,t)=>{t!=="backdropClick"&&k()},showCloseButton:!0,disableEscapeKeyDown:!0,open:!0,children:u()}):u({inDialog:!1})}export{ke as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{E as m,e as G,j as s,bE as W,a3 as L,a9 as U,T as k,bd as C,a4 as $,bZ as Q,b_ as Y}from"./vendor-mui-core-O22FPGM4.js";import{r as f,f as H}from"./vendor-react-DoD83n6N.js";import{u as B,X as v,i as tt,a2 as et,aX as st,aq as at}from"./vendor-ux-did-connect-D75Zatzm.js";import{T as nt}from"./traffic-D-ugFE9e.js";import{p as it}from"./index-B67Mm1i9.js";import{ax as q,aw as F,z as rt,C as O,f as P,aF as ot,o as lt}from"./index-CBS4EwIH.js";import{y as R,aG as ct}from"./vendor-utils-CbeKtci8.js";import{K as E}from"./vendor-arcblock-CZsH3o1m.js";import{E as X}from"./index-ZhFE0VPc.js";import{B as mt}from"./bundle-avatar-ByTSTw6q.js";import{B as ut}from"./dashboard-C07uhZlB.js";import{L as pt}from"./list-header-Bzt7zKtS.js";import"./vendor-hooks-CYyfK9g3.js";import"./lottie-web-B6s7dDoL.js";import"./useAsyncRetry-CEJwVPZ6.js";import"./useAsync-D2OhgEkV.js";import"./iframe-CrXg6lQs.js";import"./LaunchOutlined-BfbVRiJT.js";import"./ChevronLeft-CqDoHwdJ.js";import"./ChevronRight-Bpkf9aqI.js";import"./index-DWJc5Rxl.js";import"./format-error-LAoTjvJe.js";import"./vendor-mui-x-K-9WHqhO.js";import"./useLocalStorage-CtbpqE0c.js";import"./confirm-Bk48-qWj.js";import"./PlayArrow-DI84Lay5.js";import"./get-safe-url-BvS0hy8W.js";import"./session-CD9NaM-v.js";import"./InfoOutlined-HP5LuELQ.js";import"./useSetState-BL3ktMon.js";const _=n=>{const d=new Date(Math.min(...n)),r=(new Date(Math.max(...n))-d)/(1e3*60);return c=>{if(r<=10){const e=(n.length-n.length%r)/r;return c%e===0}const o=(n.length-n.length%6)/6;return c%o===0}},S=n=>`${n}%`;function N({title:n,cpus:d,currentLoad:l,history:u,empty:r,onHover:c,hoverIndex:i}){const{t:o,locale:h}=B(),e=G(),t=f.useRef(null),a=R(u)?[]:u.map(x=>q(x.date,"HH:mm",h)),w=f.useCallback(()=>{c==null||c(null)},[c]);if(f.useEffect(()=>{if(!t.current||(i==null?void 0:i.ref)===t)return;const x=t.current.getEchartsInstance(),g=i==null?void 0:i.seriesIndex,T=a.findIndex(b=>b===(i==null?void 0:i.dataValue));i&&T!==-1?x.dispatchAction({type:"showTip",seriesIndex:g,dataIndex:T}):(x.dispatchAction({type:"hideTip"}),x.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:-1}))},[i]),!R(u)){const T={tooltip:{trigger:"axis",formatter(b){const D=b[0].data,{seriesIndex:y,dataIndex:j}=b[0];return c==null||c({seriesIndex:y,dataIndex:j,dataValue:a[j],ref:(i==null?void 0:i.ref)||t}),`${b[0].name}: <b>${S(D)}</b>`}},title:{left:"0%",text:`${n||o("common.cpu")} (${Math.floor(l||0)}%)`,textAlign:"left"},toolbox:{},grid:{left:"16px",right:"16px",bottom:"0px",containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:a,axisTick:{show:!1},splitLine:{show:!1},axisLabel:{interval:_(u.map(b=>new Date(b.date)))}},yAxis:{type:"value",axisTick:{show:!1},splitLine:{show:!1},min:0,max:100,interval:Math.ceil(50),axisLabel:{formatter:S}},visualMap:{show:!1,type:"piecewise",dimension:1,seriesIndex:0,pieces:[{max:80,color:"#e9f8f9"},{min:80,max:100,color:e.palette.warning.light},{min:100,color:"#ff4d4f"}]},series:[{name:"CPU Usage",type:"line",smooth:!0,symbol:"none",lineStyle:{color:e.palette.primary.main,width:2.5},areaStyle:{},itemStyle:{},emphasis:{disabled:!0},data:u.map(b=>b.value),markLine:{silent:!0,symbol:["none","none"],lineStyle:{color:"#ff4d4f",type:"dashed",width:1.5},label:{formatter:`${S(100)}`,position:"insideEndTop"},data:[{yAxis:100},{yAxis:80,lineStyle:{color:e.palette.warning.light,type:"dashed",width:1.5},label:{formatter:`${S(80)}`,position:"insideEndTop"}}]}}]};return s.jsxs(W,{sx:{p:1},onMouseLeave:w,children:[s.jsx(X,{ref:t,option:T,style:{width:"100%",height:"160px"},onEvents:{globalout:w}}),s.jsxs(L,{sx:{ml:2,mt:1,fontSize:12},color:"text.secondary",children:[`${o("system.cores")}: ${(d==null?void 0:d.length)||0}`," "]})]})}return r}N.propTypes={title:m.string,cpus:m.array,currentLoad:m.number,history:m.array,empty:m.node,onHover:m.func,hoverIndex:m.number};N.defaultProps={title:"",cpus:[],currentLoad:0,history:[],empty:null,onHover:()=>{},hoverIndex:null};function V({instanceCount:n,title:d,total:l,used:u,history:r,empty:c,onHover:i,hoverIndex:o}){const{t:h,locale:e}=B(),t=G(),a=!!l,w=l-u,x=a?`(${F(u)}, ${Math.floor(u/l*100)}%)`:"",g=f.useRef(null),T=R(r)?[]:r.map(y=>q(y.date,"HH:mm",e));f.useEffect(()=>{if(!g.current||(o==null?void 0:o.ref)===g)return;const y=g.current.getEchartsInstance(),j=o==null?void 0:o.seriesIndex,M=T.findIndex(p=>p===(o==null?void 0:o.dataValue));o&&M!==-1?y.dispatchAction({type:"showTip",seriesIndex:j,dataIndex:M}):(y.dispatchAction({type:"hideTip"}),y.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:-1}))},[o==null?void 0:o.dataIndex]);const b=f.useCallback(()=>{i==null||i(null)},[i]);f.useEffect(()=>{if(g.current){const y=g.current.getEchartsInstance(),j=y.getDom(),M=p=>{b(p)};return j.addEventListener("mouseleave",M),()=>{j&&j.removeEventListener("mouseleave",M),y&&y.dispose()}}},[b]);const D=[];if(n&&D.push({title:h("system.instances"),metric:n}),a&&D.push({title:h("system.free"),metric:E(w,{short:!0,iec:!0})}),!R(r)){const y=Math.max(...r.map(p=>p.value),l,0),j=Math.ceil(l*.8),M={tooltip:{trigger:"axis",formatter(p){const A=p[0].data,Z=E(A,{short:!0,iec:!0}),{seriesIndex:J,dataIndex:I}=p[0];return i==null||i({seriesIndex:J,dataIndex:I,dataValue:T[I],ref:(o==null?void 0:o.ref)||g}),`${p[0].name}: <b>${Z}</b>`}},title:{left:"0%",text:`${d||h("common.memory")} ${x}`,textAlign:"left"},toolbox:{},grid:{left:"16px",right:"16px",bottom:"0px",containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:T,axisTick:{show:!1},splitLine:{show:!1},axisLabel:{interval:_(r.map(p=>new Date(p.date)))}},yAxis:{type:"value",axisTick:{show:!1},splitLine:{show:!1},min:0,max:y,interval:Math.ceil(y/2),axisLabel:{formatter:p=>E(p,{short:!0,iec:!0}),padding:[5,0,0,0]}},visualMap:{show:!1,type:"piecewise",dimension:1,seriesIndex:0,pieces:[{max:j,color:"#e9f8f9"},{min:j,max:l,color:t.palette.warning.light},{min:l,color:"#ff4d4f"}]},series:[{name:"Memory Usage",type:"line",smooth:!0,symbol:"none",lineStyle:{color:t.palette.primary.main,width:2.5},areaStyle:{},itemStyle:{},emphasis:{disabled:!0},data:r.map(p=>p.value),markLine:{silent:!0,symbol:["none","none"],data:[{yAxis:l,lineStyle:{color:"#ff4d4f",type:"dashed",width:1.5},label:{formatter:`${E(l,{short:!0,iec:!0})}`,position:"insideEndTop"}},{yAxis:j,lineStyle:{color:t.palette.warning.light,type:"dashed",width:1.5},label:{formatter:`${E(j,{short:!0,iec:!0})}`,position:"insideEndTop"}}]}}]};return s.jsxs(W,{sx:{p:1},onMouseLeave:b,children:[s.jsx(X,{ref:g,option:M,style:{width:"100%",height:"160px"}}),s.jsx(L,{sx:{ml:2,mt:1,fontSize:12},color:"text.secondary",children:D.map((p,A)=>s.jsxs(L,{sx:{marginLeft:A===0?0:1,display:"inline-flex"},children:[p.title,": ",p.metric]},p.title))})]})}return c}V.propTypes={title:m.string,instanceCount:m.number,total:m.number,used:m.number,history:m.array,empty:m.node,onHover:m.func,hoverIndex:m.number};V.defaultProps={title:"",instanceCount:null,total:null,used:null,history:[],empty:null,onHover:()=>{},hoverIndex:null};function z({blocklet:n,...d}){const{t:l}=B(),{info:u}=rt(),{runtimeHistory:r}=O(),[c,i]=f.useState(null),o=f.useCallback(e=>n.status!=="running"?s.jsx(k,{children:l("blocklet.runtimeInfo.noRunning")}):e.length?null:s.jsx(v,{children:l("common.empty")}),[n.status,l]),h=f.useCallback(e=>{i(e)},[]);return r.length===0?s.jsx(k,{children:l("blocklet.runtimeInfo.noRunning")}):s.jsxs(ft,{component:"div",...d,children:[s.jsxs(C,{className:"page-metrics",container:!0,spacing:5,children:[s.jsx(C,{item:!0,xs:12,sx:{pt:"16px !important"},children:s.jsx(k,{fontSize:"16px",fontWeight:"bold",children:"CPU"})}),r==null?void 0:r.map(e=>{var t,a;return s.jsx(C,{item:!0,lg:4,md:6,sm:6,xs:12,sx:{pt:"16px !important"},children:s.jsx(N,{title:`${e.name} CPU`,empty:o(e.cpu),currentLoad:((t=e.appRuntimeInfo)==null?void 0:t.cpuUsage)||0,cpus:((a=e.appRuntimeInfo)==null?void 0:a.cpus)||[],history:e.cpu,onHover:h,hoverIndex:c,style:{height:150}})},`${e.key}-cpu`)})]}),s.jsxs(C,{className:"page-metrics",container:!0,spacing:5,sx:{mt:1},children:[s.jsx(C,{item:!0,xs:12,sx:{pt:"16px !important"},children:s.jsx(k,{fontSize:"16px",fontWeight:"bold",children:"Memory"})}),r==null?void 0:r.map(e=>{var t,a,w;return s.jsx(C,{item:!0,lg:4,md:6,sm:6,xs:12,sx:{pt:"16px !important"},children:s.jsx(V,{title:`${e.name} Memory`,empty:o(e.memory),total:(t=u.runtimeConfig)!=null&&t.blockletMaxMemoryLimit?E.parseSize(`${u.runtimeConfig.blockletMaxMemoryLimit*(e.key===((a=n==null?void 0:n.meta)==null?void 0:a.did)?r.length-1:1)}MiB`):0,used:((w=e.appRuntimeInfo)==null?void 0:w.memoryUsage)||0,history:e.memory,onHover:h,hoverIndex:c,style:{height:150}})},`${e.key}-memory`)})]})]})}z.propTypes={blocklet:m.object.isRequired,cpuHistory:m.arrayOf(m.shape({date:m.number,value:m.number})),memoryHistory:m.arrayOf(m.shape({date:m.number,value:m.number}))};z.defaultProps={cpuHistory:[],memoryHistory:[]};const ft=U(k)``;function K(){const{t:n,locale:d}=B(),[l,u]=f.useState(6),{blocklet:r,actions:{refreshBlocklet:c}}=O(),i=f.useMemo(()=>{const e=[];return P.forEachBlockletSync(r,(t,{ancestors:a,id:w,level:x})=>{var g;(g=t==null?void 0:t.meta)!=null&&g.did&&t.meta.did!==r.meta.did&&e.push({type:"blocklet",groupId:r.meta.did,groupName:P.getDisplayName(r),id:w,name:P.getDisplayName(t,!0),blocklet:r,component:t,level:x-1>=0?x-1:0,runtimeInfo:t.runtimeInfo,ancestors:a})}),e},[r]);f.useEffect(()=>{c({hours:l});const e=setInterval(()=>{c({hours:l})},1e3*10);return()=>{clearInterval(e)}},[l]);const o=e=>it(Number(e||0),{locale:ot(d)}),h=[{label:n("common.name"),name:"name",options:{customBodyRenderLite(e){const{name:t,component:a,level:w,ancestors:x}=i[e];return s.jsxs(L,{display:"flex",alignItems:"center",pl:w*2,children:[s.jsx(mt,{size:20,blocklet:a,ancestors:x}),s.jsx(L,{ml:1,children:t}),s.jsx(ut,{variant:"pin",style:{marginLeft:8},status:a.status,source:a.source,progress:a.progress})]})}}},{label:n("common.uptime"),name:"runtimeInfo.uptime",options:{customBodyRenderLite(e){const{runtimeInfo:t,component:a}=i[e];return!(a!=null&&a.status)||a.status!=="running"?s.jsx($,{title:n("common.noData"),children:"--"}):o(t==null?void 0:t.uptime)}}},{label:n("blocklet.runtimeInfo.memoryUsage"),name:"runtimeInfo.memoryUsage",options:{customBodyRenderLite(e){const{runtimeInfo:t,component:a}=i[e];return!(a!=null&&a.status)||a.status!=="running"?s.jsx($,{title:n("common.noData"),children:"--"}):F((t==null?void 0:t.memoryUsage)||0)}}},{label:n("blocklet.runtimeInfo.cpuUsage"),name:"runtimeInfo.cpuUsage",options:{customBodyRenderLite(e){const{runtimeInfo:t,component:a}=i[e];return!(a!=null&&a.status)||a.status!=="running"?s.jsx($,{title:n("common.noData"),children:"--"}):`${((t==null?void 0:t.cpuUsage)||0).toFixed(1)}%`}}},{label:n("analytics.runtime"),name:"runtimeInfo.runtime",options:{customBodyRenderLite(e){const{runtimeInfo:t}=i[e];return t!=null&&t.uptime?s.jsxs(L,{display:"flex",alignItems:"center",children:[s.jsx(tt,{icon:t!=null&&t.runningDocker?"catppuccin:docker-ignore":"logos:nodejs-icon"}),s.jsx(L,{ml:1,children:t!=null&&t.runningDocker?"Docker":"Nodejs"})]}):null}}},{label:n("blocklet.runtimeInfo.processId"),name:"runtimeInfo.pid",options:{customBodyRenderLite(e){const{runtimeInfo:t,component:a}=i[e];return!(a!=null&&a.status)||a.status!=="running"?s.jsx($,{title:n("common.noData"),children:"--"}):t==null?void 0:t.pid}}},{label:n("blocklet.runtimeInfo.port"),name:"runtimeInfo.port",options:{customBodyRenderLite(e){const{runtimeInfo:t,component:a}=i[e];return!(a!=null&&a.status)||a.status!=="running"?s.jsx($,{title:n("common.noData"),children:"--"}):t==null?void 0:t.port}}}];return s.jsxs(dt,{component:"div",children:[s.jsxs(L,{display:"flex",justifyContent:"space-between",flexDirection:"row",mb:2,children:[s.jsx(k,{component:"h3",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:2,children:n("analytics.trend")}),s.jsx(Q,{size:"small",exclusive:!0,value:l,onChange:(e,t)=>{ct(t)&&u(t)},children:[1,3,6,12,24].map(e=>s.jsxs(Y,{value:e,children:[e,"H"]},e))})]}),s.jsx(L,{children:s.jsx(z,{blocklet:r})}),s.jsx(L,{mt:3,children:s.jsx(et,{title:n("analytics.detail"),className:"monitor-table",locale:d,data:i,columns:h,options:{search:!1,download:!1,filter:!1,print:!1,viewColumns:!1,pagination:!1,rowsPerPage:100}})})]})}K.propTypes={};const dt=U(k)``;function _t(){const{t:n}=f.useContext(st),{did:d,client:l}=lt(),[u,r]=H(),[c,i]=f.useState(u.get("tab")||"traffic"),o=a=>{i(a)};f.useEffect(()=>{u.set("tab",c),r(u,{replace:!0})},[c]);const h=[{label:n("common.traffic"),value:"traffic"},{label:n("common.runtime"),value:"runtime"}],e={traffic:nt,runtime:K},t=e[c]||e.traffic;return s.jsxs(yt,{children:[s.jsx(pt,{left:s.jsx(at,{tabs:h,current:c,onChange:o})}),s.jsx("div",{className:"page-content",children:f.isValidElement(t)?t:s.jsx(t,{client:l,did:d})})]},c)}const yt=U.main`
|
|
2
|
+
.page-header {
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
align-items: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.page-content {
|
|
9
|
+
margin-top: 16px;
|
|
10
|
+
}
|
|
11
|
+
`;export{_t as default};
|