@blocklet/launcher-layout 2.3.20 → 2.3.22
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/lib/compact-layout.js +55 -34
- package/lib/content.js +67 -20
- package/lib/context/step.js +19 -28
- package/lib/header.js +224 -91
- package/lib/index.js +198 -101
- package/lib/info-list.js +45 -0
- package/lib/launch-result-message.js +116 -55
- package/lib/locale.js +1 -8
- package/lib/markdown-body.js +45 -21
- package/lib/nav.js +300 -51
- package/lib/page-header.js +51 -38
- package/lib/theme-provider.js +24 -32
- package/lib/wizard/server-eula.js +60 -41
- package/lib/wizard/wizard-desc.js +129 -114
- package/package.json +12 -26
- package/es/assets/blocklet-default-logo.png +0 -0
- package/es/compact-layout.js +0 -114
- package/es/content.js +0 -72
- package/es/context/step.js +0 -137
- package/es/header.js +0 -337
- package/es/index.js +0 -307
- package/es/launch-result-message.js +0 -144
- package/es/locale.js +0 -13
- package/es/markdown-body.js +0 -52
- package/es/nav.js +0 -405
- package/es/page-header.js +0 -66
- package/es/theme-provider.js +0 -41
- package/es/wizard/server-eula.js +0 -96
- package/es/wizard/wizard-desc.js +0 -332
package/es/wizard/wizard-desc.js
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { createElement } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { getDisplayName } from '@blocklet/meta/lib/util';
|
|
4
|
-
import DID from '@arcblock/ux/lib/DID';
|
|
5
|
-
import get from 'lodash/get';
|
|
6
|
-
import styled from '@emotion/styled';
|
|
7
|
-
import MarkdownPreview from '@uiw/react-markdown-preview';
|
|
8
|
-
import { Box, Table, TableBody, TableCell, TableContainer, TableRow, Typography } from '@mui/material';
|
|
9
|
-
import RehypeReact from 'rehype-react';
|
|
10
|
-
import joinURL from 'url-join';
|
|
11
|
-
import { useCreation, useRequest } from 'ahooks';
|
|
12
|
-
import MarkdownBody from '../markdown-body';
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
const isFreeBlocklet = meta => {
|
|
15
|
-
if (!meta.payment) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
const priceList = (meta.payment.price || []).map(x => x.value || 0);
|
|
19
|
-
return priceList.every(x => x === 0);
|
|
20
|
-
};
|
|
21
|
-
const renderAst = new RehypeReact({
|
|
22
|
-
createElement
|
|
23
|
-
}).Compiler;
|
|
24
|
-
const localeData = {
|
|
25
|
-
zh: {
|
|
26
|
-
appinfo: {
|
|
27
|
-
name: '应用名',
|
|
28
|
-
version: '版本号',
|
|
29
|
-
author: '开发者',
|
|
30
|
-
description: '描述',
|
|
31
|
-
community: '社区地址',
|
|
32
|
-
documentation: '文档手册',
|
|
33
|
-
support: '服务支持',
|
|
34
|
-
overview: '概述',
|
|
35
|
-
requirements: '节点版本要求'
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
en: {
|
|
39
|
-
appinfo: {
|
|
40
|
-
name: 'Name',
|
|
41
|
-
version: 'Version',
|
|
42
|
-
author: 'Author',
|
|
43
|
-
description: 'Description',
|
|
44
|
-
community: 'Community',
|
|
45
|
-
documentation: 'Documentation',
|
|
46
|
-
support: 'Support',
|
|
47
|
-
overview: 'Overview',
|
|
48
|
-
requirements: 'Server requirements'
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
function WizardDesc({
|
|
53
|
-
blockletMeta,
|
|
54
|
-
locale,
|
|
55
|
-
handleDescEle
|
|
56
|
-
}) {
|
|
57
|
-
const {
|
|
58
|
-
data
|
|
59
|
-
} = blockletMeta;
|
|
60
|
-
|
|
61
|
-
// FIXME: @zhanghan 暂且假定这里是有 registryUrl 的值的,后续需要更好的方式来判断一个 blocklet 来源于哪个 registryUrl
|
|
62
|
-
const {
|
|
63
|
-
registryUrl,
|
|
64
|
-
did
|
|
65
|
-
} = data;
|
|
66
|
-
const name = getDisplayName({
|
|
67
|
-
meta: data
|
|
68
|
-
});
|
|
69
|
-
const readmeState = useRequest(() => {
|
|
70
|
-
if (registryUrl && did) {
|
|
71
|
-
return fetch(joinURL(registryUrl, '/api/blocklets', did, 'readme')).then(res => res.json());
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
}, {
|
|
75
|
-
refreshDeps: [registryUrl, did]
|
|
76
|
-
});
|
|
77
|
-
const markdownSource = useCreation(() => {
|
|
78
|
-
if (!readmeState.data) {
|
|
79
|
-
return '';
|
|
80
|
-
}
|
|
81
|
-
return readmeState.data[locale] || readmeState.data.en || readmeState.data[Object.keys(readmeState.data)[0]];
|
|
82
|
-
}, [readmeState]);
|
|
83
|
-
const blockletDesc = data && data.htmlAst ? renderAst(data.htmlAst) : '';
|
|
84
|
-
const isFree = isFreeBlocklet(data);
|
|
85
|
-
let authorInfo = get(data, 'owner.fullName');
|
|
86
|
-
if (authorInfo) {
|
|
87
|
-
const ownerDid = get(data, 'owner.did');
|
|
88
|
-
if (ownerDid) {
|
|
89
|
-
authorInfo = /*#__PURE__*/_jsxs(Box, {
|
|
90
|
-
sx: {
|
|
91
|
-
display: 'flex',
|
|
92
|
-
alignItems: 'center',
|
|
93
|
-
gap: 1
|
|
94
|
-
},
|
|
95
|
-
children: [authorInfo, /*#__PURE__*/_jsx(DID, {
|
|
96
|
-
sx: {
|
|
97
|
-
lineHeight: 'initial',
|
|
98
|
-
'&::before': {
|
|
99
|
-
content: '"("'
|
|
100
|
-
},
|
|
101
|
-
'&::after': {
|
|
102
|
-
content: '")"'
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
did: ownerDid,
|
|
106
|
-
compact: true,
|
|
107
|
-
size: 14,
|
|
108
|
-
locale: locale
|
|
109
|
-
})]
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
authorInfo = get(data, 'author.name');
|
|
114
|
-
}
|
|
115
|
-
const infos = [{
|
|
116
|
-
key: get(localeData[locale], 'appinfo.name'),
|
|
117
|
-
value: getDisplayName({
|
|
118
|
-
meta: data
|
|
119
|
-
})
|
|
120
|
-
}, {
|
|
121
|
-
key: get(localeData[locale], 'appinfo.version'),
|
|
122
|
-
value: data.version
|
|
123
|
-
}, {
|
|
124
|
-
key: get(localeData[locale], 'appinfo.author'),
|
|
125
|
-
value: authorInfo
|
|
126
|
-
}, {
|
|
127
|
-
type: 'description',
|
|
128
|
-
key: get(localeData[locale], 'appinfo.description'),
|
|
129
|
-
value: data.description
|
|
130
|
-
}];
|
|
131
|
-
if (data.requirements) {
|
|
132
|
-
infos.push({
|
|
133
|
-
key: get(localeData[locale], 'appinfo.requirements'),
|
|
134
|
-
value: data.requirements.server
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
if (data.community) {
|
|
138
|
-
infos.push({
|
|
139
|
-
key: get(localeData[locale], 'appinfo.community'),
|
|
140
|
-
value: /*#__PURE__*/_jsx("a", {
|
|
141
|
-
href: data.community,
|
|
142
|
-
target: "_blank",
|
|
143
|
-
rel: "noreferrer",
|
|
144
|
-
children: data.community
|
|
145
|
-
})
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
if (data.documentation) {
|
|
149
|
-
infos.push({
|
|
150
|
-
key: get(localeData[locale], 'appinfo.documentation'),
|
|
151
|
-
value: /*#__PURE__*/_jsx("a", {
|
|
152
|
-
href: data.documentation,
|
|
153
|
-
target: "_blank",
|
|
154
|
-
rel: "noreferrer",
|
|
155
|
-
children: data.documentation
|
|
156
|
-
})
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
if (data.support) {
|
|
160
|
-
infos.push({
|
|
161
|
-
key: get(localeData[locale], 'appinfo.support'),
|
|
162
|
-
value: /*#__PURE__*/_jsx("a", {
|
|
163
|
-
href: `mailto:${data.support}`,
|
|
164
|
-
target: "_blank",
|
|
165
|
-
rel: "noreferrer",
|
|
166
|
-
children: data.support
|
|
167
|
-
})
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (blockletDesc) {
|
|
171
|
-
infos.push({
|
|
172
|
-
key: get(localeData[locale], 'appinfo.overview'),
|
|
173
|
-
value: ''
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
let descEle;
|
|
177
|
-
if (locale === 'zh') {
|
|
178
|
-
descEle = /*#__PURE__*/_jsxs(_Fragment, {
|
|
179
|
-
children: [isFree ? /*#__PURE__*/_jsxs("p", {
|
|
180
|
-
children: ["\u60A8\u53EF\u4EE5\u514D\u8D39\u4F7F\u7528 ", /*#__PURE__*/_jsx("b", {
|
|
181
|
-
children: name
|
|
182
|
-
}), "\uFF1B"]
|
|
183
|
-
}) : /*#__PURE__*/_jsxs("p", {
|
|
184
|
-
children: ["\u60A8\u9700\u8981\u8D2D\u4E70\u624D\u80FD\u4F7F\u7528 ", /*#__PURE__*/_jsx("b", {
|
|
185
|
-
children: name
|
|
186
|
-
}), "\uFF1B"]
|
|
187
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
188
|
-
children: "\u5728\u5E94\u7528\u542F\u52A8\u524D\uFF0C\u9700\u8981\u9009\u62E9\u60A8\u7684\u8282\u70B9\uFF1B"
|
|
189
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
190
|
-
children: "\u5982\u679C\u60A8\u6CA1\u6709\u8282\u70B9\uFF0C\u6211\u4EEC\u4F1A\u5F15\u5BFC\u60A8\u521B\u5EFA\u65B0\u7684\u8282\u70B9\uFF1B"
|
|
191
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
192
|
-
children: "\u4E0B\u9762\u4E3A\u8BE5\u5E94\u7528\u7684\u4FE1\u606F\uFF1A"
|
|
193
|
-
})]
|
|
194
|
-
});
|
|
195
|
-
} else {
|
|
196
|
-
descEle = /*#__PURE__*/_jsxs(_Fragment, {
|
|
197
|
-
children: [isFree ? /*#__PURE__*/_jsxs("p", {
|
|
198
|
-
children: ["You can use ", /*#__PURE__*/_jsx("b", {
|
|
199
|
-
children: name
|
|
200
|
-
}), " for free;"]
|
|
201
|
-
}) : /*#__PURE__*/_jsxs("p", {
|
|
202
|
-
children: ["You need to purchase before launch ", /*#__PURE__*/_jsx("b", {
|
|
203
|
-
children: name
|
|
204
|
-
}), ";"]
|
|
205
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
206
|
-
children: "Before the blocklet starts, you need to select your Blocklet Server; "
|
|
207
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
208
|
-
children: "If you do not have any Blocklet Server, we will guide you to create a new one; "
|
|
209
|
-
}), /*#__PURE__*/_jsx("p", {
|
|
210
|
-
children: "Below is the information for the blocklet: "
|
|
211
|
-
})]
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
return /*#__PURE__*/_jsxs(Container, {
|
|
215
|
-
children: [handleDescEle || descEle, /*#__PURE__*/_jsx("div", {
|
|
216
|
-
className: "info-table",
|
|
217
|
-
children: /*#__PURE__*/_jsx(TableContainer, {
|
|
218
|
-
children: /*#__PURE__*/_jsx(Table, {
|
|
219
|
-
size: "small",
|
|
220
|
-
children: /*#__PURE__*/_jsx(TableBody, {
|
|
221
|
-
children: infos.map(e => {
|
|
222
|
-
return /*#__PURE__*/_jsxs(TableRow, {
|
|
223
|
-
children: [/*#__PURE__*/_jsx(TableCell, {
|
|
224
|
-
component: "th",
|
|
225
|
-
scope: "row",
|
|
226
|
-
style: {
|
|
227
|
-
width: 100
|
|
228
|
-
},
|
|
229
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
230
|
-
style: {
|
|
231
|
-
fontWeight: 'bold',
|
|
232
|
-
whiteSpace: 'nowrap'
|
|
233
|
-
},
|
|
234
|
-
children: e.key
|
|
235
|
-
})
|
|
236
|
-
}), /*#__PURE__*/_jsx(TableCell, {
|
|
237
|
-
children: e.value
|
|
238
|
-
})]
|
|
239
|
-
}, e.key);
|
|
240
|
-
})
|
|
241
|
-
})
|
|
242
|
-
})
|
|
243
|
-
})
|
|
244
|
-
}), markdownSource ? /*#__PURE__*/_jsxs("div", {
|
|
245
|
-
className: "app-overview",
|
|
246
|
-
children: [/*#__PURE__*/_jsx(Typography, {
|
|
247
|
-
variant: "h5",
|
|
248
|
-
gutterBottom: true,
|
|
249
|
-
children: get(localeData[locale], 'appinfo.overview')
|
|
250
|
-
}), /*#__PURE__*/_jsx(MarkdownBody, {
|
|
251
|
-
children: /*#__PURE__*/_jsx(PostContent, {
|
|
252
|
-
component: "div",
|
|
253
|
-
className: "content-wrapper post-content",
|
|
254
|
-
children: /*#__PURE__*/_jsx(MarkdownPreview, {
|
|
255
|
-
source: markdownSource
|
|
256
|
-
// 先保留后面两个参数,可用于精细判断
|
|
257
|
-
// eslint-disable-next-line no-unused-vars
|
|
258
|
-
,
|
|
259
|
-
urlTransform: (url, key, node) => {
|
|
260
|
-
if (url.startsWith('/')) {
|
|
261
|
-
return joinURL(registryUrl, url);
|
|
262
|
-
}
|
|
263
|
-
return url;
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
})
|
|
267
|
-
})]
|
|
268
|
-
}) : blockletDesc ? /*#__PURE__*/_jsx("div", {
|
|
269
|
-
className: "app-overview",
|
|
270
|
-
children: blockletDesc
|
|
271
|
-
}) : null]
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
const PostContent = styled(Typography)`
|
|
275
|
-
width: 100%;
|
|
276
|
-
word-wrap: break-word;
|
|
277
|
-
word-break: break-word;
|
|
278
|
-
line-height: 1.5em;
|
|
279
|
-
min-height: 10vh;
|
|
280
|
-
margin-bottom: 40px !important;
|
|
281
|
-
|
|
282
|
-
.alert-content {
|
|
283
|
-
max-width: 100%;
|
|
284
|
-
p:last-of-type {
|
|
285
|
-
margin-bottom: 0;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
iframe {
|
|
290
|
-
width: 100% !important;
|
|
291
|
-
}
|
|
292
|
-
`;
|
|
293
|
-
const Container = styled.div`
|
|
294
|
-
.info-table {
|
|
295
|
-
a {
|
|
296
|
-
word-break: break-all;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
.app-overview {
|
|
300
|
-
font-size: 16px;
|
|
301
|
-
margin: 16px 0 0 16px;
|
|
302
|
-
h1 {
|
|
303
|
-
margin: 8px 0;
|
|
304
|
-
font-size: 20px;
|
|
305
|
-
}
|
|
306
|
-
h2 {
|
|
307
|
-
margin: 8px 0;
|
|
308
|
-
font-size: 18px;
|
|
309
|
-
}
|
|
310
|
-
ul {
|
|
311
|
-
display: block;
|
|
312
|
-
list-style-type: disc;
|
|
313
|
-
padding-left: 2em;
|
|
314
|
-
li {
|
|
315
|
-
display: list-item;
|
|
316
|
-
list-style: disc;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
blockquote {
|
|
320
|
-
margin-left: 2em;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
`;
|
|
324
|
-
WizardDesc.propTypes = {
|
|
325
|
-
blockletMeta: PropTypes.object.isRequired,
|
|
326
|
-
locale: PropTypes.string.isRequired,
|
|
327
|
-
handleDescEle: PropTypes.node
|
|
328
|
-
};
|
|
329
|
-
WizardDesc.defaultProps = {
|
|
330
|
-
handleDescEle: ''
|
|
331
|
-
};
|
|
332
|
-
export default WizardDesc;
|