@abtnode/ux 1.16.11-next-470e8c41 → 1.16.11
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/component/space-selector.js +1 -1
- package/lib/blocklet/configuration.js +28 -0
- package/lib/blocklet/storage/action.js +10 -6
- package/lib/blocklet/storage/backups.js +36 -46
- package/lib/blocklet/storage/connect-to.js +41 -30
- package/lib/blocklet/storage/connected.js +94 -25
- package/lib/blocklet/storage/item.js +33 -14
- package/lib/form/form-select-input.js +200 -0
- package/lib/form/form-text-input.js +5 -97
- package/lib/form/form-wrapper.js +1 -1
- package/lib/form/input-triggers.js +104 -0
- package/lib/locales/en.js +8 -1
- package/lib/locales/zh.js +3 -1
- package/lib/util/space-gateway.js +58 -0
- package/lib/util/spaces.js +52 -0
- package/package.json +16 -16
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateSpaceGatewaysFromDIDSpaces = updateSpaceGatewaysFromDIDSpaces;
|
|
7
|
+
var _lodash = require("lodash");
|
|
8
|
+
var _spaces = require("./spaces");
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
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); } /* eslint-disable import/prefer-default-export */
|
|
14
|
+
/**
|
|
15
|
+
* @description
|
|
16
|
+
* @export
|
|
17
|
+
* @param {{
|
|
18
|
+
* nodeApi: import('@abtnode/client'),
|
|
19
|
+
* blockletDid: string,
|
|
20
|
+
* spaceGateways: import('../blocklet/storage/connected').SpaceGateway[],
|
|
21
|
+
* }} { nodeApi, blockletDid, spaceGateways }
|
|
22
|
+
* @return {Promise<import('../blocklet/storage/connected').SpaceGateway[]>}
|
|
23
|
+
*/
|
|
24
|
+
async function updateSpaceGatewaysFromDIDSpaces(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
blockletDid,
|
|
27
|
+
nodeApi,
|
|
28
|
+
spaceGateways
|
|
29
|
+
} = _ref;
|
|
30
|
+
let shouldUpdate = false;
|
|
31
|
+
const latestSpaceGateways = await Promise.all(spaceGateways.map(async x => {
|
|
32
|
+
let {
|
|
33
|
+
name
|
|
34
|
+
} = x;
|
|
35
|
+
const newName = await (0, _spaces.getSpaceNameByEndpoint)(x.endpoint);
|
|
36
|
+
if (!(0, _lodash.isEmpty)(newName) && newName !== name) {
|
|
37
|
+
name = newName;
|
|
38
|
+
shouldUpdate = true;
|
|
39
|
+
}
|
|
40
|
+
return _objectSpread(_objectSpread({}, x), {}, {
|
|
41
|
+
name
|
|
42
|
+
});
|
|
43
|
+
}));
|
|
44
|
+
if (shouldUpdate) {
|
|
45
|
+
await Promise.all(latestSpaceGateways.filter(x => x.did).map(x => {
|
|
46
|
+
return nodeApi.updateBlockletSpaceGateway({
|
|
47
|
+
input: {
|
|
48
|
+
did: blockletDid,
|
|
49
|
+
where: {
|
|
50
|
+
did: x.did
|
|
51
|
+
},
|
|
52
|
+
spaceGateway: _objectSpread({}, x)
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
return latestSpaceGateways;
|
|
58
|
+
}
|
package/lib/util/spaces.js
CHANGED
|
@@ -8,9 +8,12 @@ exports.getDIDSpaceDidFromEndpoint = getDIDSpaceDidFromEndpoint;
|
|
|
8
8
|
exports.getDIDSpaceUrlFromEndpoint = getDIDSpaceUrlFromEndpoint;
|
|
9
9
|
exports.getSpaceBackupEndpoint = getSpaceBackupEndpoint;
|
|
10
10
|
exports.getSpaceGatewayFromEndpoint = getSpaceGatewayFromEndpoint;
|
|
11
|
+
exports.getSpaceNameByEndpoint = getSpaceNameByEndpoint;
|
|
11
12
|
exports.hasPermissionByEndpoint = hasPermissionByEndpoint;
|
|
13
|
+
exports.isValidSpaceGatewayUrl = isValidSpaceGatewayUrl;
|
|
12
14
|
var _isUrl = _interopRequireDefault(require("is-url"));
|
|
13
15
|
var _constant = require("@blocklet/constant");
|
|
16
|
+
var _lodash = require("lodash");
|
|
14
17
|
var _api = require("./api");
|
|
15
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
19
|
/* eslint-disable import/prefer-default-export */
|
|
@@ -97,4 +100,53 @@ function getSpaceBackupEndpoint(environments) {
|
|
|
97
100
|
*/
|
|
98
101
|
function getSpaceGatewayFromEndpoint(endpoint) {
|
|
99
102
|
return endpoint === null || endpoint === void 0 ? void 0 : endpoint.replace(/\/api\/space\/.+/, '');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @description
|
|
107
|
+
* @export
|
|
108
|
+
* @param {string} spaceGatewayUrl
|
|
109
|
+
* @return {Promise<boolean>}
|
|
110
|
+
*/
|
|
111
|
+
async function isValidSpaceGatewayUrl(spaceGatewayUrl) {
|
|
112
|
+
try {
|
|
113
|
+
if (!(0, _isUrl.default)(spaceGatewayUrl)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
const didConnectTokenUrl = joinUrl(spaceGatewayUrl, 'space/api/did/one-click-authorization/token');
|
|
117
|
+
const {
|
|
118
|
+
status,
|
|
119
|
+
data
|
|
120
|
+
} = await _api.api.get(didConnectTokenUrl, {
|
|
121
|
+
timeout: 5000
|
|
122
|
+
});
|
|
123
|
+
// note: data 必定返回一个对象才行,如果 data 返回了一个非对象,说明失败了,此时可能返回了前端的 404 页面的 html
|
|
124
|
+
return status === 200 && (0, _lodash.isObject)(data);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.error(error);
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @description
|
|
133
|
+
* @export
|
|
134
|
+
* @param {string} endpoint
|
|
135
|
+
* @return {Promise<string >}
|
|
136
|
+
*/
|
|
137
|
+
async function getSpaceNameByEndpoint(endpoint) {
|
|
138
|
+
try {
|
|
139
|
+
if (!(0, _isUrl.default)(endpoint)) {
|
|
140
|
+
return '';
|
|
141
|
+
}
|
|
142
|
+
const {
|
|
143
|
+
headers
|
|
144
|
+
} = await _api.api.head(endpoint, {
|
|
145
|
+
timeout: 3000
|
|
146
|
+
});
|
|
147
|
+
return headers['x-space-name'];
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error(error);
|
|
150
|
+
return '';
|
|
151
|
+
}
|
|
100
152
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.11
|
|
3
|
+
"version": "1.16.11",
|
|
4
4
|
"description": "UX components shared across abtnode packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@abtnode/auth": "1.16.11
|
|
27
|
-
"@abtnode/constant": "1.16.11
|
|
28
|
-
"@abtnode/util": "1.16.11
|
|
26
|
+
"@abtnode/auth": "1.16.11",
|
|
27
|
+
"@abtnode/constant": "1.16.11",
|
|
28
|
+
"@abtnode/util": "1.16.11",
|
|
29
29
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
30
|
-
"@arcblock/did": "^1.18.
|
|
31
|
-
"@arcblock/did-connect": "^2.5.
|
|
30
|
+
"@arcblock/did": "^1.18.84",
|
|
31
|
+
"@arcblock/did-connect": "^2.5.49",
|
|
32
32
|
"@arcblock/did-motif": "^1.1.10",
|
|
33
|
-
"@arcblock/icons": "^2.5.
|
|
34
|
-
"@arcblock/react-hooks": "^2.5.
|
|
35
|
-
"@arcblock/terminal": "^2.5.
|
|
36
|
-
"@arcblock/ux": "^2.5.
|
|
37
|
-
"@blocklet/constant": "1.16.11
|
|
38
|
-
"@blocklet/launcher-layout": "2.1.
|
|
33
|
+
"@arcblock/icons": "^2.5.49",
|
|
34
|
+
"@arcblock/react-hooks": "^2.5.49",
|
|
35
|
+
"@arcblock/terminal": "^2.5.49",
|
|
36
|
+
"@arcblock/ux": "^2.5.49",
|
|
37
|
+
"@blocklet/constant": "1.16.11",
|
|
38
|
+
"@blocklet/launcher-layout": "2.1.18",
|
|
39
39
|
"@blocklet/list": "^0.11.28",
|
|
40
|
-
"@blocklet/meta": "1.16.11
|
|
41
|
-
"@blocklet/ui-react": "^2.5.
|
|
40
|
+
"@blocklet/meta": "1.16.11",
|
|
41
|
+
"@blocklet/ui-react": "^2.5.49",
|
|
42
42
|
"@emotion/react": "^11.10.4",
|
|
43
43
|
"@emotion/styled": "^11.10.4",
|
|
44
44
|
"@iconify/react": "^4.0.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@mui/lab": "^5.0.0-alpha.102",
|
|
48
48
|
"@mui/material": "^5.10.8",
|
|
49
49
|
"@mui/styles": "^5.10.8",
|
|
50
|
-
"@ocap/client": "1.18.
|
|
50
|
+
"@ocap/client": "1.18.84",
|
|
51
51
|
"@uiw/react-markdown-preview": "4.0.6",
|
|
52
52
|
"ahooks": "^3.7.1",
|
|
53
53
|
"axios": "^0.27.2",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"@babel/preset-react": "^7.18.6",
|
|
94
94
|
"babel-plugin-inline-react-svg": "^1.1.2"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "bf1a5bd70ed2ee7cd044c6b629c18bbc900f1598"
|
|
97
97
|
}
|