@abtnode/ux 1.16.23-beta-c9c4e08e → 1.16.23-beta-ed83c878

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.
Files changed (47) hide show
  1. package/es/blocklet/agreement.js +23 -4
  2. package/es/blocklet/component/related-components-dialog.js +11 -9
  3. package/es/blocklet/publish/create-release.js +47 -4
  4. package/es/blocklet/publish/select-components.js +181 -0
  5. package/es/hooks/blocklet.js +29 -19
  6. package/es/hooks/use-components-by-blocklet-meta-url.js +1 -1
  7. package/es/locales/ar.js +24 -2
  8. package/es/locales/de.js +24 -2
  9. package/es/locales/en.js +15 -2
  10. package/es/locales/es.js +24 -2
  11. package/es/locales/fr.js +24 -2
  12. package/es/locales/hi.js +24 -2
  13. package/es/locales/i18n.db +0 -0
  14. package/es/locales/id.js +24 -2
  15. package/es/locales/ja.js +24 -2
  16. package/es/locales/ko.js +24 -2
  17. package/es/locales/pt.js +24 -2
  18. package/es/locales/ru.js +24 -2
  19. package/es/locales/th.js +24 -2
  20. package/es/locales/vi.js +24 -2
  21. package/es/locales/zh-tw.js +24 -2
  22. package/es/locales/zh.js +17 -2
  23. package/es/util/storage-ttl.js +78 -0
  24. package/lib/blocklet/agreement.js +23 -4
  25. package/lib/blocklet/component/related-components-dialog.js +13 -9
  26. package/lib/blocklet/publish/create-release.js +47 -5
  27. package/lib/blocklet/publish/select-components.js +175 -0
  28. package/lib/hooks/blocklet.js +37 -24
  29. package/lib/hooks/use-components-by-blocklet-meta-url.js +1 -1
  30. package/lib/locales/ar.js +24 -2
  31. package/lib/locales/de.js +24 -2
  32. package/lib/locales/en.js +15 -2
  33. package/lib/locales/es.js +24 -2
  34. package/lib/locales/fr.js +24 -2
  35. package/lib/locales/hi.js +24 -2
  36. package/lib/locales/i18n.db +0 -0
  37. package/lib/locales/id.js +24 -2
  38. package/lib/locales/ja.js +24 -2
  39. package/lib/locales/ko.js +24 -2
  40. package/lib/locales/pt.js +24 -2
  41. package/lib/locales/ru.js +24 -2
  42. package/lib/locales/th.js +24 -2
  43. package/lib/locales/vi.js +24 -2
  44. package/lib/locales/zh-tw.js +24 -2
  45. package/lib/locales/zh.js +17 -2
  46. package/lib/util/storage-ttl.js +89 -0
  47. package/package.json +15 -15
@@ -10,24 +10,25 @@ var _context = require("@arcblock/ux/lib/Locale/context");
10
10
  var _material = require("@mui/material");
11
11
  var _react = require("@iconify/react");
12
12
  var _react2 = require("react");
13
- var _useComponentsByBlockletMetaUrl = _interopRequireDefault(require("../../hooks/use-components-by-blocklet-meta-url"));
14
13
  var _jsxRuntime = require("react/jsx-runtime");
