@abtnode/ux 1.16.22-beta-5bf86cd3 → 1.16.22-beta-87e027a7

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,3 +1,4 @@
1
+ import { getDidDomainServiceURL } from '@abtnode/util/lib/did-domain';
1
2
  import Connect from '@arcblock/did-connect/lib/Connect';
2
3
  import Button from '@arcblock/ux/lib/Button';
3
4
  import Center from '@arcblock/ux/lib/Center';
@@ -15,7 +16,6 @@ import PropTypes from 'prop-types';
15
16
  import useSetState from 'react-use/lib/useSetState';
16
17
  import useAsync from 'react-use/lib/useAsync';
17
18
  import { CircularProgress } from '@mui/material';
18
- import joinURL from 'url-join';
19
19
  import { useDomainContext } from '../../contexts/domain';
20
20
  import { useNodeContext } from '../../contexts/node';
21
21
  import { sleep, validateDomain } from '../../util';
@@ -25,22 +25,6 @@ import { parseDomainFromURL } from './util';
25
25
  import { jsx as _jsx } from "react/jsx-runtime";
26
26
  import { jsxs as _jsxs } from "react/jsx-runtime";
27
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
- };
44
28
  export default function AddDomain({
45
29
  siteId,
46
30
  teamDid,
@@ -72,7 +56,7 @@ export default function AddDomain({
72
56
  showNFTDomainAuth: false,
73
57
  showDnsTip: false
74
58
  });
75
- const nftDomainURLState = useAsync(() => didDomainServiceMountPoint(info?.nftDomainUrl));
59
+ const nftDomainURLState = useAsync(() => getDidDomainServiceURL(info?.nftDomainUrl));
76
60
  if (info?.nftDomainUrl && nftDomainURLState.loading) {
77
61
  return /*#__PURE__*/_jsx(Box, {
78
62
  ...props,
@@ -131,7 +115,7 @@ export default function AddDomain({
131
115
  };
132
116
  const error = domainContext.error || state.error; // TODO: state error 可能不需要了
133
117
 
134
- const nftDomainURL = nftDomainURLState.value;
118
+ const nftDomainService = nftDomainURLState.value;
135
119
  const domainTypes = {
136
120
  inputDomain: {
137
121
  name: t('router.domainAlias.inputDomain'),
@@ -199,7 +183,7 @@ export default function AddDomain({
199
183
  })
200
184
  }
201
185
  };
202
- if (info?.nftDomainUrl) {
186
+ if (info?.nftDomainUrl && nftDomainService) {
203
187
  domainTypes.nftDomain = {
204
188
  name: t('router.domainAlias.nftDomain'),
205
189
  component: /*#__PURE__*/_jsxs(_Fragment, {
@@ -213,7 +197,7 @@ export default function AddDomain({
213
197
  children: t('router.domainAlias.addDomainNFT.tips')
214
198
  }), /*#__PURE__*/_jsxs("div", {
215
199
  children: [t('router.domainAlias.addDomainNFT.buyTip'), /*#__PURE__*/_jsxs(Link, {
216
- href: info.nftDomainUrl,
200
+ href: nftDomainService.base,
217
201
  sx: {
218
202
  fontSize: '14px',
219
203
  display: 'inline-flex',
@@ -242,9 +226,9 @@ export default function AddDomain({
242
226
  popup: true,
243
227
  useSocket: false,
244
228
  action: "authorize",
245
- baseUrl: nftDomainURL,
229
+ baseUrl: nftDomainService.api,
246
230
  checkFn: axios.create({
247
- baseURL: nftDomainURL
231
+ baseURL: nftDomainService.api
248
232
  }).get,
249
233
  extraParams: {
250
234
  delegatee: appId,
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = AddDomain;
7
+ var _didDomain = require("@abtnode/util/lib/did-domain");
7
8
  var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
8
9
  var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
9
10
  var _Center = _interopRequireDefault(require("@arcblock/ux/lib/Center"));
@@ -21,7 +22,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
21
22
  var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
22
23
  var _useAsync = _interopRequireDefault(require("react-use/lib/useAsync"));
23
24
  var _material = require("@mui/material");
24
- var _urlJoin = _interopRequireDefault(require("url-join"));
25
25
  var _domain = require("../../contexts/domain");
26
26
  var _node = require("../../contexts/node");
27
27
  var _util = require("../../util");
@@ -38,23 +38,6 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
38
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); }
39
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; }
40
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
- };
58
41
  function AddDomain(_ref) {
59
42
  let {
60
43
  siteId,
@@ -87,7 +70,7 @@ function AddDomain(_ref) {
87
70
  showNFTDomainAuth: false,
88
71
  showDnsTip: false
89
72
  });
90
- const nftDomainURLState = (0, _useAsync.default)(() => didDomainServiceMountPoint(info === null || info === void 0 ? void 0 : info.nftDomainUrl));
73
+ const nftDomainURLState = (0, _useAsync.default)(() => (0, _didDomain.getDidDomainServiceURL)(info === null || info === void 0 ? void 0 : info.nftDomainUrl));
91
74
  if (info !== null && info !== void 0 && info.nftDomainUrl && nftDomainURLState.loading) {
92
75
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, _objectSpread(_objectSpread({}, props), {}, {
93
76
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Center.default, {
@@ -145,7 +128,7 @@ function AddDomain(_ref) {
145
128
  };
146
129
  const error = domainContext.error || state.error; // TODO: state error 可能不需要了
147
130
 
148
- const nftDomainURL = nftDomainURLState.value;
131
+ const nftDomainService = nftDomainURLState.value;
149
132
  const domainTypes = {
150
133
  inputDomain: {
151
134
  name: t('router.domainAlias.inputDomain'),
@@ -214,7 +197,7 @@ function AddDomain(_ref) {
214
197
  })
215
198
  }
216
199
  };
217
- if (info !== null && info !== void 0 && info.nftDomainUrl) {
200
+ if (info !== null && info !== void 0 && info.nftDomainUrl && nftDomainService) {
218
201
  domainTypes.nftDomain = {
219
202
  name: t('router.domainAlias.nftDomain'),
220
203
  component: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
@@ -228,7 +211,7 @@ function AddDomain(_ref) {
228
211
  children: t('router.domainAlias.addDomainNFT.tips')
229
212
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
230
213
  children: [t('router.domainAlias.addDomainNFT.buyTip'), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Link.default, {
231
- href: info.nftDomainUrl,
214
+ href: nftDomainService.base,
232
215
  sx: {
233
216
  fontSize: '14px',
234
217
  display: 'inline-flex',
@@ -257,9 +240,9 @@ function AddDomain(_ref) {
257
240
  popup: true,
258
241
  useSocket: false,
259
242
  action: "authorize",
260
- baseUrl: nftDomainURL,
243
+ baseUrl: nftDomainService.api,
261
244
  checkFn: _api.axios.create({
262
- baseURL: nftDomainURL
245
+ baseURL: nftDomainService.api
263
246
  }).get,
264
247
  extraParams: {
265
248
  delegatee: appId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.22-beta-5bf86cd3",
3
+ "version": "1.16.22-beta-87e027a7",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -27,9 +27,9 @@
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-5bf86cd3",
31
- "@abtnode/constant": "1.16.22-beta-5bf86cd3",
32
- "@abtnode/util": "1.16.22-beta-5bf86cd3",
30
+ "@abtnode/auth": "1.16.22-beta-87e027a7",
31
+ "@abtnode/constant": "1.16.22-beta-87e027a7",
32
+ "@abtnode/util": "1.16.22-beta-87e027a7",
33
33
  "@ahooksjs/use-url-state": "^3.5.1",
34
34
  "@arcblock/did": "^1.18.108",
35
35
  "@arcblock/did-connect": "^2.9.13",
@@ -39,10 +39,10 @@
39
39
  "@arcblock/react-hooks": "^2.9.13",
40
40
  "@arcblock/terminal": "^2.9.13",
41
41
  "@arcblock/ux": "^2.9.13",
42
- "@blocklet/constant": "1.16.22-beta-5bf86cd3",
42
+ "@blocklet/constant": "1.16.22-beta-87e027a7",
43
43
  "@blocklet/launcher-layout": "2.2.51",
44
44
  "@blocklet/list": "^0.12.65",
45
- "@blocklet/meta": "1.16.22-beta-5bf86cd3",
45
+ "@blocklet/meta": "1.16.22-beta-87e027a7",
46
46
  "@blocklet/ui-react": "^2.9.13",
47
47
  "@blocklet/uploader": "^0.0.64",
48
48
  "@emotion/react": "^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": "5cac513901c247011be421fb8428d7875f475b0f",
105
+ "gitHead": "c1b0c1d0b1d2504d4738cd5981e6e52872e4e1ce",
106
106
  "exports": {
107
107
  ".": {
108
108
  "import": "./es/index.js",