@abtnode/ux 1.16.21-beta-bd0e2503 → 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.
@@ -153,6 +153,7 @@ export default function AddComponentCore({
153
153
  mode,
154
154
  stores,
155
155
  resourceType,
156
+ resourceDid,
156
157
  storageKey,
157
158
  inDialog
158
159
  }) {
@@ -740,6 +741,7 @@ export default function AddComponentCore({
740
741
  },
741
742
  storeUrl: currentRegistry.url,
742
743
  resourceType: resourceType,
744
+ resourceDid: resourceDid,
743
745
  handleButtonClick: chooseParams => {
744
746
  setConfigValue({
745
747
  chooseParams: {
@@ -1114,6 +1116,7 @@ AddComponentCore.propTypes = {
1114
1116
  inDialog: PropTypes.bool,
1115
1117
  stores: PropTypes.arrayOf(PropTypes.string),
1116
1118
  resourceType: PropTypes.string,
1119
+ resourceDid: PropTypes.string,
1117
1120
  storageKey: PropTypes.string
1118
1121
  };
1119
1122
  AddComponentCore.defaultProps = {
@@ -1121,6 +1124,7 @@ AddComponentCore.defaultProps = {
1121
1124
  mode: 'normal',
1122
1125
  stores: [],
1123
1126
  resourceType: '',
1127
+ resourceDid: '',
1124
1128
  storageKey: '',
1125
1129
  inDialog: true
1126
1130
  };
@@ -38,7 +38,6 @@ import Tag from '../../tag';
38
38
  import BlockletSource from '../blocklet-source';
39
39
  import BlockletStatus from '../status';
40
40
  import BlockletVersion from '../version';
41
- import ResourceType from '../resource-type';
42
41
  import Confirm from '../../confirm';
43
42
  import { useNodeContext } from '../../contexts/node';
44
43
  import { formatPerson, formatError, sleep, BlockletAdminRoles, formatToDatetime } from '../../util';
@@ -120,6 +119,7 @@ const getComponentName = (componentId, app) => {
120
119
  }
121
120
  return names.join(' / ');
122
121
  };
122
+ const isPack = component => component?.meta?.group === 'pack';
123
123
  function ComponentItem({
124
124
  blocklet,
125
125
  ancestors,
@@ -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,12 +299,8 @@ function ComponentItem({
298
299
  marginLeft: 4
299
300
  },
300
301
  status: status,
301
- source: blocklet.source
302
- }), !hasStartEngine(blocklet.meta) && /*#__PURE__*/_jsx(ResourceType, {
303
- style: {
304
- marginLeft: 4
305
- },
306
- blocklet: blocklet
302
+ source: blocklet.source,
303
+ progress: blocklet.progress
307
304
  }), /*#__PURE__*/_jsx(BlockletMode, {
308
305
  style: {
309
306
  marginLeft: 4
@@ -399,7 +396,7 @@ function ComponentItem({
399
396
  onClick: () => {
400
397
  setComponentInfo(blocklet);
401
398
  }
402
- } : null, {
399
+ } : null, !isPack(blocklet) && {
403
400
  icon: /*#__PURE__*/_jsx(RestartIcon, {}),
404
401
  text: t('common.restart'),
405
402
  onClick: () => {
@@ -417,7 +414,7 @@ function ComponentItem({
417
414
  });
418
415
  },
419
416
  disabled: appInProgress || componentInProgress || blocklet.status !== 'running'
420
- }, {
417
+ }, !isPack(blocklet) && {
421
418
  icon: /*#__PURE__*/_jsx(ReloadIcon, {}),
422
419
  text: t('common.reload'),
423
420
  onClick: async () => {
@@ -135,6 +135,7 @@ export default function BlockletList({
135
135
  extraFilter,
136
136
  serverVersion,
137
137
  resourceType,
138
+ resourceDid,
138
139
  ...rest
139
140
  }) {
140
141
  const {
@@ -148,13 +149,15 @@ export default function BlockletList({
148
149
  const endpoint = storeUrl;
149
150
  useEffect(() => {
150
151
  setFilters({
151
- resourceType
152
+ resourceType,
153
+ resourceDid
152
154
  });
153
- }, [endpoint, resourceType]);
155
+ }, [endpoint, resourceType, resourceDid]);
154
156
  useEffect(() => {
155
157
  setInitialized(true);
156
158
  setFilters({
157
- resourceType
159
+ resourceType,
160
+ resourceDid
158
161
  });
159
162
  // eslint-disable-next-line react-hooks/exhaustive-deps
160
163
  }, []);
@@ -197,7 +200,8 @@ BlockletList.propTypes = {
197
200
  handleBlockletRender: PropTypes.func,
198
201
  extraFilter: PropTypes.func,
199
202
  serverVersion: PropTypes.string,
200
- resourceType: PropTypes.string
203
+ resourceType: PropTypes.string,
204
+ resourceDid: PropTypes.string
201
205
  };
202
206
  BlockletList.defaultProps = {
203
207
  handleButtonClick: null,
@@ -205,7 +209,8 @@ BlockletList.defaultProps = {
205
209
  handleBlockletRender: null,
206
210
  extraFilter: undefined,
207
211
  serverVersion: '',
208
- resourceType: ''
212
+ resourceType: '',
213
+ resourceDid: ''
209
214
  };
210
215
  const StyledBlocklet = styled(Blocklet)`
211
216
  .ms-highlight {
@@ -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',
@@ -131,7 +131,7 @@ export default function CreateRelease({
131
131
  const releaseId = inputReleaseId === 'create' ? '' : inputReleaseId;
132
132
  const mode = inputReleaseId === 'create' ? 'create' : 'edit';
133
133
  const tabs = [];
134
- const resourceComponents = (blocklet?.children || []).filter(x => x.meta.capabilities.resourceExportApi).filter(x => !componentDid || x.meta.did === componentDid);
134
+ const resourceComponents = (blocklet?.children || []).filter(x => x.meta.resource?.exportApi).filter(x => !componentDid || x.meta.did === componentDid);
135
135
  resourceComponents.forEach(item => {
136
136
  addComponentTabs({
137
137
  tabs,
@@ -45,9 +45,9 @@ export default function Resource({
45
45
  const releaseId = release.id;
46
46
  const readonly = release.status === 'published';
47
47
  const {
48
- resourceExportApi = '/'
49
- } = component?.meta.capabilities || {};
50
- const urlObj = new URL(joinUrl('http://127.0.0.1', component.mountPoint, resourceExportApi || '/').replace(/\/+/g, '/'));
48
+ exportApi = '/'
49
+ } = component?.meta.resource || {};
50
+ const urlObj = new URL(joinUrl('http://127.0.0.1', component.mountPoint, exportApi || '/').replace(/\/+/g, '/'));
51
51
  urlObj.searchParams.set('projectId', projectId);
52
52
  urlObj.searchParams.set('releaseId', releaseId);
53
53
  urlObj.searchParams.set('local', locale);
@@ -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
  };
@@ -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
@@ -509,6 +509,7 @@ export default {
509
509
  added: 'Added',
510
510
  waiting: 'Waiting',
511
511
  downloading: 'Downloading',
512
+ extracting: 'Extracting',
512
513
  installing: 'Installing',
513
514
  upgrading: 'Upgrading',
514
515
  installed: 'Installed',
package/es/locales/zh.js CHANGED
@@ -516,6 +516,7 @@ export default {
516
516
  added: '已添加',
517
517
  waiting: '等待中',
518
518
  downloading: '下载中',
519
+ extracting: '提取中',
519
520
  installing: '安装中',
520
521
  upgrading: '升级中',
521
522
  installed: '已安装',
package/es/util/index.js CHANGED
@@ -14,7 +14,7 @@ import axios from '@abtnode/util/lib/axios';
14
14
  import dayjs from '@abtnode/util/lib/dayjs';
15
15
  import formatError from '@abtnode/util/lib/format-error';
16
16
  import normalizePathPrefix from '@abtnode/util/lib/normalize-path-prefix';
17
- import { evaluateURLs, isDidDomain, isIpEcho, isSlpDomain } from '@abtnode/util/lib/url-evaluation';
17
+ import { evaluateURLs } from '@abtnode/util/lib/url-evaluation';
18
18
  import checkAccessible from '@abtnode/util/lib/url-evaluation/check-accessible-browser';
19
19
  import { BLOCKLET_MODES } from '@blocklet/constant';
20
20
  import urlPathFriendly from '@blocklet/meta/lib/url-path-friendly';
@@ -48,18 +48,12 @@ export function getAccessUrl(hostname, path = '', params = undefined) {
48
48
  if (!hostname) {
49
49
  return '';
50
50
  }
51
- let protocol = 'http';
52
- if (window.location.protocol === 'https:') {
53
- if (isIpEcho(hostname) || isSlpDomain(hostname) || isDidDomain(hostname)) {
54
- protocol = 'https';
55
- }
56
- }
57
51
  let port = '';
58
52
  const browserPort = Number(window.location.port);
59
53
  if (process.env.NODE_ENV !== 'development' && browserPort && ![80, 443].includes(browserPort)) {
60
54
  port = `:${browserPort}`;
61
55
  }
62
- const urlObj = new URL(`${protocol}://${hostname}${port}`);
56
+ const urlObj = new URL(`${window.location.protocol}//${hostname}${port}`);
63
57
  urlObj.pathname = path;
64
58
  const url = urlObj.href.replace(/\/$/, '');
65
59
  if (!params || !Object.keys(params)) {
@@ -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;
@@ -174,6 +174,7 @@ function AddComponentCore(_ref3) {
174
174
  mode,
175
175
  stores,
176
176
  resourceType,
177
+ resourceDid,
177
178
  storageKey,
178
179
  inDialog
179
180
  } = _ref3;
@@ -750,6 +751,7 @@ function AddComponentCore(_ref3) {
750
751
  },
751
752
  storeUrl: currentRegistry.url,
752
753
  resourceType: resourceType,
754
+ resourceDid: resourceDid,
753
755
  handleButtonClick: chooseParams => {
754
756
  setConfigValue({
755
757
  chooseParams: _objectSpread(_objectSpread({}, chooseParams), {}, {
@@ -1121,6 +1123,7 @@ AddComponentCore.propTypes = {
1121
1123
  inDialog: _propTypes.default.bool,
1122
1124
  stores: _propTypes.default.arrayOf(_propTypes.default.string),
1123
1125
  resourceType: _propTypes.default.string,
1126
+ resourceDid: _propTypes.default.string,
1124
1127
  storageKey: _propTypes.default.string
1125
1128
  };
1126
1129
  AddComponentCore.defaultProps = {
@@ -1128,6 +1131,7 @@ AddComponentCore.defaultProps = {
1128
1131
  mode: 'normal',
1129
1132
  stores: [],
1130
1133
  resourceType: '',
1134
+ resourceDid: '',
1131
1135
  storageKey: '',
1132
1136
  inDialog: true
1133
1137
  };
@@ -44,7 +44,6 @@ var _tag = _interopRequireDefault(require("../../tag"));
44
44
  var _blockletSource = _interopRequireDefault(require("../blocklet-source"));
45
45
  var _status = _interopRequireDefault(require("../status"));
46
46
  var _version = _interopRequireDefault(require("../version"));
47
- var _resourceType = _interopRequireDefault(require("../resource-type"));
48
47
  var _confirm = _interopRequireDefault(require("../../confirm"));
49
48
  var _node = require("../../contexts/node");
50
49
  var _util2 = require("../../util");
@@ -138,6 +137,10 @@ const getComponentName = (componentId, app) => {
138
137
  }
139
138
  return names.join(' / ');
140
139
  };
140
+ const isPack = component => {
141
+ var _component$meta;
142
+ return (component === null || component === void 0 ? void 0 : (_component$meta = component.meta) === null || _component$meta === void 0 ? void 0 : _component$meta.group) === 'pack';
143
+ };
141
144
  function ComponentItem(_ref) {
142
145
  var _blocklet$dependents, _blocklet$meta$resour, _blocklet$dependents2, _blocklet$meta, _blocklet$dependents3;
143
146
  let {
@@ -202,7 +205,8 @@ function ComponentItem(_ref) {
202
205
  name: t('common.status'),
203
206
  value: /*#__PURE__*/(0, _jsxRuntime.jsx)(_status.default, {
204
207
  status: status,
205
- source: componentInfo.source
208
+ source: componentInfo.source,
209
+ progress: blocklet.progress
206
210
  })
207
211
  }, blocklet.status === 'running' ? {
208
212
  name: t('blocklet.startedAt'),
@@ -321,12 +325,8 @@ function ComponentItem(_ref) {
321
325
  marginLeft: 4
322
326
  },
323
327
  status: status,
324
- source: blocklet.source
325
- }), !(0, _util.hasStartEngine)(blocklet.meta) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_resourceType.default, {
326
- style: {
327
- marginLeft: 4
328
- },
329
- blocklet: blocklet
328
+ source: blocklet.source,
329
+ progress: blocklet.progress
330
330
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_mode.default, {
331
331
  style: {
332
332
  marginLeft: 4
@@ -425,7 +425,7 @@ function ComponentItem(_ref) {
425
425
  onClick: () => {
426
426
  setComponentInfo(blocklet);
427
427
  }
428
- } : null, {
428
+ } : null, !isPack(blocklet) && {
429
429
  icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Replay.default, {}),
430
430
  text: t('common.restart'),
431
431
  onClick: () => {
@@ -443,7 +443,7 @@ function ComponentItem(_ref) {
443
443
  });
444
444
  },
445
445
  disabled: appInProgress || componentInProgress || blocklet.status !== 'running'
446
- }, {
446
+ }, !isPack(blocklet) && {
447
447
  icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Autorenew.default, {}),
448
448
  text: t('common.reload'),
449
449
  onClick: async () => {
@@ -21,7 +21,7 @@ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
21
21
  var _util2 = require("../../util");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
23
  var _templateObject;
24
- const _excluded = ["handleButtonClick", "handleSearchSelect", "storeUrl", "handleBlockletRender", "extraFilter", "serverVersion", "resourceType"];
24
+ const _excluded = ["handleButtonClick", "handleSearchSelect", "storeUrl", "handleBlockletRender", "extraFilter", "serverVersion", "resourceType", "resourceDid"];
25
25
  /* eslint-disable react/no-unstable-nested-components */
26
26
  /* eslint-disable react/jsx-wrap-multilines */
27
27
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -154,7 +154,8 @@ function BlockletList(_ref3) {
154
154
  handleBlockletRender,
155
155
  extraFilter,
156
156
  serverVersion,
157
- resourceType
157
+ resourceType,
158
+ resourceDid
158
159
  } = _ref3,
159
160
  rest = _objectWithoutProperties(_ref3, _excluded);
160
161
  const {
@@ -168,13 +169,15 @@ function BlockletList(_ref3) {
168
169
  const endpoint = storeUrl;
169
170
  (0, _react.useEffect)(() => {
170
171
  setFilters({
171
- resourceType
172
+ resourceType,
173
+ resourceDid
172
174
  });
173
- }, [endpoint, resourceType]);
175
+ }, [endpoint, resourceType, resourceDid]);
174
176
  (0, _react.useEffect)(() => {
175
177
  setInitialized(true);
176
178
  setFilters({
177
- resourceType
179
+ resourceType,
180
+ resourceDid
178
181
  });
179
182
  // eslint-disable-next-line react-hooks/exhaustive-deps
180
183
  }, []);
@@ -212,7 +215,8 @@ BlockletList.propTypes = {
212
215
  handleBlockletRender: _propTypes.default.func,
213
216
  extraFilter: _propTypes.default.func,
214
217
  serverVersion: _propTypes.default.string,
215
- resourceType: _propTypes.default.string
218
+ resourceType: _propTypes.default.string,
219
+ resourceDid: _propTypes.default.string
216
220
  };
217
221
  BlockletList.defaultProps = {
218
222
  handleButtonClick: null,
@@ -220,6 +224,7 @@ BlockletList.defaultProps = {
220
224
  handleBlockletRender: null,
221
225
  extraFilter: undefined,
222
226
  serverVersion: '',
223
- resourceType: ''
227
+ resourceType: '',
228
+ resourceDid: ''
224
229
  };
225
230
  const StyledBlocklet = (0, _styled.default)(_Blocklet.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ms-highlight {\n color: ", ";\n }\n"])), props => props.theme.palette.primary.main);
@@ -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',
@@ -147,7 +147,10 @@ function CreateRelease(_ref2) {
147
147
  const releaseId = inputReleaseId === 'create' ? '' : inputReleaseId;
148
148
  const mode = inputReleaseId === 'create' ? 'create' : 'edit';
149
149
  const tabs = [];
150
- const resourceComponents = ((blocklet === null || blocklet === void 0 ? void 0 : blocklet.children) || []).filter(x => x.meta.capabilities.resourceExportApi).filter(x => !componentDid || x.meta.did === componentDid);
150
+ const resourceComponents = ((blocklet === null || blocklet === void 0 ? void 0 : blocklet.children) || []).filter(x => {
151
+ var _x$meta$resource;
152
+ return (_x$meta$resource = x.meta.resource) === null || _x$meta$resource === void 0 ? void 0 : _x$meta$resource.exportApi;
153
+ }).filter(x => !componentDid || x.meta.did === componentDid);
151
154
  resourceComponents.forEach(item => {
152
155
  addComponentTabs({
153
156
  tabs,
@@ -54,9 +54,9 @@ function Resource(_ref) {
54
54
  const releaseId = release.id;
55
55
  const readonly = release.status === 'published';
56
56
  const {
57
- resourceExportApi = '/'
58
- } = (component === null || component === void 0 ? void 0 : component.meta.capabilities) || {};
59
- const urlObj = new URL((0, _urlJoin.default)('http://127.0.0.1', component.mountPoint, resourceExportApi || '/').replace(/\/+/g, '/'));
57
+ exportApi = '/'
58
+ } = (component === null || component === void 0 ? void 0 : component.meta.resource) || {};
59
+ const urlObj = new URL((0, _urlJoin.default)('http://127.0.0.1', component.mountPoint, exportApi || '/').replace(/\/+/g, '/'));
60
60
  urlObj.searchParams.set('projectId', projectId);
61
61
  urlObj.searchParams.set('releaseId', releaseId);
62
62
  urlObj.searchParams.set('local', locale);
@@ -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
  };
@@ -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$meta, _blocklet$meta2, _blocklet$meta3, _blocklet$meta4, _blocklet$meta5, _blocklet$meta6;
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$meta = blocklet.meta) === null || _blocklet$meta === void 0 ? void 0 : _blocklet$meta.did, !disableSubscription]);
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$meta3;
194
- if ((data === null || data === void 0 ? void 0 : (_data$meta3 = data.meta) === null || _data$meta3 === void 0 ? void 0 : _data$meta3.did) === blocklet.meta.did) {
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$meta;
201
- return ((_z$meta = z.meta) === null || _z$meta === void 0 ? void 0 : _z$meta.did) === ((_x$meta = x.meta) === null || _x$meta === void 0 ? void 0 : _x$meta.did);
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$meta2 = blocklet.meta) === null || _blocklet$meta2 === void 0 ? void 0 : _blocklet$meta2.did, !disableSubscription]); // eslint-disable-line prettier/prettier
212
- useSubscription(_constant.BlockletEvents.storeChange, handleRefreshWithoutRuntime, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta3 = blocklet.meta) === null || _blocklet$meta3 === void 0 ? void 0 : _blocklet$meta3.did, !disableSubscription]);
213
- useSubscription(_constant.BlockletEvents.installed, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta4 = blocklet.meta) === null || _blocklet$meta4 === void 0 ? void 0 : _blocklet$meta4.did, !disableSubscription]);
214
- useSubscription(_constant.BlockletEvents.upgraded, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta5 = blocklet.meta) === null || _blocklet$meta5 === void 0 ? void 0 : _blocklet$meta5.did, !disableSubscription]);
215
- useSubscription(_constant.BlockletEvents.updated, handleRefresh, [blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$meta6 = blocklet.meta) === null || _blocklet$meta6 === void 0 ? void 0 : _blocklet$meta6.did, !disableSubscription]);
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
@@ -515,6 +515,7 @@ var _default = exports.default = {
515
515
  added: 'Added',
516
516
  waiting: 'Waiting',
517
517
  downloading: 'Downloading',
518
+ extracting: 'Extracting',
518
519
  installing: 'Installing',
519
520
  upgrading: 'Upgrading',
520
521
  installed: 'Installed',
package/lib/locales/zh.js CHANGED
@@ -522,6 +522,7 @@ var _default = exports.default = {
522
522
  added: '已添加',
523
523
  waiting: '等待中',
524
524
  downloading: '下载中',
525
+ extracting: '提取中',
525
526
  installing: '安装中',
526
527
  upgrading: '升级中',
527
528
  installed: '已安装',
package/lib/util/index.js CHANGED
@@ -95,18 +95,12 @@ function getAccessUrl(hostname) {
95
95
  if (!hostname) {
96
96
  return '';
97
97
  }
98
- let protocol = 'http';
99
- if (window.location.protocol === 'https:') {
100
- if ((0, _urlEvaluation.isIpEcho)(hostname) || (0, _urlEvaluation.isSlpDomain)(hostname) || (0, _urlEvaluation.isDidDomain)(hostname)) {
101
- protocol = 'https';
102
- }
103
- }
104
98
  let port = '';
105
99
  const browserPort = Number(window.location.port);
106
100
  if (process.env.NODE_ENV !== 'development' && browserPort && ![80, 443].includes(browserPort)) {
107
101
  port = ":".concat(browserPort);
108
102
  }
109
- const urlObj = new URL("".concat(protocol, "://").concat(hostname).concat(port));
103
+ const urlObj = new URL("".concat(window.location.protocol, "//").concat(hostname).concat(port));
110
104
  urlObj.pathname = path;
111
105
  const url = urlObj.href.replace(/\/$/, '');
112
106
  if (!params || !Object.keys(params)) {
@@ -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-bd0e2503",
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-bd0e2503",
31
- "@abtnode/constant": "1.16.21-beta-bd0e2503",
32
- "@abtnode/util": "1.16.21-beta-bd0e2503",
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-bd0e2503",
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-bd0e2503",
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": "f4550e061b661cb67d7f1413ada51f3f6491f0b8",
105
+ "gitHead": "7a7ff8be7f424775c3bde0eead773d8e6177fa1a",
106
106
  "exports": {
107
107
  ".": {
108
108
  "import": "./es/index.js",