15
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function parseLogoUrl(component) {
16
+ var _component$bundleSour, _component$meta, _component$meta2, _component$meta3;
17
+ return "".concat(((_component$bundleSour = component.bundleSource) === null || _component$bundleSour === void 0 ? void 0 : _component$bundleSour.store) || component.meta.homepage, "/assets/").concat((_component$meta = component.meta) === null || _component$meta === void 0 ? void 0 : _component$meta.did, "/").concat(((_component$meta2 = component.meta) === null || _component$meta2 === void 0 ? void 0 : _component$meta2.logo) || 'logo.png', "?v=").concat((_component$meta3 = component.meta) === null || _component$meta3 === void 0 ? void 0 : _component$meta3.version);
18
+ }
16
19
  function RelatedComponentsDialog(_ref) {
17
20
  let {
18
21
  installRelated,
19
22
  meta,
20
23
  show,
21
- onClose: _onClose
24
+ onClose: _onClose,
25
+ components,
26
+ loading
22
27
  } = _ref;
23
28
  const {
24
29
  t
25
30
  } = (0, _context.useLocaleContext)();
26
31
  const isMobile = (0, _material.useMediaQuery)(theme => theme.breakpoints.down('md'));
27
- const {
28
- components,
29
- loading
30
- } = (0, _useComponentsByBlockletMetaUrl.default)(meta);
31
32
  const requiredList = (0, _react2.useMemo)(() => {
32
33
  if (!meta || !meta.components) {
33
34
  return {};
@@ -126,7 +127,7 @@ function RelatedComponentsDialog(_ref) {
126
127
  minWidth: size,
127
128
  minHeight: size
128
129
  },
129
- src: "".concat(component.meta.homepage, "/assets/").concat(meta.did, "/logo.png?v=").concat(meta.version),
130
+ src: parseLogoUrl(component),
130
131
  alt: component.meta.title
131
132
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
132
133
  sx: {
@@ -149,7 +150,8 @@ function RelatedComponentsDialog(_ref) {
149
150
  }
150
151
  },
151
152
  onClick: () => {
152
- window.open("".concat(component.meta.homepage, "/blocklets/").concat(component.meta.did), '_blank');
153
+ var _component$bundleSour2;
154
+ window.open("".concat(((_component$bundleSour2 = component.bundleSource) === null || _component$bundleSour2 === void 0 ? void 0 : _component$bundleSour2.store) || component.meta.homepage, "/blocklets/").concat(component.meta.did), '_blank');
153
155
  },
154
156
  children: [component.meta.title, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
155
157
  sx: {
@@ -187,7 +189,9 @@ RelatedComponentsDialog.propTypes = {
187
189
  meta: _propTypes.default.object,
188
190
  show: _propTypes.default.bool,
189
191
  onClose: _propTypes.default.func.isRequired,
190
- installRelated: _propTypes.default.func
192
+ installRelated: _propTypes.default.func,
193
+ components: _propTypes.default.array.isRequired,
194
+ loading: _propTypes.default.bool.isRequired
191
195
  };
192
196
  RelatedComponentsDialog.defaultProps = {
193
197
  meta: null,
@@ -36,16 +36,17 @@ var _emptySpinner = _interopRequireDefault(require("../../empty-spinner"));
36
36
  var _clickToCopy = _interopRequireDefault(require("../../click-to-copy"));
37
37
  var _util = require("../../util");
38
38
  var _resource = _interopRequireDefault(require("./resource"));
39
+ var _selectComponents = _interopRequireDefault(require("./select-components"));
39
40
  var _jsxRuntime = require("react/jsx-runtime");
40
41
  var _window$env, _templateObject;
41
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42
43
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
44
+ function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
43
45
  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; }
44
46
  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; }
45
47
  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; }
46
48
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
47
49
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
48
- function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
49
50
  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); }
50
51
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
51
52
  const allowedFileTypes = ['image/*', '.jpg', '.jpeg', '.png', '.gif', '.svg'];
@@ -119,9 +120,20 @@ const addComponentTabs = _ref => {
119
120
  value: key
120
121
  });
121
122
  };
