@abtnode/ux 1.16.23-beta-7b5b0175 → 1.16.23-beta-abdda301
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/es/blocklet/component/did-space/connect-to.js +37 -39
- package/es/blocklet/component/did-space/index.js +2 -0
- package/es/blocklet/publish/tree.js +2 -2
- package/es/blocklet/storage/connect-to.js +38 -36
- package/es/blocklet/util.js +8 -2
- package/es/contexts/config-space.js +1 -1
- package/es/hooks/use-blocklet-info-for-connect-did-spaces.js +4 -0
- package/lib/blocklet/component/did-space/connect-to.js +31 -33
- package/lib/blocklet/component/did-space/index.js +1 -1
- package/lib/blocklet/publish/tree.js +4 -4
- package/lib/blocklet/storage/connect-to.js +32 -30
- package/lib/blocklet/util.js +7 -1
- package/lib/contexts/config-space.js +1 -1
- package/lib/hooks/use-blocklet-info-for-connect-did-spaces.js +5 -0
- package/package.json +17 -16
|
@@ -9,10 +9,10 @@ import SplitButton from '@arcblock/ux/lib/SplitButton';
|
|
|
9
9
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
10
10
|
import Alert from '@arcblock/ux/lib/Alert';
|
|
11
11
|
import { func } from 'prop-types';
|
|
12
|
-
import
|
|
12
|
+
import isEmpty from 'lodash/isEmpty';
|
|
13
13
|
import useBlockletInfoForConnectDIDSpaces from '../../../hooks/use-blocklet-info-for-connect-did-spaces';
|
|
14
14
|
import { extraDIDSpacesCoreUrl, getDIDSpaceDidFromEndpoint, getSpaceGatewayUrl, isValidSpaceGatewayUrl } from '../../../util/spaces';
|
|
15
|
-
import { formatError, getWebWalletUrl } from '../../../util';
|
|
15
|
+
import { formatError, getPathPrefix, getWebWalletUrl } from '../../../util';
|
|
16
16
|
import { useBlockletContext } from '../../../contexts/blocklet';
|
|
17
17
|
import { useConfigSpaceContext } from '../../../contexts/config-space';
|
|
18
18
|
import { useNodeContext } from '../../../contexts/node';
|
|
@@ -60,12 +60,11 @@ function ConnectTo({
|
|
|
60
60
|
} = useConfigSpaceContext();
|
|
61
61
|
const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = useState({
|
|
62
62
|
open: false,
|
|
63
|
-
action: '
|
|
63
|
+
action: 'connect-to-did-spaces',
|
|
64
64
|
checkTimeout: 1000 * 300,
|
|
65
|
-
prefix:
|
|
66
|
-
baseUrl: new URL(PROD_DID_SPACES.CORE_URL).origin,
|
|
65
|
+
prefix: '/api/did',
|
|
67
66
|
checkFn: axios.create({
|
|
68
|
-
baseURL: joinUrl(
|
|
67
|
+
baseURL: joinUrl(window.location.origin, getPathPrefix())
|
|
69
68
|
}).get,
|
|
70
69
|
messages: {
|
|
71
70
|
title: t('storage.spaces.provideNFT.title', {
|
|
@@ -113,32 +112,6 @@ function ConnectTo({
|
|
|
113
112
|
}));
|
|
114
113
|
}
|
|
115
114
|
});
|
|
116
|
-
const onAuthorizeConnectSuccess = (response, decrypt) => {
|
|
117
|
-
setTimeout(async () => {
|
|
118
|
-
setAuthorizeConnect(preValue => ({
|
|
119
|
-
...preValue,
|
|
120
|
-
open: false
|
|
121
|
-
}));
|
|
122
|
-
setUrl(null);
|
|
123
|
-
setAuthorizeFromNftConnect(preValue => ({
|
|
124
|
-
...preValue,
|
|
125
|
-
open: false
|
|
126
|
-
}));
|
|
127
|
-
const endpoint = decrypt(response.endpoint);
|
|
128
|
-
const space = response.space ? decrypt(response.space) : {};
|
|
129
|
-
|
|
130
|
-
// eslint-disable-next-line no-use-before-define
|
|
131
|
-
await updateSpaceGateway({
|
|
132
|
-
endpoint,
|
|
133
|
-
// name 默认为 DID Space,兼容旧版本的 DID Spaces
|
|
134
|
-
...{
|
|
135
|
-
did: getDIDSpaceDidFromEndpoint(endpoint),
|
|
136
|
-
name: 'DID Space'
|
|
137
|
-
},
|
|
138
|
-
...space
|
|
139
|
-
});
|
|
140
|
-
}, 0);
|
|
141
|
-
};
|
|
142
115
|
|
|
143
116
|
/**
|
|
144
117
|
*
|
|
@@ -168,18 +141,43 @@ function ConnectTo({
|
|
|
168
141
|
name: spaceGateway.name
|
|
169
142
|
}));
|
|
170
143
|
};
|
|
144
|
+
const onAuthorizeConnectSuccess = (response, decrypt) => {
|
|
145
|
+
setTimeout(async () => {
|
|
146
|
+
setAuthorizeConnect(preValue => ({
|
|
147
|
+
...preValue,
|
|
148
|
+
open: false
|
|
149
|
+
}));
|
|
150
|
+
setUrl(null);
|
|
151
|
+
setAuthorizeFromNftConnect(preValue => ({
|
|
152
|
+
...preValue,
|
|
153
|
+
open: false
|
|
154
|
+
}));
|
|
155
|
+
if (!isEmpty(response.spaceGateway)) {
|
|
156
|
+
await updateSpaceGateway(decrypt(response.spaceGateway));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const endpoint = decrypt(response.endpoint);
|
|
160
|
+
const space = response.space ? decrypt(response.space) : {};
|
|
161
|
+
|
|
162
|
+
// eslint-disable-next-line no-use-before-define
|
|
163
|
+
await updateSpaceGateway({
|
|
164
|
+
endpoint,
|
|
165
|
+
// name 默认为 DID Space,兼容旧版本的 DID Spaces
|
|
166
|
+
...{
|
|
167
|
+
did: getDIDSpaceDidFromEndpoint(endpoint),
|
|
168
|
+
name: 'DID Space'
|
|
169
|
+
},
|
|
170
|
+
...space
|
|
171
|
+
});
|
|
172
|
+
}, 0);
|
|
173
|
+
};
|
|
171
174
|
const handleUseWalletConnect = () => {
|
|
172
175
|
setAuthorizeFromNftConnect(preValue => ({
|
|
173
176
|
...preValue,
|
|
174
177
|
open: true,
|
|
175
178
|
extraParams: {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
appDescription: blockletInfo.appDescription,
|
|
179
|
-
scopes: blockletInfo.scopes,
|
|
180
|
-
appUrl: blockletInfo.appUrl,
|
|
181
|
-
referrer: blockletInfo.referrer,
|
|
182
|
-
nodeDid: info.did
|
|
179
|
+
appPid: blocklet.appPid,
|
|
180
|
+
referrer: window.location.href
|
|
183
181
|
}
|
|
184
182
|
}));
|
|
185
183
|
};
|
|
@@ -4,8 +4,8 @@ import classnames from 'classnames';
|
|
|
4
4
|
import isUrl from 'is-url';
|
|
5
5
|
import Box from '@mui/material/Box';
|
|
6
6
|
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
7
|
-
import TreeView from '@mui/
|
|
8
|
-
import TreeItem from '@mui/
|
|
7
|
+
import { TreeView } from '@mui/x-tree-view/TreeView';
|
|
8
|
+
import { TreeItem } from '@mui/x-tree-view/TreeItem';
|
|
9
9
|
import Checkbox from '@mui/material/Checkbox';
|
|
10
10
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
11
11
|
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
@@ -8,10 +8,10 @@ import toast from '@arcblock/ux/lib/Toast';
|
|
|
8
8
|
import SplitButton from '@arcblock/ux/lib/SplitButton';
|
|
9
9
|
import Dialog from '@arcblock/ux/lib/Dialog';
|
|
10
10
|
import Alert from '@arcblock/ux/lib/Alert';
|
|
11
|
-
import {
|
|
11
|
+
import { isEmpty } from 'lodash';
|
|
12
12
|
import { useBlockletContext } from '../../contexts/blocklet';
|
|
13
13
|
import { axios } from '../../util/api';
|
|
14
|
-
import { formatError, getWebWalletUrl } from '../../util';
|
|
14
|
+
import { formatError, getPathPrefix, getWebWalletUrl } from '../../util';
|
|
15
15
|
import { useNodeContext } from '../../contexts/node';
|
|
16
16
|
import useBlockletInfoForConnectDIDSpaces from '../../hooks/use-blocklet-info-for-connect-did-spaces';
|
|
17
17
|
import { extraDIDSpacesCoreUrl, getDIDSpaceDidFromEndpoint, getSpaceGatewayUrl, isValidSpaceGatewayUrl } from '../../util/spaces';
|
|
@@ -27,6 +27,7 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
27
27
|
function ConnectTo({
|
|
28
28
|
...rest
|
|
29
29
|
}) {
|
|
30
|
+
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
30
31
|
const {
|
|
31
32
|
blocklet
|
|
32
33
|
} = useBlockletContext();
|
|
@@ -51,12 +52,10 @@ function ConnectTo({
|
|
|
51
52
|
} = useBlockletStorageContext();
|
|
52
53
|
const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = useState({
|
|
53
54
|
open: false,
|
|
54
|
-
action: '
|
|
55
|
+
action: 'connect-to-did-spaces',
|
|
55
56
|
checkTimeout: 1000 * 300,
|
|
56
|
-
prefix: joinUrl(PROD_DID_SPACES.CORE_URL, 'space/api/did'),
|
|
57
|
-
baseUrl: new URL(PROD_DID_SPACES.CORE_URL).origin,
|
|
58
57
|
checkFn: axios.create({
|
|
59
|
-
baseURL: joinUrl(
|
|
58
|
+
baseURL: joinUrl(window.location.origin, getPathPrefix())
|
|
60
59
|
}).get,
|
|
61
60
|
messages: {
|
|
62
61
|
title: t('storage.spaces.provideNFT.title', {
|
|
@@ -104,35 +103,6 @@ function ConnectTo({
|
|
|
104
103
|
}));
|
|
105
104
|
}
|
|
106
105
|
});
|
|
107
|
-
const onAuthorizeConnectSuccess = async (response, decrypt) => {
|
|
108
|
-
try {
|
|
109
|
-
const endpoint = decrypt(response.endpoint);
|
|
110
|
-
const space = response.space ? decrypt(response.space) : {};
|
|
111
|
-
|
|
112
|
-
// eslint-disable-next-line no-use-before-define
|
|
113
|
-
await addSpaceGatewayNow({
|
|
114
|
-
endpoint,
|
|
115
|
-
// name 默认为 DID Space,兼容旧版本的 DID Spaces
|
|
116
|
-
...{
|
|
117
|
-
did: getDIDSpaceDidFromEndpoint(endpoint),
|
|
118
|
-
name: 'DID Space'
|
|
119
|
-
},
|
|
120
|
-
...space
|
|
121
|
-
});
|
|
122
|
-
setAuthorizeConnect(preValue => ({
|
|
123
|
-
...preValue,
|
|
124
|
-
open: false
|
|
125
|
-
}));
|
|
126
|
-
setUrl(null);
|
|
127
|
-
setAuthorizeFromNftConnect(preValue => ({
|
|
128
|
-
...preValue,
|
|
129
|
-
open: false
|
|
130
|
-
}));
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.error(error);
|
|
133
|
-
toast.error(formatError(error));
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
106
|
|
|
137
107
|
/**
|
|
138
108
|
*
|
|
@@ -171,12 +141,44 @@ function ConnectTo({
|
|
|
171
141
|
name: spaceGateway?.name ?? 'DID Spaces'
|
|
172
142
|
}));
|
|
173
143
|
};
|
|
144
|
+
const onAuthorizeConnectSuccess = async (response, decrypt) => {
|
|
145
|
+
try {
|
|
146
|
+
if (!isEmpty(response.spaceGateway)) {
|
|
147
|
+
await addSpaceGatewayNow(decrypt(response.spaceGateway));
|
|
148
|
+
} else {
|
|
149
|
+
const endpoint = decrypt(response.endpoint);
|
|
150
|
+
const space = response.space ? decrypt(response.space) : {};
|
|
151
|
+
// eslint-disable-next-line no-use-before-define
|
|
152
|
+
await addSpaceGatewayNow({
|
|
153
|
+
endpoint,
|
|
154
|
+
// name 默认为 DID Space,兼容旧版本的 DID Spaces
|
|
155
|
+
...{
|
|
156
|
+
did: getDIDSpaceDidFromEndpoint(endpoint),
|
|
157
|
+
name: 'DID Space'
|
|
158
|
+
},
|
|
159
|
+
...space
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
setAuthorizeConnect(preValue => ({
|
|
163
|
+
...preValue,
|
|
164
|
+
open: false
|
|
165
|
+
}));
|
|
166
|
+
setUrl(null);
|
|
167
|
+
setAuthorizeFromNftConnect(preValue => ({
|
|
168
|
+
...preValue,
|
|
169
|
+
open: false
|
|
170
|
+
}));
|
|
171
|
+
} catch (error) {
|
|
172
|
+
console.error(error);
|
|
173
|
+
toast.error(formatError(error));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
174
176
|
const handleUseWalletConnect = () => {
|
|
175
177
|
setAuthorizeFromNftConnect(preValue => ({
|
|
176
178
|
...preValue,
|
|
177
179
|
open: true,
|
|
178
180
|
extraParams: {
|
|
179
|
-
|
|
181
|
+
appPid: blocklet.appPid,
|
|
180
182
|
appName: blockletInfo.appName,
|
|
181
183
|
appDescription: blockletInfo.appDescription,
|
|
182
184
|
scopes: blockletInfo.scopes,
|
package/es/blocklet/util.js
CHANGED
|
@@ -3,7 +3,7 @@ import joinUrl from 'url-join';
|
|
|
3
3
|
import isEmpty from 'lodash/isEmpty';
|
|
4
4
|
import normalizePathPrefix from '@abtnode/util/lib/normalize-path-prefix';
|
|
5
5
|
import { forEachBlockletSync, replaceSlotToIp } from '@blocklet/meta/lib/util';
|
|
6
|
-
import {
|
|
6
|
+
import { BLOCKLET_APP_SPACE_REQUIREMENT } from '@blocklet/constant';
|
|
7
7
|
import { SLOT_FOR_IP_DNS_SITE } from '@abtnode/constant';
|
|
8
8
|
export const getServerUrl = (info, encodeURI = false) => {
|
|
9
9
|
const adminPath = process.env.NODE_ENV === 'production' ? info.routing.adminPath : '';
|
|
@@ -49,7 +49,7 @@ export const getAppCapabilities = blocklet => {
|
|
|
49
49
|
didSpace: null
|
|
50
50
|
};
|
|
51
51
|
forEachBlockletSync(blocklet, b => {
|
|
52
|
-
if (capabilities.didSpace ===
|
|
52
|
+
if (capabilities.didSpace === BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED || capabilities.didSpace === BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP) {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
if (b?.meta?.capabilities?.didSpace) {
|
|
@@ -142,4 +142,10 @@ export const getWalletType = (raw, fromState = false) => {
|
|
|
142
142
|
}
|
|
143
143
|
return DEFAULT_WALLET_TYPE;
|
|
144
144
|
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
* @param {import('@abtnode/client').BlockletState} blocklet
|
|
149
|
+
* @returns {boolean}
|
|
150
|
+
*/
|
|
145
151
|
export const isServerless = blocklet => !isEmpty(blocklet?.controller);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getAppDescription, getAppName } from '@blocklet/meta/lib/util';
|
|
2
|
+
import isEmpty from 'lodash/isEmpty';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
@@ -17,6 +18,9 @@ import { getAppDescription, getAppName } from '@blocklet/meta/lib/util';
|
|
|
17
18
|
function useBlockletInfoForConnectDIDSpaces({
|
|
18
19
|
blocklet
|
|
19
20
|
}) {
|
|
21
|
+
if (isEmpty(blocklet)) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
20
24
|
const {
|
|
21
25
|
appDid
|
|
22
26
|
} = blocklet;
|
|
@@ -15,7 +15,7 @@ var _SplitButton = _interopRequireDefault(require("@arcblock/ux/lib/SplitButton"
|
|
|
15
15
|
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
16
16
|
var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
|
|
17
17
|
var _propTypes = require("prop-types");
|
|
18
|
-
var
|
|
18
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
19
19
|
var _useBlockletInfoForConnectDidSpaces = _interopRequireDefault(require("../../../hooks/use-blocklet-info-for-connect-did-spaces"));
|
|
20
20
|
var _spaces = require("../../../util/spaces");
|
|
21
21
|
var _util = require("../../../util");
|
|
@@ -74,12 +74,11 @@ function ConnectTo(_ref) {
|
|
|
74
74
|
} = (0, _configSpace.useConfigSpaceContext)();
|
|
75
75
|
const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = (0, _react.useState)({
|
|
76
76
|
open: false,
|
|
77
|
-
action: '
|
|
77
|
+
action: 'connect-to-did-spaces',
|
|
78
78
|
checkTimeout: 1000 * 300,
|
|
79
|
-
prefix:
|
|
80
|
-
baseUrl: new URL(_constant.PROD_DID_SPACES.CORE_URL).origin,
|
|
79
|
+
prefix: '/api/did',
|
|
81
80
|
checkFn: _api.axios.create({
|
|
82
|
-
baseURL: (0, _urlJoin.default)(
|
|
81
|
+
baseURL: (0, _urlJoin.default)(window.location.origin, (0, _util.getPathPrefix)())
|
|
83
82
|
}).get,
|
|
84
83
|
messages: {
|
|
85
84
|
title: t('storage.spaces.provideNFT.title', {
|
|
@@ -125,27 +124,6 @@ function ConnectTo(_ref) {
|
|
|
125
124
|
}));
|
|
126
125
|
}
|
|
127
126
|
});
|
|
128
|
-
const onAuthorizeConnectSuccess = (response, decrypt) => {
|
|
129
|
-
setTimeout(async () => {
|
|
130
|
-
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
131
|
-
open: false
|
|
132
|
-
}));
|
|
133
|
-
setUrl(null);
|
|
134
|
-
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
135
|
-
open: false
|
|
136
|
-
}));
|
|
137
|
-
const endpoint = decrypt(response.endpoint);
|
|
138
|
-
const space = response.space ? decrypt(response.space) : {};
|
|
139
|
-
|
|
140
|
-
// eslint-disable-next-line no-use-before-define
|
|
141
|
-
await updateSpaceGateway(_objectSpread(_objectSpread({
|
|
142
|
-
endpoint
|
|
143
|
-
}, {
|
|
144
|
-
did: (0, _spaces.getDIDSpaceDidFromEndpoint)(endpoint),
|
|
145
|
-
name: 'DID Space'
|
|
146
|
-
}), space));
|
|
147
|
-
}, 0);
|
|
148
|
-
};
|
|
149
127
|
|
|
150
128
|
/**
|
|
151
129
|
*
|
|
@@ -176,17 +154,37 @@ function ConnectTo(_ref) {
|
|
|
176
154
|
name: spaceGateway.name
|
|
177
155
|
}));
|
|
178
156
|
};
|
|
157
|
+
const onAuthorizeConnectSuccess = (response, decrypt) => {
|
|
158
|
+
setTimeout(async () => {
|
|
159
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
160
|
+
open: false
|
|
161
|
+
}));
|
|
162
|
+
setUrl(null);
|
|
163
|
+
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
164
|
+
open: false
|
|
165
|
+
}));
|
|
166
|
+
if (!(0, _isEmpty.default)(response.spaceGateway)) {
|
|
167
|
+
await updateSpaceGateway(decrypt(response.spaceGateway));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const endpoint = decrypt(response.endpoint);
|
|
171
|
+
const space = response.space ? decrypt(response.space) : {};
|
|
172
|
+
|
|
173
|
+
// eslint-disable-next-line no-use-before-define
|
|
174
|
+
await updateSpaceGateway(_objectSpread(_objectSpread({
|
|
175
|
+
endpoint
|
|
176
|
+
}, {
|
|
177
|
+
did: (0, _spaces.getDIDSpaceDidFromEndpoint)(endpoint),
|
|
178
|
+
name: 'DID Space'
|
|
179
|
+
}), space));
|
|
180
|
+
}, 0);
|
|
181
|
+
};
|
|
179
182
|
const handleUseWalletConnect = () => {
|
|
180
183
|
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
181
184
|
open: true,
|
|
182
185
|
extraParams: {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
appDescription: blockletInfo.appDescription,
|
|
186
|
-
scopes: blockletInfo.scopes,
|
|
187
|
-
appUrl: blockletInfo.appUrl,
|
|
188
|
-
referrer: blockletInfo.referrer,
|
|
189
|
-
nodeDid: info.did
|
|
186
|
+
appPid: blocklet.appPid,
|
|
187
|
+
referrer: window.location.href
|
|
190
188
|
}
|
|
191
189
|
}));
|
|
192
190
|
};
|
|
@@ -77,5 +77,5 @@ DidSpace.propTypes = {
|
|
|
77
77
|
DidSpace.defaultProps = {
|
|
78
78
|
onEndpointUpdate: () => undefined
|
|
79
79
|
};
|
|
80
|
-
const Container = (0, _styled.default)(_contentLayout.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n"])));
|
|
80
|
+
const Container = (0, _styled.default)(_contentLayout.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n padding-bottom: 32px;\n overflow-x: hidden;\n"])));
|
|
81
81
|
var _default = exports.default = DidSpace;
|
|
@@ -10,8 +10,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
10
10
|
var _isUrl = _interopRequireDefault(require("is-url"));
|
|
11
11
|
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
12
12
|
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
13
|
-
var _TreeView =
|
|
14
|
-
var _TreeItem =
|
|
13
|
+
var _TreeView = require("@mui/x-tree-view/TreeView");
|
|
14
|
+
var _TreeItem = require("@mui/x-tree-view/TreeItem");
|
|
15
15
|
var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
|
|
16
16
|
var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
|
|
17
17
|
var _ChevronRight = _interopRequireDefault(require("@mui/icons-material/ChevronRight"));
|
|
@@ -128,7 +128,7 @@ function Tree(_ref2) {
|
|
|
128
128
|
});
|
|
129
129
|
const renderTree = node => {
|
|
130
130
|
var _node$images;
|
|
131
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeItem.
|
|
131
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeItem.TreeItem, {
|
|
132
132
|
nodeId: node.id,
|
|
133
133
|
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
|
|
134
134
|
onClick: stopExpand,
|
|
@@ -192,7 +192,7 @@ Tree.defaultProps = {
|
|
|
192
192
|
onChange: () => {},
|
|
193
193
|
disabled: false
|
|
194
194
|
};
|
|
195
|
-
const StyledTreeView = (0, _styled.default)(_TreeView.
|
|
195
|
+
const StyledTreeView = (0, _styled.default)(_TreeView.TreeView)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.no-children {\n .MuiTreeItem-content {\n padding: 0;\n .MuiTreeItem-iconContainer {\n display: none;\n }\n .MuiTreeItem-label {\n padding-left: 0;\n }\n }\n }\n .MuiTreeItem-content {\n align-items: flex-start;\n .MuiTreeItem-iconContainer {\n transform: translateY(10px);\n }\n &.Mui-selected {\n background-color: transparent;\n }\n }\n .MuiTreeItem-label {\n cursor: default;\n }\n .MuiFormControlLabel-root {\n align-items: flex-start;\n }\n .content {\n padding-top: 6px;\n }\n .name {\n font-size: 16px;\n font-weight: 700;\n }\n .resource-icon {\n margin-right: 2px;\n font-size: 16px;\n }\n img.resource-icon {\n width: 1rem;\n height: 1rem;\n }\n .link {\n margin-left: 8px;\n font-size: 16px;\n color: ", ";\n display: flex;\n }\n .link-icon {\n font-size: inherit;\n }\n .description {\n font-size: 14px;\n color: ", ";\n }\n"])), _ref3 => {
|
|
196
196
|
let {
|
|
197
197
|
theme
|
|
198
198
|
} = _ref3;
|
|
@@ -14,7 +14,7 @@ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
|
14
14
|
var _SplitButton = _interopRequireDefault(require("@arcblock/ux/lib/SplitButton"));
|
|
15
15
|
var _Dialog = _interopRequireDefault(require("@arcblock/ux/lib/Dialog"));
|
|
16
16
|
var _Alert = _interopRequireDefault(require("@arcblock/ux/lib/Alert"));
|
|
17
|
-
var
|
|
17
|
+
var _lodash = require("lodash");
|
|
18
18
|
var _blocklet = require("../../contexts/blocklet");
|
|
19
19
|
var _api = require("../../util/api");
|
|
20
20
|
var _util = require("../../util");
|
|
@@ -38,6 +38,7 @@ function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("
|
|
|
38
38
|
*/
|
|
39
39
|
function ConnectTo(_ref) {
|
|
40
40
|
let rest = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
41
|
+
/** @type {{ blocklet: import('@abtnode/client').BlockletState }} */
|
|
41
42
|
const {
|
|
42
43
|
blocklet
|
|
43
44
|
} = (0, _blocklet.useBlockletContext)();
|
|
@@ -62,12 +63,10 @@ function ConnectTo(_ref) {
|
|
|
62
63
|
} = (0, _blockletStorage.useBlockletStorageContext)();
|
|
63
64
|
const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = (0, _react.useState)({
|
|
64
65
|
open: false,
|
|
65
|
-
action: '
|
|
66
|
+
action: 'connect-to-did-spaces',
|
|
66
67
|
checkTimeout: 1000 * 300,
|
|
67
|
-
prefix: (0, _urlJoin.default)(_constant.PROD_DID_SPACES.CORE_URL, 'space/api/did'),
|
|
68
|
-
baseUrl: new URL(_constant.PROD_DID_SPACES.CORE_URL).origin,
|
|
69
68
|
checkFn: _api.axios.create({
|
|
70
|
-
baseURL: (0, _urlJoin.default)(
|
|
69
|
+
baseURL: (0, _urlJoin.default)(window.location.origin, (0, _util.getPathPrefix)())
|
|
71
70
|
}).get,
|
|
72
71
|
messages: {
|
|
73
72
|
title: t('storage.spaces.provideNFT.title', {
|
|
@@ -113,30 +112,6 @@ function ConnectTo(_ref) {
|
|
|
113
112
|
}));
|
|
114
113
|
}
|
|
115
114
|
});
|
|
116
|
-
const onAuthorizeConnectSuccess = async (response, decrypt) => {
|
|
117
|
-
try {
|
|
118
|
-
const endpoint = decrypt(response.endpoint);
|
|
119
|
-
const space = response.space ? decrypt(response.space) : {};
|
|
120
|
-
|
|
121
|
-
// eslint-disable-next-line no-use-before-define
|
|
122
|
-
await addSpaceGatewayNow(_objectSpread(_objectSpread({
|
|
123
|
-
endpoint
|
|
124
|
-
}, {
|
|
125
|
-
did: (0, _spaces.getDIDSpaceDidFromEndpoint)(endpoint),
|
|
126
|
-
name: 'DID Space'
|
|
127
|
-
}), space));
|
|
128
|
-
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
129
|
-
open: false
|
|
130
|
-
}));
|
|
131
|
-
setUrl(null);
|
|
132
|
-
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
133
|
-
open: false
|
|
134
|
-
}));
|
|
135
|
-
} catch (error) {
|
|
136
|
-
console.error(error);
|
|
137
|
-
_Toast.default.error((0, _util.formatError)(error));
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
115
|
|
|
141
116
|
/**
|
|
142
117
|
*
|
|
@@ -177,11 +152,38 @@ function ConnectTo(_ref) {
|
|
|
177
152
|
name: (_spaceGateway$name = spaceGateway === null || spaceGateway === void 0 ? void 0 : spaceGateway.name) !== null && _spaceGateway$name !== void 0 ? _spaceGateway$name : 'DID Spaces'
|
|
178
153
|
}));
|
|
179
154
|
};
|
|
155
|
+
const onAuthorizeConnectSuccess = async (response, decrypt) => {
|
|
156
|
+
try {
|
|
157
|
+
if (!(0, _lodash.isEmpty)(response.spaceGateway)) {
|
|
158
|
+
await addSpaceGatewayNow(decrypt(response.spaceGateway));
|
|
159
|
+
} else {
|
|
160
|
+
const endpoint = decrypt(response.endpoint);
|
|
161
|
+
const space = response.space ? decrypt(response.space) : {};
|
|
162
|
+
// eslint-disable-next-line no-use-before-define
|
|
163
|
+
await addSpaceGatewayNow(_objectSpread(_objectSpread({
|
|
164
|
+
endpoint
|
|
165
|
+
}, {
|
|
166
|
+
did: (0, _spaces.getDIDSpaceDidFromEndpoint)(endpoint),
|
|
167
|
+
name: 'DID Space'
|
|
168
|
+
}), space));
|
|
169
|
+
}
|
|
170
|
+
setAuthorizeConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
171
|
+
open: false
|
|
172
|
+
}));
|
|
173
|
+
setUrl(null);
|
|
174
|
+
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
175
|
+
open: false
|
|
176
|
+
}));
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.error(error);
|
|
179
|
+
_Toast.default.error((0, _util.formatError)(error));
|
|
180
|
+
}
|
|
181
|
+
};
|
|
180
182
|
const handleUseWalletConnect = () => {
|
|
181
183
|
setAuthorizeFromNftConnect(preValue => _objectSpread(_objectSpread({}, preValue), {}, {
|
|
182
184
|
open: true,
|
|
183
185
|
extraParams: {
|
|
184
|
-
|
|
186
|
+
appPid: blocklet.appPid,
|
|
185
187
|
appName: blockletInfo.appName,
|
|
186
188
|
appDescription: blockletInfo.appDescription,
|
|
187
189
|
scopes: blockletInfo.scopes,
|
package/lib/blocklet/util.js
CHANGED
|
@@ -60,7 +60,7 @@ const getAppCapabilities = blocklet => {
|
|
|
60
60
|
};
|
|
61
61
|
(0, _util.forEachBlockletSync)(blocklet, b => {
|
|
62
62
|
var _b$meta, _b$meta$capabilities;
|
|
63
|
-
if (capabilities.didSpace === _constant.
|
|
63
|
+
if (capabilities.didSpace === _constant.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED || capabilities.didSpace === _constant.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
if (b !== null && b !== void 0 && (_b$meta = b.meta) !== null && _b$meta !== void 0 && (_b$meta$capabilities = _b$meta.capabilities) !== null && _b$meta$capabilities !== void 0 && _b$meta$capabilities.didSpace) {
|
|
@@ -158,5 +158,11 @@ const getWalletType = exports.getWalletType = function getWalletType(raw) {
|
|
|
158
158
|
}
|
|
159
159
|
return DEFAULT_WALLET_TYPE;
|
|
160
160
|
};
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
* @param {import('@abtnode/client').BlockletState} blocklet
|
|
165
|
+
* @returns {boolean}
|
|
166
|
+
*/
|
|
161
167
|
const isServerless = blocklet => !(0, _isEmpty.default)(blocklet === null || blocklet === void 0 ? void 0 : blocklet.controller);
|
|
162
168
|
exports.isServerless = isServerless;
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _util = require("@blocklet/meta/lib/util");
|
|
8
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
10
|
/**
|
|
9
11
|
*
|
|
10
12
|
*
|
|
@@ -24,6 +26,9 @@ function useBlockletInfoForConnectDIDSpaces(_ref) {
|
|
|
24
26
|
let {
|
|
25
27
|
blocklet
|
|
26
28
|
} = _ref;
|
|
29
|
+
if ((0, _isEmpty.default)(blocklet)) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
27
32
|
const {
|
|
28
33
|
appDid
|
|
29
34
|
} = blocklet;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.23-beta-
|
|
3
|
+
"version": "1.16.23-beta-abdda301",
|
|
4
4
|
"description": "UX components shared across abtnode packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,24 +27,24 @@
|
|
|
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.23-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.23-beta-
|
|
32
|
-
"@abtnode/util": "1.16.23-beta-
|
|
30
|
+
"@abtnode/auth": "1.16.23-beta-abdda301",
|
|
31
|
+
"@abtnode/constant": "1.16.23-beta-abdda301",
|
|
32
|
+
"@abtnode/util": "1.16.23-beta-abdda301",
|
|
33
33
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
34
34
|
"@arcblock/did": "^1.18.108",
|
|
35
|
-
"@arcblock/did-connect": "^2.9.
|
|
35
|
+
"@arcblock/did-connect": "^2.9.19",
|
|
36
36
|
"@arcblock/did-motif": "^1.1.13",
|
|
37
|
-
"@arcblock/icons": "^2.9.
|
|
38
|
-
"@arcblock/nft-display": "2.9.
|
|
39
|
-
"@arcblock/react-hooks": "^2.9.
|
|
40
|
-
"@arcblock/terminal": "^2.9.
|
|
41
|
-
"@arcblock/ux": "^2.9.
|
|
42
|
-
"@blocklet/constant": "1.16.23-beta-
|
|
37
|
+
"@arcblock/icons": "^2.9.19",
|
|
38
|
+
"@arcblock/nft-display": "2.9.19",
|
|
39
|
+
"@arcblock/react-hooks": "^2.9.19",
|
|
40
|
+
"@arcblock/terminal": "^2.9.19",
|
|
41
|
+
"@arcblock/ux": "^2.9.19",
|
|
42
|
+
"@blocklet/constant": "1.16.23-beta-abdda301",
|
|
43
43
|
"@blocklet/launcher-layout": "2.2.51",
|
|
44
|
-
"@blocklet/list": "^0.12.
|
|
45
|
-
"@blocklet/meta": "1.16.23-beta-
|
|
46
|
-
"@blocklet/ui-react": "^2.9.
|
|
47
|
-
"@blocklet/uploader": "^0.0.
|
|
44
|
+
"@blocklet/list": "^0.12.67",
|
|
45
|
+
"@blocklet/meta": "1.16.23-beta-abdda301",
|
|
46
|
+
"@blocklet/ui-react": "^2.9.19",
|
|
47
|
+
"@blocklet/uploader": "^0.0.67",
|
|
48
48
|
"@emotion/react": "^11.10.4",
|
|
49
49
|
"@emotion/styled": "^11.10.4",
|
|
50
50
|
"@iconify/react": "^4.0.0",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@mui/material": "^5.15.6",
|
|
55
55
|
"@mui/styles": "^5.15.6",
|
|
56
56
|
"@mui/x-date-pickers": "^6.19.0",
|
|
57
|
+
"@mui/x-tree-view": "^6.17.0",
|
|
57
58
|
"@ocap/client": "1.18.108",
|
|
58
59
|
"@uiw/react-markdown-preview": "4.0.6",
|
|
59
60
|
"ahooks": "^3.7.8",
|
|
@@ -104,7 +105,7 @@
|
|
|
104
105
|
"jest": "^29.7.0",
|
|
105
106
|
"jest-environment-jsdom": "^29.7.0"
|
|
106
107
|
},
|
|
107
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "2b064df15b34007f6145170ee691ae9e91ff1528",
|
|
108
109
|
"exports": {
|
|
109
110
|
".": {
|
|
110
111
|
"import": "./es/index.js",
|