@abtnode/ux 1.16.22-beta-079a9053 → 1.16.22-beta-5bf86cd3
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Connect from '@arcblock/did-connect/lib/Connect';
|
|
2
2
|
import Button from '@arcblock/ux/lib/Button';
|
|
3
|
+
import Center from '@arcblock/ux/lib/Center';
|
|
3
4
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
5
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
5
6
|
import IconInfo from '@mui/icons-material/InfoOutlined';
|
|
@@ -12,6 +13,8 @@ import noop from 'lodash/noop';
|
|
|
12
13
|
import trim from 'lodash/trim';
|
|
13
14
|
import PropTypes from 'prop-types';
|
|
14
15
|
import useSetState from 'react-use/lib/useSetState';
|
|
16
|
+
import useAsync from 'react-use/lib/useAsync';
|
|
17
|
+
import { CircularProgress } from '@mui/material';
|
|
15
18
|
import joinURL from 'url-join';
|
|
16
19
|
import { useDomainContext } from '../../contexts/domain';
|
|
17
20
|
import { useNodeContext } from '../../contexts/node';
|
|
@@ -22,6 +25,22 @@ import { parseDomainFromURL } from './util';
|
|
|
22
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
27
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
28
|
+
const DID_DOMAIN_SERVICE_DID = 'z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p';
|
|
29
|
+
const didDomainServiceMountPoint = async url => {
|
|
30
|
+
if (!url || !url?.trim()) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
const urlObj = new URL(url);
|
|
34
|
+
urlObj.pathname = '__blocklet__.js';
|
|
35
|
+
urlObj.searchParams.set('type', 'json');
|
|
36
|
+
const {
|
|
37
|
+
data
|
|
38
|
+
} = await axios.get(urlObj.toString());
|
|
39
|
+
const component = data?.componentMountPoints?.find(x => x.did === DID_DOMAIN_SERVICE_DID);
|
|
40
|
+
const resultUrlObj = new URL(url);
|
|
41
|
+
resultUrlObj.pathname = joinURL(component?.mountPoint || '', '/api');
|
|
42
|
+
return resultUrlObj.toString();
|
|
43
|
+
};
|
|
25
44
|
export default function AddDomain({
|
|
26
45
|
siteId,
|
|
27
46
|
teamDid,
|
|
@@ -53,9 +72,24 @@ export default function AddDomain({
|
|
|
53
72
|
showNFTDomainAuth: false,
|
|
54
73
|
showDnsTip: false
|
|
55
74
|
});
|
|
56
|
-
|
|
57
|
-
if (info.
|
|
58
|
-
|
|
75
|
+
const nftDomainURLState = useAsync(() => didDomainServiceMountPoint(info?.nftDomainUrl));
|
|
76
|
+
if (info?.nftDomainUrl && nftDomainURLState.loading) {
|
|
77
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
78
|
+
...props,
|
|
79
|
+
children: /*#__PURE__*/_jsx(Center, {
|
|
80
|
+
relative: "parent",
|
|
81
|
+
children: /*#__PURE__*/_jsx(CircularProgress, {})
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (nftDomainURLState.error) {
|
|
86
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
87
|
+
...props,
|
|
88
|
+
children: /*#__PURE__*/_jsx(Center, {
|
|
89
|
+
relative: "parent",
|
|
90
|
+
children: nftDomainURLState.error.message
|
|
91
|
+
})
|
|
92
|
+
});
|
|
59
93
|
}
|
|
60
94
|
const handleAuthSuccess = async ({
|
|
61
95
|
domain,
|
|
@@ -97,6 +131,7 @@ export default function AddDomain({
|
|
|
97
131
|
};
|
|
98
132
|
const error = domainContext.error || state.error; // TODO: state error 可能不需要了
|
|
99
133
|
|
|
134
|
+
const nftDomainURL = nftDomainURLState.value;
|
|
100
135
|
const domainTypes = {
|
|
101
136
|
inputDomain: {
|
|
102
137
|
name: t('router.domainAlias.inputDomain'),
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = AddDomain;
|
|
7
7
|
var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
|
|
8
8
|
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
9
|
+
var _Center = _interopRequireDefault(require("@arcblock/ux/lib/Center"));
|
|
9
10
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
11
|
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
11
12
|
var _InfoOutlined = _interopRequireDefault(require("@mui/icons-material/InfoOutlined"));
|
|
@@ -18,6 +19,8 @@ var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
|
18
19
|
var _trim = _interopRequireDefault(require("lodash/trim"));
|
|
19
20
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
20
21
|
var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
|
|
22
|
+
var _useAsync = _interopRequireDefault(require("react-use/lib/useAsync"));
|
|
23
|
+
var _material = require("@mui/material");
|
|
21
24
|
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
22
25
|
var _domain = require("../../contexts/domain");
|
|
23
26
|
var _node = require("../../contexts/node");
|
|
@@ -35,6 +38,23 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
35
38
|
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); }
|
|
36
39
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
37
40
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
41
|
+
const DID_DOMAIN_SERVICE_DID = 'z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p';
|
|
42
|
+
const didDomainServiceMountPoint = async url => {
|
|
43
|
+
var _data$componentMountP;
|
|
44
|
+
if (!url || !(url !== null && url !== void 0 && url.trim())) {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
const urlObj = new URL(url);
|
|
48
|
+
urlObj.pathname = '__blocklet__.js';
|
|
49
|
+
urlObj.searchParams.set('type', 'json');
|
|
50
|
+
const {
|
|
51
|
+
data
|
|
52
|
+
} = await _api.axios.get(urlObj.toString());
|
|
53
|
+
const component = data === null || data === void 0 ? void 0 : (_data$componentMountP = data.componentMountPoints) === null || _data$componentMountP === void 0 ? void 0 : _data$componentMountP.find(x => x.did === DID_DOMAIN_SERVICE_DID);
|
|
54
|
+
const resultUrlObj = new URL(url);
|
|
55
|
+
resultUrlObj.pathname = (0, _urlJoin.default)((component === null || component === void 0 ? void 0 : component.mountPoint) || '', '/api');
|
|
56
|
+
return resultUrlObj.toString();
|
|
57
|
+
};
|
|
38
58
|
function AddDomain(_ref) {
|
|
39
59
|
let {
|
|
40
60
|
siteId,
|
|
@@ -67,9 +87,22 @@ function AddDomain(_ref) {
|
|
|
67
87
|
showNFTDomainAuth: false,
|
|
68
88
|
showDnsTip: false
|
|
69
89
|
});
|
|
70
|
-
|
|
71
|
-
if (info.nftDomainUrl) {
|
|
72
|
-
|
|
90
|
+
const nftDomainURLState = (0, _useAsync.default)(() => didDomainServiceMountPoint(info === null || info === void 0 ? void 0 : info.nftDomainUrl));
|
|
91
|
+
if (info !== null && info !== void 0 && info.nftDomainUrl && nftDomainURLState.loading) {
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, _objectSpread(_objectSpread({}, props), {}, {
|
|
93
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Center.default, {
|
|
94
|
+
relative: "parent",
|
|
95
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
|
|
96
|
+
})
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
if (nftDomainURLState.error) {
|
|
100
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, _objectSpread(_objectSpread({}, props), {}, {
|
|
101
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Center.default, {
|
|
102
|
+
relative: "parent",
|
|
103
|
+
children: nftDomainURLState.error.message
|
|
104
|
+
})
|
|
105
|
+
}));
|
|
73
106
|
}
|
|
74
107
|
const handleAuthSuccess = async _ref2 => {
|
|
75
108
|
let {
|
|
@@ -112,6 +145,7 @@ function AddDomain(_ref) {
|
|
|
112
145
|
};
|
|
113
146
|
const error = domainContext.error || state.error; // TODO: state error 可能不需要了
|
|
114
147
|
|
|
148
|
+
const nftDomainURL = nftDomainURLState.value;
|
|
115
149
|
const domainTypes = {
|
|
116
150
|
inputDomain: {
|
|
117
151
|
name: t('router.domainAlias.inputDomain'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.22-beta-
|
|
3
|
+
"version": "1.16.22-beta-5bf86cd3",
|
|
4
4
|
"description": "UX components shared across abtnode packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,23 +27,23 @@
|
|
|
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.22-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.22-beta-
|
|
32
|
-
"@abtnode/util": "1.16.22-beta-
|
|
30
|
+
"@abtnode/auth": "1.16.22-beta-5bf86cd3",
|
|
31
|
+
"@abtnode/constant": "1.16.22-beta-5bf86cd3",
|
|
32
|
+
"@abtnode/util": "1.16.22-beta-5bf86cd3",
|
|
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.13",
|
|
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.22-beta-
|
|
37
|
+
"@arcblock/icons": "^2.9.13",
|
|
38
|
+
"@arcblock/nft-display": "2.9.13",
|
|
39
|
+
"@arcblock/react-hooks": "^2.9.13",
|
|
40
|
+
"@arcblock/terminal": "^2.9.13",
|
|
41
|
+
"@arcblock/ux": "^2.9.13",
|
|
42
|
+
"@blocklet/constant": "1.16.22-beta-5bf86cd3",
|
|
43
43
|
"@blocklet/launcher-layout": "2.2.51",
|
|
44
|
-
"@blocklet/list": "^0.12.
|
|
45
|
-
"@blocklet/meta": "1.16.22-beta-
|
|
46
|
-
"@blocklet/ui-react": "^2.9.
|
|
44
|
+
"@blocklet/list": "^0.12.65",
|
|
45
|
+
"@blocklet/meta": "1.16.22-beta-5bf86cd3",
|
|
46
|
+
"@blocklet/ui-react": "^2.9.13",
|
|
47
47
|
"@blocklet/uploader": "^0.0.64",
|
|
48
48
|
"@emotion/react": "^11.10.4",
|
|
49
49
|
"@emotion/styled": "^11.10.4",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"babel-plugin-inline-react-svg": "^1.1.2",
|
|
103
103
|
"glob": "^10.3.3"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "5cac513901c247011be421fb8428d7875f475b0f",
|
|
106
106
|
"exports": {
|
|
107
107
|
".": {
|
|
108
108
|
"import": "./es/index.js",
|