122
- const pickParams = release => {
123
- const params = (0, _pick.default)(release, ['blockletVersion', 'blockletTitle', 'blockletDescription', 'blockletLogo', 'blockletIntroduction', 'blockletScreenshots', 'note']);
123
+ const pickParams = (release, app) => {
124
+ const params = (0, _pick.default)(release, ['blockletVersion', 'blockletTitle', 'blockletDescription', 'blockletLogo', 'blockletIntroduction', 'blockletScreenshots', 'blockletComponents', 'note']);
124
125
  params.blockletScreenshots || (params.blockletScreenshots = []);
126
+ if (!params.blockletComponents) {
127
+ params.blockletComponents = (app.children || []).map(x => ({
128
+ did: x.meta.did,
129
+ included: true,
130
+ required: true
131
+ }));
132
+ } else {
133
+ params.blockletComponents = params.blockletComponents.map(x => _objectSpread(_objectSpread({}, x), {}, {
134
+ included: true
135
+ }));
136
+ }
125
137
  return params;
126
138
  };
127
139
  function CreateRelease(_ref2) {
@@ -190,7 +202,7 @@ function CreateRelease(_ref2) {
190
202
  } else if (_semver.default.valid(data.blockletVersion)) {
191
203
  data.blockletVersion = _semver.default.inc(data.blockletVersion, 'patch');
192
204
  }
193
- setParams(pickParams(data));
205
+ setParams(pickParams(data, blocklet));
194
206
  setProjectType(data.type);
195
207
  }).catch(err => {
196
208
  setLoading(false);
@@ -206,7 +218,7 @@ function CreateRelease(_ref2) {
206
218
  }
207
219
  }).then(res => {
208
220
  setLoading(false);
209
- setParams(pickParams(res === null || res === void 0 ? void 0 : res.release));
221
+ setParams(pickParams(res === null || res === void 0 ? void 0 : res.release, blocklet));
210
222
  setRelease(res === null || res === void 0 ? void 0 : res.release);
211
223
  }).catch(err => {
212
224
  setLoading(false);
@@ -254,6 +266,11 @@ function CreateRelease(_ref2) {
254
266
  _params.blockletDescription = (_params.blockletDescription || '').trim();
255
267
  _params.blockletIntroduction = (_params.blockletIntroduction || '').trim();
256
268
  _params.note = (_params.note || '').trim();
269
+ if (projectType === 'pack') {
270
+ _params.blockletComponents = (_params.blockletComponents || []).filter(x => x.included).map(x => (0, _pick.default)(x, ['did', 'required'])).map(JSON.stringify);
271
+ } else {
272
+ delete _params.blockletComponents;
273
+ }
257
274
  setCreateLoading(status);
258
275
  setLoading(true);
259
276
  api.createRelease({
@@ -778,6 +795,31 @@ function CreateRelease(_ref2) {
778
795
  children: resourceContent
779
796
  })]
780
797
  })]
798
+ }), projectType === 'pack' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
799
+ display: "flex",
800
+ mt: 3,
801
+ className: "section full-width",
802
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
803
+ className: "left",
804
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
805
+ variant: "h3",
806
+ children: t('common.components')
807
+ })
808
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
809
+ sx: {
810
+ flex: 1
811
+ },
812
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_selectComponents.default, {
813
+ disabled: loading || readOnly,
814
+ app: blocklet,
815
+ value: params.blockletComponents,
816
+ onChange: data => {
817
+ setParams({
818
+ blockletComponents: data
819
+ });
820
+ }
821
+ })
822
+ })]
781
823
  })]
782
824
  })]
