@abtnode/ux 1.16.21-beta-420f105a → 1.16.21-beta-445a8baa
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/blocklet/component/index.js +4 -2
- package/es/blocklet/overview.js +2 -1
- package/es/blocklet/status.js +13 -3
- package/es/hooks/blocklet.js +75 -0
- package/es/locales/en.js +1 -0
- package/es/locales/zh.js +1 -0
- package/es/util/parse-progress.js +10 -0
- package/lib/blocklet/component/index.js +4 -2
- package/lib/blocklet/overview.js +2 -1
- package/lib/blocklet/status.js +15 -5
- package/lib/hooks/blocklet.js +89 -11
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/util/parse-progress.js +16 -0
- package/package.json +7 -7
|
@@ -182,7 +182,8 @@ function ComponentItem({
|
|
|
182
182
|
name: t('common.status'),
|
|
183
183
|
value: /*#__PURE__*/_jsx(BlockletStatus, {
|
|
184
184
|
status: status,
|
|
185
|
-
source: componentInfo.source
|
|
185
|
+
source: componentInfo.source,
|
|
186
|
+
progress: blocklet.progress
|
|
186
187
|
})
|
|
187
188
|
}, blocklet.status === 'running' ? {
|
|
188
189
|
name: t('blocklet.startedAt'),
|
|
@@ -298,7 +299,8 @@ function ComponentItem({
|
|
|
298
299
|
marginLeft: 4
|
|
299
300
|
},
|
|
300
301
|
status: status,
|
|
301
|
-
source: blocklet.source
|
|
302
|
+
source: blocklet.source,
|
|
303
|
+
progress: blocklet.progress
|
|
302
304
|
}), /*#__PURE__*/_jsx(BlockletMode, {
|
|
303
305
|
style: {
|
|
304
306
|
marginLeft: 4
|
package/es/blocklet/overview.js
CHANGED
|
@@ -71,7 +71,8 @@ export default function BlockletOverview() {
|
|
|
71
71
|
name: t('common.status'),
|
|
72
72
|
value: /*#__PURE__*/_jsx(BlockletStatus, {
|
|
73
73
|
status: blocklet.status,
|
|
74
|
-
source: blocklet.source
|
|
74
|
+
source: blocklet.source,
|
|
75
|
+
progress: blocklet.progress
|
|
75
76
|
})
|
|
76
77
|
}, isServerless(blocklet) ? {
|
|
77
78
|
name: 'NFT',
|
package/es/blocklet/status.js
CHANGED
|
@@ -16,6 +16,7 @@ export default function BlockletStatus({
|
|
|
16
16
|
status,
|
|
17
17
|
variant,
|
|
18
18
|
source,
|
|
19
|
+
progress,
|
|
19
20
|
...rest
|
|
20
21
|
}) {
|
|
21
22
|
const {
|
|
@@ -25,6 +26,7 @@ export default function BlockletStatus({
|
|
|
25
26
|
added: 'primary',
|
|
26
27
|
waiting: 'warning',
|
|
27
28
|
downloading: 'warning',
|
|
29
|
+
extracting: 'warning',
|
|
28
30
|
downloaded: 'primary',
|
|
29
31
|
installing: 'warning',
|
|
30
32
|
installed: 'primary',
|
|
@@ -42,6 +44,7 @@ export default function BlockletStatus({
|
|
|
42
44
|
added: colors.grey,
|
|
43
45
|
waiting: colors.yellow,
|
|
44
46
|
downloading: colors.yellow,
|
|
47
|
+
extracting: colors.yellow,
|
|
45
48
|
downloaded: colors.grey,
|
|
46
49
|
installing: colors.yellow,
|
|
47
50
|
installed: colors.grey,
|
|
@@ -77,15 +80,22 @@ export default function BlockletStatus({
|
|
|
77
80
|
style: {
|
|
78
81
|
marginRight: 5
|
|
79
82
|
}
|
|
80
|
-
}), statusTxt
|
|
83
|
+
}), statusTxt, status === 'downloading' && progress ? /*#__PURE__*/_jsx("div", {
|
|
84
|
+
style: {
|
|
85
|
+
marginLeft: 5
|
|
86
|
+
},
|
|
87
|
+
children: `${progress} %`
|
|
88
|
+
}) : null]
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
91
|
BlockletStatus.propTypes = {
|
|
84
92
|
status: PropTypes.string.isRequired,
|
|
85
93
|
variant: PropTypes.oneOf(['dot', 'tag']),
|
|
86
|
-
source: PropTypes.string
|
|
94
|
+
source: PropTypes.string,
|
|
95
|
+
progress: PropTypes.number
|
|
87
96
|
};
|
|
88
97
|
BlockletStatus.defaultProps = {
|
|
89
98
|
variant: 'tag',
|
|
90
|
-
source: ''
|
|
99
|
+
source: '',
|
|
100
|
+
progress: 0
|
|
91
101
|
};
|
package/es/hooks/blocklet.js
CHANGED
|
@@ -6,6 +6,18 @@ import Toast from '@arcblock/ux/lib/Toast';
|
|
|
6
6
|
import { toSlotDomain, getBlockletUrlParams, getBlockletUrl } from '../util';
|
|
7
7
|
import { fixBlocklet } from '../blocklet/util';
|
|
8
8
|
import { useDomainsAccessibility } from './url-evaluation';
|
|
9
|
+
import parseProgress from '../util/parse-progress';
|
|
10
|
+
const excludeDownloadingStatus = {
|
|
11
|
+
waiting: 1,
|
|
12
|
+
installing: 1,
|
|
13
|
+
installed: 1,
|
|
14
|
+
starting: 1,
|
|
15
|
+
running: 1,
|
|
16
|
+
stopped: 1,
|
|
17
|
+
upgrading: 1,
|
|
18
|
+
restarting: 1,
|
|
19
|
+
deleting: 1
|
|
20
|
+
};
|
|
9
21
|
|
|
10
22
|
// eslint-disable-next-line import/prefer-default-export
|
|
11
23
|
export function useBlocklet({
|
|
@@ -104,6 +116,12 @@ export function useBlocklet({
|
|
|
104
116
|
fixRuntime: 'merge-old',
|
|
105
117
|
oldBlocklet
|
|
106
118
|
});
|
|
119
|
+
if (oldBlocklet && excludeDownloadingStatus[data.status]) {
|
|
120
|
+
oldBlocklet?.children?.forEach(item => {
|
|
121
|
+
delete item.progress;
|
|
122
|
+
});
|
|
123
|
+
delete oldBlocklet.progress;
|
|
124
|
+
}
|
|
107
125
|
return data;
|
|
108
126
|
});
|
|
109
127
|
setLoading(false);
|
|
@@ -137,6 +155,62 @@ export function useBlocklet({
|
|
|
137
155
|
});
|
|
138
156
|
}
|
|
139
157
|
};
|
|
158
|
+
const handleProgress = data => {
|
|
159
|
+
if (!data || data.meta?.did !== blocklet?.meta?.did) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (data.status === 'extracting') {
|
|
163
|
+
setBlocklet(oldBlocklet => {
|
|
164
|
+
if (!oldBlocklet) {
|
|
165
|
+
return oldBlocklet;
|
|
166
|
+
}
|
|
167
|
+
const children = oldBlocklet.children || [];
|
|
168
|
+
children.forEach(x => {
|
|
169
|
+
if (x.meta?.bundleDid === data.component?.did) {
|
|
170
|
+
x.status = data.status;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// 判断当前下载的 children 是否都处于 extracting
|
|
175
|
+
const extracting = children.every(x => {
|
|
176
|
+
if (excludeDownloadingStatus[x.status]) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
return x.status === 'extracting';
|
|
180
|
+
});
|
|
181
|
+
return {
|
|
182
|
+
...oldBlocklet,
|
|
183
|
+
children,
|
|
184
|
+
status: extracting ? 'extracting' : oldBlocklet.status
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (data.status === 'downloading' && data.total) {
|
|
189
|
+
setBlocklet(oldBlocklet => {
|
|
190
|
+
if (!oldBlocklet) {
|
|
191
|
+
return oldBlocklet;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// keep largest files as progress
|
|
195
|
+
const children = oldBlocklet.children || [];
|
|
196
|
+
let progress = 100;
|
|
197
|
+
children.forEach(item => {
|
|
198
|
+
if (item.meta?.bundleDid === data.component?.did) {
|
|
199
|
+
item.progress = parseProgress(data.current, data.total);
|
|
200
|
+
item.status = data.status;
|
|
201
|
+
if (item.progress < progress) {
|
|
202
|
+
progress = item.progress;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
...oldBlocklet,
|
|
208
|
+
children,
|
|
209
|
+
progress
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
140
214
|
const refreshDomainStatus = () => {
|
|
141
215
|
if (did && domainListStr) {
|
|
142
216
|
client.checkDomains({
|
|
@@ -196,6 +270,7 @@ export function useBlocklet({
|
|
|
196
270
|
useSubscription(BlockletEvents.installed, handleRefresh, [blocklet?.meta?.did, !disableSubscription]);
|
|
197
271
|
useSubscription(BlockletEvents.upgraded, handleRefresh, [blocklet?.meta?.did, !disableSubscription]);
|
|
198
272
|
useSubscription(BlockletEvents.updated, handleRefresh, [blocklet?.meta?.did, !disableSubscription]);
|
|
273
|
+
useSubscription(BlockletEvents.downloadBundleProgress, handleProgress, [blocklet?.meta?.did, !disableSubscription]);
|
|
199
274
|
const data = blocklet ? merge(blocklet, {
|
|
200
275
|
site: {
|
|
201
276
|
domainAliases: blocklet.site.domainAliases.map(x => {
|
package/es/locales/en.js
CHANGED
package/es/locales/zh.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// 0~100
|
|
2
|
+
const parseProgress = (current, total) => {
|
|
3
|
+
const totalNumber = typeof total !== 'number' ? Number(total) : total;
|
|
4
|
+
if (Number.isNaN(totalNumber) || totalNumber <= 0) {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
const value = Math.floor(current / totalNumber * 100);
|
|
8
|
+
return Math.min(Math.max(value, 0), 100);
|
|
9
|
+
};
|
|
10
|
+
export default parseProgress;
|
|
@@ -205,7 +205,8 @@ function ComponentItem(_ref) {
|
|
|
205
205
|
name: t('common.status'),
|
|
206
206
|
value: /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
|
|
207
207
|
status: status,
|
|
208
|
-
source: componentInfo.source
|
|
208
|
+
source: componentInfo.source,
|
|
209
|
+
progress: blocklet.progress
|
|
209
210
|
})
|
|
210
211
|
}, blocklet.status === 'running' ? {
|
|
211
212
|
name: t('blocklet.startedAt'),
|
|
@@ -324,7 +325,8 @@ function ComponentItem(_ref) {
|
|
|
324
325
|
marginLeft: 4
|
|
325
326
|
},
|
|
326
327
|
status: status,
|
|
327
|
-
source: blocklet.source
|
|
328
|
+
source: blocklet.source,
|
|
329
|
+
progress: blocklet.progress
|
|
328
330
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_mode.default, {
|
|
329
331
|
style: {
|
|
330
332
|
marginLeft: 4
|
package/lib/blocklet/overview.js
CHANGED
|
@@ -82,7 +82,8 @@ function BlockletOverview() {
|
|
|
82
82
|
name: t('common.status'),
|
|
83
83
|
value: /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
|
|
84
84
|
status: blocklet.status,
|
|
85
|
-
source: blocklet.source
|
|
85
|
+
source: blocklet.source,
|
|
86
|
+
progress: blocklet.progress
|
|
86
87
|
})
|
|
87
88
|
}, (0, _util3.isServerless)(blocklet) ? {
|
|
88
89
|
name: 'NFT',
|
package/lib/blocklet/status.js
CHANGED
|
@@ -13,7 +13,7 @@ var _util = require("@blocklet/meta/lib/util");
|
|
|
13
13
|
var _dot = _interopRequireDefault(require("../dot"));
|
|
14
14
|
var _tag = _interopRequireDefault(require("../tag"));
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
const _excluded = ["status", "variant", "source"];
|
|
16
|
+
const _excluded = ["status", "variant", "source", "progress"];
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
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; }
|
|
19
19
|
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; }
|
|
@@ -30,7 +30,8 @@ function BlockletStatus(_ref) {
|
|
|
30
30
|
let {
|
|
31
31
|
status,
|
|
32
32
|
variant,
|
|
33
|
-
source
|
|
33
|
+
source,
|
|
34
|
+
progress
|
|
34
35
|
} = _ref,
|
|
35
36
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
36
37
|
const {
|
|
@@ -40,6 +41,7 @@ function BlockletStatus(_ref) {
|
|
|
40
41
|
added: 'primary',
|
|
41
42
|
waiting: 'warning',
|
|
42
43
|
downloading: 'warning',
|
|
44
|
+
extracting: 'warning',
|
|
43
45
|
downloaded: 'primary',
|
|
44
46
|
installing: 'warning',
|
|
45
47
|
installed: 'primary',
|
|
@@ -57,6 +59,7 @@ function BlockletStatus(_ref) {
|
|
|
57
59
|
added: colors.grey,
|
|
58
60
|
waiting: colors.yellow,
|
|
59
61
|
downloading: colors.yellow,
|
|
62
|
+
extracting: colors.yellow,
|
|
60
63
|
downloaded: colors.grey,
|
|
61
64
|
installing: colors.yellow,
|
|
62
65
|
installed: colors.grey,
|
|
@@ -91,15 +94,22 @@ function BlockletStatus(_ref) {
|
|
|
91
94
|
style: {
|
|
92
95
|
marginRight: 5
|
|
93
96
|
}
|
|
94
|
-
}), statusTxt
|
|
97
|
+
}), statusTxt, status === 'downloading' && progress ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
98
|
+
style: {
|
|
99
|
+
marginLeft: 5
|
|
100
|
+
},
|
|
101
|
+
children: "".concat(progress, " %")
|
|
102
|
+
}) : null]
|
|
95
103
|
}));
|
|
96
104
|
}
|
|
97
105
|
BlockletStatus.propTypes = {
|
|
98
106
|
status: _propTypes.default.string.isRequired,
|
|
99
107
|
variant: _propTypes.default.oneOf(['dot', 'tag']),
|
|
100
|
-
source: _propTypes.default.string
|
|
108
|
+
source: _propTypes.default.string,
|
|
109
|
+
progress: _propTypes.default.number
|
|
101
110
|
};
|
|
102
111
|
BlockletStatus.defaultProps = {
|
|
103
112
|
variant: 'tag',
|
|
104
|
-
source: ''
|
|
113
|
+
source: '',
|
|
114
|
+
progress: 0
|
|
105
115
|
};
|
package/lib/hooks/blocklet.js
CHANGED
|
@@ -12,15 +12,28 @@ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
|
12
12
|
var _util = require("../util");
|
|
13
13
|
var _util2 = require("../blocklet/util");
|
|
14
14
|
var _urlEvaluation = require("./url-evaluation");
|
|
15
|
+
var _parseProgress = _interopRequireDefault(require("../util/parse-progress"));
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
17
|
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; }
|
|
17
18
|
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; }
|
|
18
19
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
20
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
20
21
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
|
+
const excludeDownloadingStatus = {
|
|
23
|
+
waiting: 1,
|
|
24
|
+
installing: 1,
|
|
25
|
+
installed: 1,
|
|
26
|
+
starting: 1,
|
|
27
|
+
running: 1,
|
|
28
|
+
stopped: 1,
|
|
29
|
+
upgrading: 1,
|
|
30
|
+
restarting: 1,
|
|
31
|
+
deleting: 1
|
|
32
|
+
};
|
|
33
|
+
|
|
21
34
|
// eslint-disable-next-line import/prefer-default-export
|
|
22
35
|
function useBlocklet(_ref) {
|
|
23
|
-
var _blocklet$site, _blocklet$site$domain, _blocklet$
|
|
36
|
+
var _blocklet$site, _blocklet$site$domain, _blocklet$meta2, _blocklet$meta3, _blocklet$meta4, _blocklet$meta5, _blocklet$meta6, _blocklet$meta7, _blocklet$meta8;
|
|
24
37
|
let {
|
|
25
38
|
did,
|
|
26
39
|
client,
|
|
@@ -121,6 +134,13 @@ function useBlocklet(_ref) {
|
|
|
121
134
|
fixRuntime: 'merge-old',
|
|
122
135
|
oldBlocklet
|
|
123
136
|
});
|
|
137
|
+
if (oldBlocklet && excludeDownloadingStatus[data.status]) {
|
|
138
|
+
var _oldBlocklet$children;
|
|
139
|
+
oldBlocklet === null || oldBlocklet === void 0 ? void 0 : (_oldBlocklet$children = oldBlocklet.children) === null || _oldBlocklet$children === void 0 ? void 0 : _oldBlocklet$children.forEach(item => {
|
|
140
|
+
delete item.progress;
|
|
141
|
+
});
|
|
142
|
+
delete oldBlocklet.progress;
|
|
143
|
+
}
|
|
124
144
|
return data;
|
|
125
145
|
});
|
|
126
146
|
setLoading(false);
|
|
@@ -156,6 +176,63 @@ function useBlocklet(_ref) {
|
|
|
156
176
|
});
|
|
157
177
|
}
|
|
158
178
|
};
|
|
179
|
+
const handleProgress = data => {
|
|
180
|
+
var _data$meta3, _blocklet$meta;
|
|
181
|
+
if (!data || ((_data$meta3 = data.meta) === null || _data$meta3 === void 0 ? void 0 : _data$meta3.did) !== (blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did)) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (data.status === 'extracting') {
|
|
185
|
+
setBlocklet(oldBlocklet => {
|
|
186
|
+
if (!oldBlocklet) {
|
|
187
|
+
return oldBlocklet;
|
|
188
|
+
}
|
|
189
|
+
const children = oldBlocklet.children || [];
|
|
190
|
+
children.forEach(x => {
|
|
191
|
+
var _x$meta, _data$component;
|
|
192
|
+
if (((_x$meta = x.meta) === null || _x$meta === void 0 ? void 0 : _x$meta.bundleDid) === ((_data$component = data.component) === null || _data$component === void 0 ? void 0 : _data$component.did)) {
|
|
193
|
+
x.status = data.status;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// 判断当前下载的 children 是否都处于 extracting
|
|
198
|
+
const extracting = children.every(x => {
|
|
199
|
+
if (excludeDownloadingStatus[x.status]) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
return x.status === 'extracting';
|
|
203
|
+
});
|
|
204
|
+
return _objectSpread(_objectSpread({}, oldBlocklet), {}, {
|
|
205
|
+
children,
|
|
206
|
+
status: extracting ? 'extracting' : oldBlocklet.status
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (data.status === 'downloading' && data.total) {
|
|
211
|
+
setBlocklet(oldBlocklet => {
|
|
212
|
+
if (!oldBlocklet) {
|
|
213
|
+
return oldBlocklet;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// keep largest files as progress
|
|
217
|
+
const children = oldBlocklet.children || [];
|
|
218
|
+
let progress = 100;
|
|
219
|
+
children.forEach(item => {
|
|
220
|
+
var _item$meta, _data$component2;
|
|
221
|
+
if (((_item$meta = item.meta) === null || _item$meta === void 0 ? void 0 : _item$meta.bundleDid) === ((_data$component2 = data.component) === null || _data$component2 === void 0 ? void 0 : _data$component2.did)) {
|
|
222
|
+
item.progress = (0, _parseProgress.default)(data.current, data.total);
|
|
223
|
+
item.status = data.status;
|
|
224
|
+
if (item.progress < progress) {
|
|
225
|
+
progress = item.progress;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return _objectSpread(_objectSpread({}, oldBlocklet), {}, {
|
|
230
|
+
children,
|
|
231
|
+
progress
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
};
|
|
159
236
|
const refreshDomainStatus = () => {
|
|
160
237
|
if (did && domainListStr) {
|
|
161
238
|
client.checkDomains({
|
|
@@ -188,17 +265,17 @@ function useBlocklet(_ref) {
|
|
|
188
265
|
setDomainStatus(pre => _objectSpread(_objectSpread({}, pre), {}, {
|
|
189
266
|
[data.domain]: _objectSpread(_objectSpread({}, pre[data.domain]), data)
|
|
190
267
|
}));
|
|
191
|
-
}, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$
|
|
268
|
+
}, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did, !disableSubscription]);
|
|
192
269
|
useSubscription(_constant.BlockletEvents.statusChange, data => {
|
|
193
|
-
var _data$
|
|
194
|
-
if ((data === null || data === void 0 ? void 0 : (_data$
|
|
270
|
+
var _data$meta4;
|
|
271
|
+
if ((data === null || data === void 0 ? void 0 : (_data$meta4 = data.meta) === null || _data$meta4 === void 0 ? void 0 : _data$meta4.did) === blocklet.meta.did) {
|
|
195
272
|
setBlocklet(oldBlocklet => {
|
|
196
273
|
const newBlocklet = _objectSpread({}, oldBlocklet);
|
|
197
274
|
newBlocklet.status = (0, _constant.fromBlockletStatus)(data.status);
|
|
198
275
|
(newBlocklet.children || []).forEach(x => {
|
|
199
276
|
const y = data.children.find(z => {
|
|
200
|
-
var _z$meta, _x$
|
|
201
|
-
return ((_z$meta = z.meta) === null || _z$meta === void 0 ? void 0 : _z$meta.did) === ((_x$
|
|
277
|
+
var _z$meta, _x$meta2;
|
|
278
|
+
return ((_z$meta = z.meta) === null || _z$meta === void 0 ? void 0 : _z$meta.did) === ((_x$meta2 = x.meta) === null || _x$meta2 === void 0 ? void 0 : _x$meta2.did);
|
|
202
279
|
});
|
|
203
280
|
if (y) {
|
|
204
281
|
x.status = (0, _constant.fromBlockletStatus)(y.status);
|
|
@@ -208,11 +285,12 @@ function useBlocklet(_ref) {
|
|
|
208
285
|
});
|
|
209
286
|
handleRefreshWithoutRuntime(data);
|
|
210
287
|
}
|
|
211
|
-
}, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$
|
|
212
|
-
useSubscription(_constant.BlockletEvents.storeChange, handleRefreshWithoutRuntime, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$
|
|
213
|
-
useSubscription(_constant.BlockletEvents.installed, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$
|
|
214
|
-
useSubscription(_constant.BlockletEvents.upgraded, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$
|
|
215
|
-
useSubscription(_constant.BlockletEvents.updated, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$
|
|
288
|
+
}, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta3 = blocklet.meta) === null || _blocklet$meta3 === void 0 ? void 0 : _blocklet$meta3.did, !disableSubscription]); // eslint-disable-line prettier/prettier
|
|
289
|
+
useSubscription(_constant.BlockletEvents.storeChange, handleRefreshWithoutRuntime, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta4 = blocklet.meta) === null || _blocklet$meta4 === void 0 ? void 0 : _blocklet$meta4.did, !disableSubscription]);
|
|
290
|
+
useSubscription(_constant.BlockletEvents.installed, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta5 = blocklet.meta) === null || _blocklet$meta5 === void 0 ? void 0 : _blocklet$meta5.did, !disableSubscription]);
|
|
291
|
+
useSubscription(_constant.BlockletEvents.upgraded, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta6 = blocklet.meta) === null || _blocklet$meta6 === void 0 ? void 0 : _blocklet$meta6.did, !disableSubscription]);
|
|
292
|
+
useSubscription(_constant.BlockletEvents.updated, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta7 = blocklet.meta) === null || _blocklet$meta7 === void 0 ? void 0 : _blocklet$meta7.did, !disableSubscription]);
|
|
293
|
+
useSubscription(_constant.BlockletEvents.downloadBundleProgress, handleProgress, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta8 = blocklet.meta) === null || _blocklet$meta8 === void 0 ? void 0 : _blocklet$meta8.did, !disableSubscription]);
|
|
216
294
|
const data = blocklet ? (0, _merge.default)(blocklet, {
|
|
217
295
|
site: {
|
|
218
296
|
domainAliases: blocklet.site.domainAliases.map(x => {
|
package/lib/locales/en.js
CHANGED
package/lib/locales/zh.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// 0~100
|
|
8
|
+
const parseProgress = (current, total) => {
|
|
9
|
+
const totalNumber = typeof total !== 'number' ? Number(total) : total;
|
|
10
|
+
if (Number.isNaN(totalNumber) || totalNumber <= 0) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
const value = Math.floor(current / totalNumber * 100);
|
|
14
|
+
return Math.min(Math.max(value, 0), 100);
|
|
15
|
+
};
|
|
16
|
+
var _default = exports.default = parseProgress;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.21-beta-
|
|
3
|
+
"version": "1.16.21-beta-445a8baa",
|
|
4
4
|
"description": "UX components shared across abtnode packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abtnode/auth": "1.16.21-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.21-beta-
|
|
32
|
-
"@abtnode/util": "1.16.21-beta-
|
|
30
|
+
"@abtnode/auth": "1.16.21-beta-445a8baa",
|
|
31
|
+
"@abtnode/constant": "1.16.21-beta-445a8baa",
|
|
32
|
+
"@abtnode/util": "1.16.21-beta-445a8baa",
|
|
33
33
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
34
34
|
"@arcblock/did": "^1.18.107",
|
|
35
35
|
"@arcblock/did-connect": "^2.8.23",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@arcblock/react-hooks": "^2.8.23",
|
|
40
40
|
"@arcblock/terminal": "^2.8.23",
|
|
41
41
|
"@arcblock/ux": "^2.8.23",
|
|
42
|
-
"@blocklet/constant": "1.16.21-beta-
|
|
42
|
+
"@blocklet/constant": "1.16.21-beta-445a8baa",
|
|
43
43
|
"@blocklet/launcher-layout": "2.2.48",
|
|
44
44
|
"@blocklet/list": "^0.12.60",
|
|
45
|
-
"@blocklet/meta": "1.16.21-beta-
|
|
45
|
+
"@blocklet/meta": "1.16.21-beta-445a8baa",
|
|
46
46
|
"@blocklet/ui-react": "^2.8.23",
|
|
47
47
|
"@blocklet/uploader": "^0.0.56",
|
|
48
48
|
"@emotion/react": "^11.10.4",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"babel-plugin-inline-react-svg": "^1.1.2",
|
|
103
103
|
"glob": "^10.3.3"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "7a7ff8be7f424775c3bde0eead773d8e6177fa1a",
|
|
106
106
|
"exports": {
|
|
107
107
|
".": {
|
|
108
108
|
"import": "./es/index.js",
|