@abtnode/ux 1.16.7 → 1.16.8-beta-ca58a421

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.7",
3
+ "version": "1.16.8-beta-ca58a421",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,9 +22,9 @@
22
22
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@abtnode/auth": "1.16.7",
26
- "@abtnode/constant": "1.16.7",
27
- "@abtnode/util": "1.16.7",
25
+ "@abtnode/auth": "1.16.8-beta-ca58a421",
26
+ "@abtnode/constant": "1.16.8-beta-ca58a421",
27
+ "@abtnode/util": "1.16.8-beta-ca58a421",
28
28
  "@ahooksjs/use-url-state": "^3.5.1",
29
29
  "@arcblock/did": "^1.18.78",
30
30
  "@arcblock/did-connect": "^2.5.37",
@@ -33,10 +33,10 @@
33
33
  "@arcblock/react-hooks": "^2.5.37",
34
34
  "@arcblock/terminal": "^2.5.37",
35
35
  "@arcblock/ux": "^2.5.37",
36
- "@blocklet/constant": "1.16.7",
36
+ "@blocklet/constant": "1.16.8-beta-ca58a421",
37
37
  "@blocklet/launcher-layout": "2.0.39",
38
38
  "@blocklet/list": "^0.11.24",
39
- "@blocklet/meta": "1.16.7",
39
+ "@blocklet/meta": "1.16.8-beta-ca58a421",
40
40
  "@blocklet/ui-react": "^2.5.37",
41
41
  "@emotion/react": "^11.10.4",
42
42
  "@emotion/styled": "^11.10.4",
@@ -92,5 +92,5 @@
92
92
  "@babel/preset-react": "^7.18.6",
93
93
  "babel-plugin-inline-react-svg": "^1.1.2"
94
94
  },
95
- "gitHead": "dadd7bfa319e2ee5144bdccb6e280ffe4b8d2679"
95
+ "gitHead": "d0f724c8082572a01b6e9287df6c3d0663ec9c57"
96
96
  }
@@ -1,180 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = Storage;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _Box = _interopRequireDefault(require("@mui/material/Box"));
9
- var _context = require("@arcblock/ux/lib/Locale/context");
10
- var _constant = require("@blocklet/constant");
11
- var _styled = _interopRequireDefault(require("@emotion/styled"));
12
- var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
13
- var _material = require("@mui/material");
14
- var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
15
- var _blocklet = require("../../lib/contexts/blocklet");
16
- var _node = require("../contexts/node");
17
- var _toast = _interopRequireDefault(require("../../lib/toast"));
18
- var _spaceConnector = _interopRequireDefault(require("./component/space-connector"));
19
- var _jsxRuntime = require("react/jsx-runtime");
20
- var _templateObject;
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
26
- 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; }
27
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
28
- 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); }
29
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
30
- const Container = (0, _styled.default)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n"])));
31
-
32
- /**
33
- * @description 实时显示备份的进度
34
- * @param {{appDid: string}} {appDid}
35
- * @return {{message: string, progress: number, completed: boolean}}
36
- */
37
- function useBackupProgress(_ref) {
38
- let {
39
- appDid
40
- } = _ref;
41
- const [progress, setProgress] = (0, _react.useState)({
42
- message: '',
43
- progress: 0,
44
- completed: false
45
- });
46
- const node = (0, _node.useNodeContext)();
47
- const {
48
- ws: {
49
- useSubscription
50
- }
51
- } = node;
52
- useSubscription(_constant.BlockletEvents.backupProgress, data => {
53
- setProgress(preValue => _objectSpread(_objectSpread({}, preValue), data));
54
- }, [appDid]);
55
- return progress;
56
- }
57
- function Storage() {
58
- /** @type {{ api: import('@abtnode/client').ABTNodeClient, info: import('@abtnode/client').NodeState }} */
59
- const {
60
- api
61
- } = (0, _node.useNodeContext)();
62
- const {
63
- t
64
- } = (0, _react.useContext)(_context.LocaleContext);
65
- /** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
66
- const {
67
- blocklet
68
- } = (0, _blocklet.useBlockletContext)();
69
- const endpoint = (0, _react.useMemo)(() => {
70
- var _blocklet$environment;
71
- return ((_blocklet$environment = blocklet.environments.find(e => e.key === _constant.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACE_ENDPOINT)) === null || _blocklet$environment === void 0 ? void 0 : _blocklet$environment.value) || '';
72
- }, [blocklet]);
73
- const progress = useBackupProgress({
74
- appDid: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appDid
75
- });
76
- const [isLoading, setIsLoading] = (0, _react.useState)(false);
77
- const onBackup = async () => {
78
- try {
79
- if (isLoading) {
80
- return;
81
- }
82
- setIsLoading(true);
83
- await api.backupBlocklet({
84
- input: {
85
- appDid: blocklet.appDid,
86
- to: 'spaces'
87
- }
88
- });
89
- _toast.default.success(t('storage.spaces.backupSuccessfully'));
90
- } catch (error) {
91
- _toast.default.error(error.message);
92
- console.error(error);
93
- } finally {
94
- setIsLoading(false);
95
- }
96
- };
97
- (0, _react.useEffect)(() => {
98
- if (progress !== null && progress !== void 0 && progress.completed) {
99
- setIsLoading(false);
100
- if (progress !== null && progress !== void 0 && progress.progress) {
101
- progress.progress = 0;
102
- }
103
- } else if (progress !== null && progress !== void 0 && progress.message) {
104
- setIsLoading(true);
105
- }
106
- }, [progress]);
107
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
108
- style: {
109
- maxWidth: '720px'
110
- },
111
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_spaceConnector.default, {
112
- sx: {
113
- marginTop: '24px',
114
- marginBottom: '40px'
115
- }
116
- }), endpoint && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
117
- mt: 3,
118
- display: "flex",
119
- alignItems: "center",
120
- justifyContent: "space-between",
121
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
122
- display: "inline",
123
- children: [t('storage.spaces.tips'), ": \xA0", ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
124
- display: "inline",
125
- color: "primary.main",
126
- fontWeight: "fontWeightBold",
127
- children: t('storage.spaces.connected')
128
- })]
129
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
130
- onClick: onBackup,
131
- loading: isLoading,
132
- variant: "contained",
133
- color: "primary",
134
- "data-cy": "add-domain-alias",
135
- disabled: !endpoint || isLoading,
136
- children: t('storage.spaces.backup')
137
- })]
138
- }), isLoading && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
139
- sx: {
140
- overflow: 'hidden'
141
- },
142
- display: "flex",
143
- flexDirection: "column",
144
- justifyContent: "center",
145
- textAlign: "center",
146
- marginTop: "16px",
147
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
148
- color: "primary",
149
- children: progress === null || progress === void 0 ? void 0 : progress.message
150
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
151
- sx: {
152
- display: 'flex',
153
- alignItems: 'center'
154
- },
155
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
156
- sx: {
157
- width: '100%',
158
- mr: 1
159
- },
160
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.LinearProgress, {
161
- color: "primary",
162
- variant: "determinate",
163
- value: progress === null || progress === void 0 ? void 0 : progress.progress
164
- })
165
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
166
- sx: {
167
- minWidth: 35
168
- },
169
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
170
- variant: "body2",
171
- color: "text.secondary",
172
- children: [progress === null || progress === void 0 ? void 0 : progress.progress, "%"]
173
- })
174
- })]
175
- })]
176
- })]
177
- });
178
- }
179
- Storage.propTypes = {};
180
- Storage.defaultProps = {};