783
825
  }));
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = SelectComponents;
7
+ var _react = require("react");
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _pick = _interopRequireDefault(require("lodash/pick"));
12
+ var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
13
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
14
+ var _Datatable = _interopRequireDefault(require("@arcblock/ux/lib/Datatable"));
15
+ var _context = require("@arcblock/ux/lib/Locale/context");
16
+ var _bundleAvatar = _interopRequireDefault(require("../bundle-avatar"));
17
+ var _jsxRuntime = require("react/jsx-runtime");
18
+ var _templateObject;
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
21
+ 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; }
22
+ 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; }
23
+ 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; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
25
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
26
+ function SelectComponents(_ref) {
27
+ let {
28
+ value,
29
+ app,
30
+ onChange,
31
+ disabled
32
+ } = _ref;
33
+ const {
34
+ t,
35
+ locale
36
+ } = (0, _context.useLocaleContext)();
37
+ const components = app.children || [];
38
+ const list = (0, _react.useMemo)(() => app.children.map(component => {
39
+ const exist = value.find(item => item.did === component.meta.did);
40
+ return exist || {
41
+ did: component.meta.did
42
+ };
43
+ }), [app, value]);
44
+ const map = list.reduce((acc, curr) => {
45
+ acc[curr.did] = (0, _pick.default)(curr, ['required', 'included']);
46
+ return acc;
47
+ }, {});
48
+ const toggleIncluded = did => {
49
+ const newValue = list.map(item => {
50
+ if (item.did === did) {
51
+ const included = !item.included;
52
+ return _objectSpread(_objectSpread({}, item), {}, {
53
+ included,
54
+ required: included
55
+ });
56
+ }
57
+ return item;
58
+ });
59
+ onChange(newValue);
60
+ };
61
+ const toggleRequired = did => {
62
+ const newValue = list.map(item => {
63
+ if (item.did === did) {
64
+ return _objectSpread(_objectSpread({}, item), {}, {
65
+ required: !item.required
66
+ });
67
+ }
68
+ return item;
69
+ });
70
+ onChange(newValue);
71
+ };
72
+ const columns = [{
73
+ label: t('common.name'),
74
+ name: 'meta.title',
75
+ width: 200,
76
+ options: {
77
+ // eslint-disable-next-line react/no-unstable-nested-components
78
+ customBodyRenderLite: rawIndex => {
79
+ var _map$component$meta$d;
80
+ const component = components[rawIndex];
81
+ const included = (_map$component$meta$d = map[component.meta.did]) === null || _map$component$meta$d === void 0 ? void 0 : _map$component$meta$d.included;
82
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
83
+ display: "flex",
84
+ alignItems: "center",
85
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_bundleAvatar.default, {
86
+ size: 24,
87
+ blocklet: component,
88
+ ancestors: [app]
89
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
90
+ ml: "4px",
91
+ className: (0, _classnames.default)('text', {
92
+ excluded: !included
93
+ }),
94
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
95
+ children: component.meta.title
96
+ })
97
+ })]
98
+ });
99
+ }
100
+ }
101
+ }, {
102
+ label: t('blocklet.publish.componentIncluded'),
103
+ width: 100,
104
+ options: {
105
+ // eslint-disable-next-line react/no-unstable-nested-components
106
+ customBodyRenderLite: rawIndex => {
107
+ var _map$component$meta$d2;
108
+ const component = components[rawIndex];
109
+ const included = (_map$component$meta$d2 = map[component.meta.did]) === null || _map$component$meta$d2 === void 0 ? void 0 : _map$component$meta$d2.included;
110
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.default, {
111
+ size: "small",
112
+ checked: included,
113
+ onClick: () => toggleIncluded(component.meta.did),
114
+ disabled: disabled
115
+ });
116
+ }
117
+ }
118
+ }, {
119
+ label: t('blocklet.publish.componentForceRequired'),
120
+ width: 100,
121
+ options: {
122
+ // eslint-disable-next-line react/no-unstable-nested-components
123
+ customBodyRenderLite: rawIndex => {
124
+ var _map$component$meta$d3, _map$component$meta$d4;
125
+ const component = components[rawIndex];
126
+ const included = (_map$component$meta$d3 = map[component.meta.did]) === null || _map$component$meta$d3 === void 0 ? void 0 : _map$component$meta$d3.included;
127
+ const required = (_map$component$meta$d4 = map[component.meta.did]) === null || _map$component$meta$d4 === void 0 ? void 0 : _map$component$meta$d4.required;
128
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.default, {
129
+ disabled: disabled || !included,
130
+ size: "small",
131
+ checked: required && included,
132
+ onClick: () => toggleRequired(component.meta.did)
133
+ });
134
+ }
135
+ }
136
+ }];
137
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
138
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Datatable.default, {
139
+ className: "main-table",
140
+ verticalKeyWidth: 100,
141
+ locale: locale,
142
+ data: components,
143
+ columns: columns,
144
+ options: {
145
+ sort: false,
146
+ download: false,
147
+ filter: false,
148
+ print: false,
149
+ search: false,
150
+ rowsPerPage: 100
151
+ }
152
+ })
153
+ });
154
+ }
155
+ SelectComponents.propTypes = {
156
+ app: _propTypes.default.object.isRequired,
157
+ value: _propTypes.default.arrayOf(_propTypes.default.shape({
158
+ did: _propTypes.default.string.isRequired,
159
+ required: _propTypes.default.bool,
160
+ included: _propTypes.default.bool
161
+ })),
162
+ onChange: _propTypes.default.func,
163
+ disabled: _propTypes.default.bool
164
+ };
165
+ SelectComponents.defaultProps = {
166
+ value: [],
167
+ onChange: () => {},
168
+ disabled: false
169
+ };
170
+ const Root = (0, _styled.default)(_Box.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .main-table {\n .text.excluded {\n color: #999;\n }\n width: 400px;\n ", " {\n width: 100%;\n }\n > div:first-child {\n display: none;\n }\n .MuiTableCell-head {\n padding-top: 0;\n padding-bottom: 0;\n }\n .MuiTableCell-body {\n padding-top: 6px;\n padding-bottom: 6px;\n }\n .datatable-footer {\n display: none;\n }\n }\n"])), _ref2 => {
171
+ let {
172
+ theme
173
+ } = _ref2;
174
+ return theme.breakpoints.down('md');
175
+ });
@@ -13,15 +13,15 @@ var _util = require("../util");
13
13
  var _util2 = require("../blocklet/util");
14
14
  var _urlEvaluation = require("./url-evaluation");
15
15
  var _parseProgress = _interopRequireDefault(require("../util/parse-progress"));
16
+ var _storageTtl = require("../util/storage-ttl");
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
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; }
18
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; }
19
20
  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; }
