@abtnode/ux 1.8.69-beta-650a290b → 1.16.0-beta-b16cb035
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/blocklet/migration.js +32 -6
- package/lib/blocklet/storage.js +7 -7
- package/lib/locales/en.js +7 -0
- package/lib/locales/zh.js +7 -0
- package/lib/util/index.js +3 -2
- package/package.json +13 -13
|
@@ -12,6 +12,7 @@ var _constant = require("@abtnode/constant");
|
|
|
12
12
|
var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
|
|
13
13
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
14
14
|
var _util = require("@blocklet/meta/lib/util");
|
|
15
|
+
var _node = require("../contexts/node");
|
|
15
16
|
var _blocklet = require("../contexts/blocklet");
|
|
16
17
|
var _session = require("../contexts/session");
|
|
17
18
|
var _toast = _interopRequireDefault(require("../toast"));
|
|
@@ -30,6 +31,31 @@ const findDuplicate = blocklet => {
|
|
|
30
31
|
});
|
|
31
32
|
return duplicate;
|
|
32
33
|
};
|
|
34
|
+
const getNewHref = (location, blocklet, inService) => {
|
|
35
|
+
const {
|
|
36
|
+
hostname,
|
|
37
|
+
href
|
|
38
|
+
} = location;
|
|
39
|
+
if (!blocklet) {
|
|
40
|
+
return href;
|
|
41
|
+
}
|
|
42
|
+
if (inService) {
|
|
43
|
+
var _blocklet$site;
|
|
44
|
+
const ipRegex = /\d+[-.]\d+[-.]\d+[-.]\d+/;
|
|
45
|
+
const match = ipRegex.exec(hostname);
|
|
46
|
+
if (!match) {
|
|
47
|
+
return href;
|
|
48
|
+
}
|
|
49
|
+
const ip = match[0];
|
|
50
|
+
const didDomain = (((_blocklet$site = blocklet.site) === null || _blocklet$site === void 0 ? void 0 : _blocklet$site.domainAliases) || []).map(x => x.value).filter(Boolean).find(x => x.endsWith(_constant.DEFAULT_DID_DOMAIN)) || '';
|
|
51
|
+
const base32Did = didDomain.replace(".".concat(_constant.DEFAULT_DID_DOMAIN), '');
|
|
52
|
+
if (!base32Did) {
|
|
53
|
+
return href;
|
|
54
|
+
}
|
|
55
|
+
return href.replace(hostname, "".concat(base32Did, "-").concat(ip, ".").concat(_constant.DEFAULT_IP_DOMAIN_SUFFIX));
|
|
56
|
+
}
|
|
57
|
+
return href.replace(blocklet.meta.bundleDid, blocklet.appPid);
|
|
58
|
+
};
|
|
33
59
|
function BlockletMigration() {
|
|
34
60
|
const {
|
|
35
61
|
t
|
|
@@ -40,6 +66,9 @@ function BlockletMigration() {
|
|
|
40
66
|
const {
|
|
41
67
|
blocklet
|
|
42
68
|
} = (0, _blocklet.useBlockletContext)();
|
|
69
|
+
const {
|
|
70
|
+
inService
|
|
71
|
+
} = (0, _node.useNodeContext)();
|
|
43
72
|
const [openConnect, setOpenConnect] = (0, _react.useState)(false);
|
|
44
73
|
const [leftSec, setLeftSec] = (0, _react.useState)(5);
|
|
45
74
|
const needMigration = blocklet && blocklet.structVersion !== _constant.APP_STRUCT_VERSION;
|
|
@@ -62,10 +91,7 @@ function BlockletMigration() {
|
|
|
62
91
|
}
|
|
63
92
|
};
|
|
64
93
|
const onSuccess = () => {
|
|
65
|
-
const
|
|
66
|
-
href
|
|
67
|
-
} = window.location;
|
|
68
|
-
const newHref = href.replace(blocklet.meta.bundleDid, blocklet.appPid);
|
|
94
|
+
const newHref = getNewHref(window.location, blocklet, inService);
|
|
69
95
|
setTimeout(() => {
|
|
70
96
|
window.location.href = newHref;
|
|
71
97
|
}, 5000);
|
|
@@ -117,9 +143,9 @@ function BlockletMigration() {
|
|
|
117
143
|
title: t('blocklet.migrate.title'),
|
|
118
144
|
scan: t('blocklet.migrate.scan'),
|
|
119
145
|
confirm: t('blocklet.migrate.confirm'),
|
|
120
|
-
success: t('blocklet.migrate.success', {
|
|
146
|
+
success: leftSec >= 0 ? t('blocklet.migrate.success', {
|
|
121
147
|
sec: leftSec
|
|
122
|
-
})
|
|
148
|
+
}) : 'Redirecting...'
|
|
123
149
|
},
|
|
124
150
|
onClose: onClose
|
|
125
151
|
})];
|
package/lib/blocklet/storage.js
CHANGED
|
@@ -36,12 +36,12 @@ const Container = (0, _styled.default)('div')(_templateObject || (_templateObjec
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @description 实时显示备份的进度
|
|
39
|
-
* @param {{
|
|
39
|
+
* @param {{appDid: string}} {appDid}
|
|
40
40
|
* @return {{message: string, progress: number, completed: boolean}}
|
|
41
41
|
*/
|
|
42
42
|
function useBackupProgress(_ref) {
|
|
43
43
|
let {
|
|
44
|
-
|
|
44
|
+
appDid
|
|
45
45
|
} = _ref;
|
|
46
46
|
const [progress, setProgress] = (0, _react.useState)({
|
|
47
47
|
message: '',
|
|
@@ -52,14 +52,14 @@ function useBackupProgress(_ref) {
|
|
|
52
52
|
const webSocketClient = node.ws.getWsClient();
|
|
53
53
|
(0, _react.useEffect)(() => {
|
|
54
54
|
webSocketClient.on(_constant.BlockletEvents.backupProgress, data => {
|
|
55
|
-
if (
|
|
55
|
+
if (appDid === (data === null || data === void 0 ? void 0 : data.appDid)) {
|
|
56
56
|
setProgress(preValue => _objectSpread(_objectSpread({}, preValue), data));
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
return () => {
|
|
60
60
|
webSocketClient.off(_constant.BlockletEvents.backupProgress);
|
|
61
61
|
};
|
|
62
|
-
}, [
|
|
62
|
+
}, [appDid, webSocketClient]);
|
|
63
63
|
return progress;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -109,7 +109,7 @@ function Storage() {
|
|
|
109
109
|
const [gatewayUrl, setGatewayUrl] = (0, _react.useState)('');
|
|
110
110
|
const [endpoint, setEndpoint] = (0, _react.useState)(((_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) || '');
|
|
111
111
|
const progress = useBackupProgress({
|
|
112
|
-
|
|
112
|
+
appDid: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appDid
|
|
113
113
|
});
|
|
114
114
|
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
115
115
|
const appName = (0, _util.getAppName)(blocklet);
|
|
@@ -166,7 +166,7 @@ function Storage() {
|
|
|
166
166
|
baseURL: (0, _urlJoin.default)(gatewayUrl, 'space')
|
|
167
167
|
}).get,
|
|
168
168
|
extraParams: {
|
|
169
|
-
appDid: blocklet.
|
|
169
|
+
appDid: blocklet.appDid,
|
|
170
170
|
appName,
|
|
171
171
|
appDescription,
|
|
172
172
|
scopes: 'list:object read:object write:object',
|
|
@@ -191,7 +191,7 @@ function Storage() {
|
|
|
191
191
|
setIsLoading(true);
|
|
192
192
|
await api.backupToSpaces({
|
|
193
193
|
input: {
|
|
194
|
-
|
|
194
|
+
appDid: blocklet.appDid
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
_toast.default.success(t('storage.spaces.backupSuccessfully'));
|
package/lib/locales/en.js
CHANGED
|
@@ -33,6 +33,7 @@ module.exports = {
|
|
|
33
33
|
connect: 'Connect Owner DID Wallet',
|
|
34
34
|
verify: 'Verify Ownership',
|
|
35
35
|
basicSettings: 'Basic Settings',
|
|
36
|
+
launchApp: 'Launch Application',
|
|
36
37
|
complete: 'Complete'
|
|
37
38
|
},
|
|
38
39
|
congratulation: 'Congratulations! Your Blocklet Server is secure and ready to use',
|
|
@@ -1122,6 +1123,12 @@ module.exports = {
|
|
|
1122
1123
|
installedButStopped: 'The Blocklet is installed successfully, but cannot be started. You can start it manually after resolving blocking issues',
|
|
1123
1124
|
installedButError: 'The Blocklet is successfully installed, but failed to start',
|
|
1124
1125
|
upgradeFailed: 'Upgrade Failed'
|
|
1126
|
+
},
|
|
1127
|
+
steps: {
|
|
1128
|
+
introduction: 'Introduction',
|
|
1129
|
+
installApp: 'Install Application',
|
|
1130
|
+
purchaseSpace: 'Purchase Space',
|
|
1131
|
+
prepareSpace: 'Prepare Space'
|
|
1125
1132
|
}
|
|
1126
1133
|
},
|
|
1127
1134
|
issuePassport: {
|
package/lib/locales/zh.js
CHANGED
|
@@ -33,6 +33,7 @@ module.exports = {
|
|
|
33
33
|
connect: '链接所有者的 DID 钱包',
|
|
34
34
|
verify: '验证所有权',
|
|
35
35
|
basicSettings: '基础设置',
|
|
36
|
+
launchApp: '启动应用',
|
|
36
37
|
complete: '完成'
|
|
37
38
|
},
|
|
38
39
|
congratulation: '恭喜, 您的节点安全可用!',
|
|
@@ -1128,6 +1129,12 @@ module.exports = {
|
|
|
1128
1129
|
installedButStopped: '应用安装成功,但是无法启动,解决启动问题之后后可手动启动',
|
|
1129
1130
|
installedButError: '应用已经安装,但是运行出错了',
|
|
1130
1131
|
upgradeFailed: '更新失败'
|
|
1132
|
+
},
|
|
1133
|
+
steps: {
|
|
1134
|
+
introduction: '简介',
|
|
1135
|
+
installApp: '安装应用',
|
|
1136
|
+
purchaseSpace: '选购空间',
|
|
1137
|
+
prepareSpace: '准备空间'
|
|
1131
1138
|
}
|
|
1132
1139
|
},
|
|
1133
1140
|
issuePassport: {
|
package/lib/util/index.js
CHANGED
|
@@ -117,7 +117,7 @@ function getAccessUrl(hostname) {
|
|
|
117
117
|
Object.keys(params).forEach(key => {
|
|
118
118
|
searchParams.append(key, params[key]);
|
|
119
119
|
});
|
|
120
|
-
return "".concat(url, "?").concat(searchParams.toString());
|
|
120
|
+
return "".concat(url).concat(urlObj.pathname === '/' ? '/' : '', "?").concat(searchParams.toString());
|
|
121
121
|
}
|
|
122
122
|
function getBlockletUrl() {
|
|
123
123
|
let {
|
|
@@ -161,8 +161,9 @@ function getBlockletUrls() {
|
|
|
161
161
|
}
|
|
162
162
|
let mountPoint = inputMountPoint;
|
|
163
163
|
if (!mountPoint) {
|
|
164
|
+
var _rule$from;
|
|
164
165
|
const rule = site.rules.filter(x => !x.from.pathPrefix.startsWith(_constant.WELLKNOWN_PATH_PREFIX))[0];
|
|
165
|
-
mountPoint = rule ? rule.
|
|
166
|
+
mountPoint = (0, _normalizePathPrefix.default)((rule === null || rule === void 0 ? void 0 : (_rule$from = rule.from) === null || _rule$from === void 0 ? void 0 : _rule$from.pathPrefix) || '/');
|
|
166
167
|
}
|
|
167
168
|
return domains.map(domain => getAccessUrl(domain.value, mountPoint, params));
|
|
168
169
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.16.0-beta-b16cb035",
|
|
7
7
|
"description": "UX components shared across abtnode packages",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@abtnode/auth": "1.
|
|
25
|
-
"@abtnode/constant": "1.
|
|
26
|
-
"@abtnode/util": "1.
|
|
27
|
-
"@arcblock/did-connect": "^2.5.
|
|
24
|
+
"@abtnode/auth": "1.16.0-beta-b16cb035",
|
|
25
|
+
"@abtnode/constant": "1.16.0-beta-b16cb035",
|
|
26
|
+
"@abtnode/util": "1.16.0-beta-b16cb035",
|
|
27
|
+
"@arcblock/did-connect": "^2.5.12",
|
|
28
28
|
"@arcblock/did-motif": "^1.1.10",
|
|
29
|
-
"@arcblock/icons": "^2.5.
|
|
30
|
-
"@arcblock/terminal": "^2.5.
|
|
31
|
-
"@arcblock/ux": "^2.5.
|
|
32
|
-
"@blocklet/constant": "1.
|
|
33
|
-
"@blocklet/launcher-layout": "
|
|
29
|
+
"@arcblock/icons": "^2.5.12",
|
|
30
|
+
"@arcblock/terminal": "^2.5.12",
|
|
31
|
+
"@arcblock/ux": "^2.5.12",
|
|
32
|
+
"@blocklet/constant": "1.16.0-beta-b16cb035",
|
|
33
|
+
"@blocklet/launcher-layout": "1.9.65",
|
|
34
34
|
"@blocklet/list": "^0.11.6",
|
|
35
|
-
"@blocklet/meta": "1.
|
|
36
|
-
"@blocklet/ui-react": "^2.5.
|
|
35
|
+
"@blocklet/meta": "1.16.0-beta-b16cb035",
|
|
36
|
+
"@blocklet/ui-react": "^2.5.12",
|
|
37
37
|
"@emotion/react": "^11.10.4",
|
|
38
38
|
"@emotion/styled": "^11.10.4",
|
|
39
39
|
"@iconify/react": "^4.0.0",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"@babel/preset-react": "^7.18.6",
|
|
87
87
|
"babel-plugin-inline-react-svg": "^1.1.2"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "138bd91aee5a35b28c2de4e1e924c44932efaf3a"
|
|
90
90
|
}
|