20
21
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
21
22
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
+ const parseStatusKey = id => "blocklet-status-".concat(id);
22
24
  const excludeDownloadingStatus = {
23
- waiting: 1,
24
- installing: 1,
25
25
  installed: 1,
26
26
  starting: 1,
27
27
  running: 1,
@@ -30,6 +30,28 @@ const excludeDownloadingStatus = {
30
30
  restarting: 1,
31
31
  deleting: 1
32
32
  };
33
+ function rollbackSessionBlockletStatus(blocklet) {
34
+ if (blocklet) {
35
+ const children = blocklet.children || [];
36
+ let isExtracting = false;
37
+ children.forEach(item => {
38
+ if (item.status === 'downloading') {
39
+ var _item$meta;
40
+ const status = (0, _storageTtl.getStorageWithTTL)(parseStatusKey((_item$meta = item.meta) === null || _item$meta === void 0 ? void 0 : _item$meta.bundleDid));
41
+ item.status = status || item.status;
42
+ if (status === 'extracting') {
43
+ isExtracting = true;
44
+ }
45
+ } else if (excludeDownloadingStatus[blocklet.status]) {
46
+ var _item$meta2;
47
+ (0, _storageTtl.removeStorageTTL)(parseStatusKey((_item$meta2 = item.meta) === null || _item$meta2 === void 0 ? void 0 : _item$meta2.bundleDid));
48
+ }
49
+ });
50
+ if (isExtracting) {
51
+ blocklet.status = 'extracting';
52
+ }
53
+ }
54
+ }
33
55
 
34
56
  // eslint-disable-next-line import/prefer-default-export
35
57
  function useBlocklet(_ref) {
@@ -79,6 +101,7 @@ function useBlocklet(_ref) {
79
101
  await (0, _util2.fixBlocklet)(data, {
80
102
  getIP
81
103
  });
104
+ rollbackSessionBlockletStatus(data);
82
105
  setBlocklet(data);
83
106
  } catch (err) {
84
107
  _Toast.default.error(err.message);
@@ -134,13 +157,7 @@ function useBlocklet(_ref) {
134
157
  fixRuntime: 'merge-old',
135
158
  oldBlocklet
136
159
  });
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
- }
160
+ rollbackSessionBlockletStatus(data);
144
161
  return data;
145
162
  });
146
163
  setLoading(false);
@@ -190,20 +207,14 @@ function useBlocklet(_ref) {
190
207
  children.forEach(x => {
191
208
  var _x$meta, _data$component;
192
209
  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)) {
210
+ var _x$meta2;
211
+ (0, _storageTtl.setStorageWithTTL)(parseStatusKey((_x$meta2 = x.meta) === null || _x$meta2 === void 0 ? void 0 : _x$meta2.bundleDid), data.status, 1000 * 60 * 5);
193
212
  x.status = data.status;
194
213
  }
195
214
  });
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
215
  return _objectSpread(_objectSpread({}, oldBlocklet), {}, {
205
216
  children,
206
- status: extracting ? 'extracting' : oldBlocklet.status
217
+ status: data.status
207
218
  });
208
219
  });
209
220
  }
@@ -215,15 +226,17 @@ function useBlocklet(_ref) {
215
226
 
216
227
  // keep largest files as progress
217
228
  const children = oldBlocklet.children || [];
218
- let progress = 100;
229
+ let progress = oldBlocklet.progress || 0;
219
230
  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)) {
231
+ var _item$meta3, _data$component2;
232
+ if (((_item$meta3 = item.meta) === null || _item$meta3 === void 0 ? void 0 : _item$meta3.bundleDid) === ((_data$component2 = data.component) === null || _data$component2 === void 0 ? void 0 : _data$component2.did)) {
233
+ var _item$meta4;
222
234
  item.progress = (0, _parseProgress.default)(data.current, data.total);
223
235
  item.status = data.status;
224
- if (item.progress < progress) {
236
+ if (item.progress > progress) {
225
237
  progress = item.progress;
226
238
  }
239
+ (0, _storageTtl.removeStorageTTL)(parseStatusKey((_item$meta4 = item.meta) === null || _item$meta4 === void 0 ? void 0 : _item$meta4.bundleDid));
227
240
  }
228
241
  });
229
242
  return _objectSpread(_objectSpread({}, oldBlocklet), {}, {
@@ -274,8 +287,8 @@ function useBlocklet(_ref) {
274
287
  newBlocklet.status = (0, _constant.fromBlockletStatus)(data.status);
275
288
  (newBlocklet.children || []).forEach(x => {
276
289
  const y = data.children.find(z => {
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);
290
+ var _z$meta, _x$meta3;
291
+ return ((_z$meta = z.meta) === null || _z$meta === void 0 ? void 0 : _z$meta.did) === ((_x$meta3 = x.meta) === null || _x$meta3 === void 0 ? void 0 : _x$meta3.did);
279
292
  });
280
293
  if (y) {
281
294
  x.status = (0, _constant.fromBlockletStatus)(y.status);
@@ -8,7 +8,7 @@ var _react = require("react");
8
8
  var _reactRouterDom = require("react-router-dom");
9
9
  var _node = require("../contexts/node");
10
10
  function parseBlockletMetaUrl(meta) {
11
- return meta && meta.homepage && meta.did ? "".concat(meta === null || meta === void 0 ? void 0 : meta.homepage, "/api/blocklets/").concat(meta === null || meta === void 0 ? void 0 : meta.did, "/blocklet.json") : '';
11
+ return meta && (meta.registryUrl || meta.homepage) && meta.did ? "".concat(meta.registryUrl || meta.homepage, "/api/blocklets/").concat(meta === null || meta === void 0 ? void 0 : meta.did, "/blocklet.json") : '';
12
12
  }
13
13
  function useComponentsByBlockletMetaUrl(meta) {
14
14
  const {
package/lib/locales/ar.js CHANGED
@@ -52,6 +52,24 @@ var _default = exports.default = {
52
52
  scan: 'قم بتوصيل محفظة DID الخاصة بك لتوفير جواز السفر',
53
53
  confirm: 'أكد على محفظة الهوية الرقمية الخاصة بك',
54
54
  success: 'تم اتصالك بنجاح'
55
+ },
56
+ switchDid: {
57
+ title: 'تبديل محفظة DID',
58
+ scan: 'مسح رمز الاستجابة السريعة التالي لتبديل الحساب',
59
+ confirm: 'قم بتأكيد التبديل في محفظة ديد الخاصة بك',
60
+ success: 'تم التحويل بنجاح'
61
+ },
62
+ switchSpecifiedDid: {
63
+ title: 'تبديل محفظة DID',
64
+ scan: 'تحتاج إلى تبديل DID إلى {did} لإكمال الإجراءات التالية',
65
+ confirm: 'قم بتأكيد التبديل في محفظة ديد الخاصة بك',
66
+ success: 'تم التبديل بنجاح'
67
+ },
68
+ connect: {
69
+ title: 'قم بتوصيل محفظة DID',
70
+ scan: 'قم بتوصيل محفظة DID الخاصة بك لتوفير جواز السفر',
71
+ confirm: 'قم بتأكيد على محفظتك الرقمية',
72
+ success: 'لقد تم توصيلك بنجاح'
55
73
  }
56
74
  },
57
75
  acceptServer: {
@@ -585,7 +603,8 @@ var _default = exports.default = {
585
603
  setting: 'الإعدادات',
586
604
  components: 'تبعيات المكوّن {name}',
587
605
  noDependencies: 'لا يوجد لدى {name} أي تبعيات',
588
- relatedComponents: 'المكونات ذات الصلة'
606
+ relatedComponents: 'المكونات ذات الصلة',
607
+ required: 'مطلوب'
589
608
  },
590
609
  router: {
591
610
  urlPath: 'مسار عنوان URL',
@@ -668,7 +687,10 @@ var _default = exports.default = {
668
687
  noNote: 'ملاحظة الإصدار مطلوبة'
669
688
  },
670
689
  packTip: 'سيتم تضمين مكونات وتكوين التطبيق تلقائيًا في البلوكليت.',
671
- resourceChangedWarning: 'لقد قمت بتعديل المورد، يرجى حفظه في الوقت المناسب'
690
+ resourceChangedWarning: 'لقد قمت بتعديل المورد، يرجى حفظه في الوقت المناسب',
691
+ installResourceTip: 'يرجى إضافة المكون في التطبيق، عنوان URL للمكون:',
692
+ installResourceTip2: 'إذا كنت ترغب في رؤية المزيد من النصائح، يرجى زيارة',
693
+ installResourceHelp: 'وثيقة المساعدة'
672
694
  }
673
695
  },
674
696
  dashboard: {
package/lib/locales/de.js CHANGED
@@ -52,6 +52,24 @@ var _default = exports.default = {
52
52
  scan: 'Verbinden Sie Ihre DID-Brieftasche, um Ihren Reisepass bereitzustellen',
53
53
  confirm: 'Bestätigen Sie in Ihrer DID-Brieftasche',
54
54
  success: 'Du bist erfolgreich verbunden'
55
+ },
56
+ switchDid: {
57
+ title: 'Schalte DID Wallet um',
58
+ scan: 'Scannen Sie den folgenden QR-Code, um das Konto zu wechseln',
59
+ confirm: 'Bestätigen Sie den Wechsel in Ihrem DID-Wallet',
60
+ success: 'Erfolgreich umgeschaltet'
61
+ },
62
+ switchSpecifiedDid: {
63
+ title: 'Wechsle auf DID Wallet',
64
+ scan: 'Du musst DID auf {did} umschalten, um die folgenden Aktionen abzuschließen',
65
+ confirm: 'Bestätige den Wechsel in deiner DID-Brieftasche',
66
+ success: 'Erfolgreich gewechselt'
67
+ },
68
+ connect: {
69
+ title: 'Verbinden Sie das DID-Wallet',
70
+ scan: 'Verbinden Sie Ihre DID Wallet, um einen Pass zu hinterlegen',
71
+ confirm: 'Bestätige in deinem DID Wallet',
72
+ success: 'Du bist erfolgreich verbunden'
55
73
  }
56
74
  },
57
75
  acceptServer: {
@@ -585,7 +603,8 @@ var _default = exports.default = {
585
603
  setting: 'Einstellungen',
586
604
  components: 'Abhängigkeiten von Komponente {name}',
587
605
  noDependencies: '{name} hat keine Abhängigkeiten',
588
- relatedComponents: 'Verbundene Komponenten'
606
+ relatedComponents: 'Verbundene Komponenten',
607
+ required: 'Erforderlich'
589
608
  },
590
609
  router: {
591
610
  urlPath: 'URL Pfad',
@@ -668,7 +687,10 @@ var _default = exports.default = {
668
687
  noNote: 'Versionshinweis wird benötigt'
669
688
  },
670
689
  packTip: 'Komponenten und Anwendungskonfiguration werden automatisch in das Blocklet einbezogen.',
671
- resourceChangedWarning: 'Sie haben die Ressource geändert, bitte rechtzeitig speichern'
690
+ resourceChangedWarning: 'Sie haben die Ressource geändert, bitte rechtzeitig speichern',
691
+ installResourceTip: 'Bitte fügen Sie das Bauteil in einer Anwendung hinzu, Bauteil-URL:',
692
+ installResourceTip2: 'Wenn du mehr Tipps sehen möchtest, besuche bitte',
693
+ installResourceHelp: 'Hilfe-Dokument'
672
694
  }
673
695
  },
674
696
  dashboard: {
package/lib/locales/en.js CHANGED
@@ -47,7 +47,19 @@ var _default = exports.default = {
47
47
  login: {
48
48
  loginTo: 'Connect to',
49
49
  description: 'Only server owner and approved members can access the dashboard',
50
- dialog: {
50
+ switchDid: {
51
+ title: 'Switch DID Wallet',
52
+ scan: 'Scan following qrcode to switch account',
53
+ confirm: 'Confirm switch in your DID Wallet',
54
+ success: 'Successfully switched'
55
+ },
56
+ switchSpecifiedDid: {
57
+ title: 'Switch DID Wallet',
58
+ scan: 'You need switch DID to {did} to complete the following actions',
59
+ confirm: 'Confirm switch in your DID Wallet',
60
+ success: 'Successfully switched'
61
+ },
62
+ connect: {
51
63
  title: 'Connect DID Wallet',
52
64
  scan: 'Connect your DID Wallet to provide passport',
53
65
  confirm: 'Confirm on your DID Wallet',
@@ -656,8 +668,9 @@ var _default = exports.default = {
656
668
  resourceChangedWarning: 'You have modified the resource, please save it in time',
657
669
  installResourceTip: 'Please add the component in an application, component URL:',
658
670
  installResourceTip2: 'If you want to see more tips, please visit',
659
- // translate to en
660
671
  installResourceHelp: 'Help Document',
672
+ componentIncluded: 'Included',
673
+ componentForceRequired: 'Forced Required',
661
674
  connect: {
662
675
  title: 'Create Blocklet DID',
663
676
  scan: 'Scan the QR code below to generate Blocklet DID',
package/lib/locales/es.js CHANGED
@@ -52,6 +52,24 @@ var _default = exports.default = {
52
52
  scan: 'Conecta tu billetera DID para proporcionar el pasaporte',
53
53
  confirm: 'Confirma en tu billetera DID',
54
54
  success: 'Estás conectado con éxito'
55
+ },
56
+ switchDid: {
57
+ title: 'Cambiar billetera DID',
58
+ scan: 'Escanea el siguiente código QR para cambiar de cuenta',
59
+ confirm: 'Confirma el cambio en tu billetera DID',
60
+ success: 'Cambiado exitosamente'
61
+ },
62
+ switchSpecifiedDid: {
63
+ title: 'Cambiar billetera DID',
64
+ scan: 'Necesitas cambiar el DID a {did} para completar las siguientes acciones',
65
+ confirm: 'Confirma el cambio en tu billetera de DID',
66
+ success: 'Cambiado con éxito'
67
+ },
68
+ connect: {
69
+ title: 'Conectar billetera DID',
70
+ scan: 'Conecta tu billetera DID para proporcionar pasaporte',
71
+ confirm: 'Confirma en tu billetera DID',
72
+ success: 'Estás conectado exitosamente'
55
73
  }
56
74
  },
57
75
  acceptServer: {
@@ -585,7 +603,8 @@ var _default = exports.default = {
585
603
  setting: 'Ajustes',
586
604
  components: 'Dependencias del componente {name}',
587
605
  noDependencies: '{name} no tiene dependencias',
588
- relatedComponents: 'Componentes relacionados'
606
+ relatedComponents: 'Componentes relacionados',
607
+ required: 'Requerido'
589
608
  },
590
609
  router: {
591
610
  urlPath: 'URL Path',
@@ -668,7 +687,10 @@ var _default = exports.default = {
668
687
  noNote: 'Se requiere la Nota de Lanzamiento'
669
688
  },
670
689
  packTip: 'Los componentes y la configuración de la aplicación se incluirán automáticamente en el blocklet',
671
- resourceChangedWarning: 'Ha modificado el recurso, por favor guárdelo a tiempo'
690
+ resourceChangedWarning: 'Ha modificado el recurso, por favor guárdelo a tiempo',
691
+ installResourceTip: 'Por favor agrega el componente en una aplicación, URL del componente:',
692
+ installResourceTip2: 'Si desea ver más consejos, visite {name}',
693
+ installResourceHelp: 'Ayuda Documento'
672
694
  }
673
695
  },
674
696
  dashboard: {