@abtnode/ux 1.16.15-beta-e3a24907 → 1.16.15-beta-18951729
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/router/action/add-domain-alias.js +4 -6
- package/es/blocklet/router/util.js +16 -0
- package/es/locales/en.js +5 -3
- package/es/locales/zh.js +5 -3
- package/es/subscription.js +23 -14
- package/es/util/index.js +20 -2
- package/lib/blocklet/router/action/add-domain-alias.js +3 -5
- package/lib/blocklet/router/util.js +19 -2
- package/lib/locales/en.js +5 -3
- package/lib/locales/zh.js +5 -3
- package/lib/subscription.js +24 -16
- package/lib/util/index.js +19 -2
- package/package.json +7 -7
|
@@ -6,11 +6,10 @@ import Typography from '@mui/material/Typography';
|
|
|
6
6
|
import TextField from '@mui/material/TextField';
|
|
7
7
|
import MenuItem from '@mui/material/MenuItem';
|
|
8
8
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
9
|
-
import Toast from '@arcblock/ux/lib/Toast';
|
|
10
9
|
import Confirm from '../../../confirm';
|
|
11
10
|
import { formatError, sleep } from '../../../util';
|
|
12
11
|
import { useNodeContext } from '../../../contexts/node';
|
|
13
|
-
import { validateDomain } from '../util';
|
|
12
|
+
import { parseDomainFromURL, validateDomain } from '../util';
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
15
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -41,15 +40,13 @@ export default function AddDomainAlias({
|
|
|
41
40
|
await api.addDomainAlias({
|
|
42
41
|
input: {
|
|
43
42
|
id,
|
|
44
|
-
domainAlias: params.domain
|
|
43
|
+
domainAlias: parseDomainFromURL(params.domain),
|
|
45
44
|
teamDid
|
|
46
45
|
}
|
|
47
46
|
});
|
|
48
47
|
await sleep(2000);
|
|
49
|
-
} catch (err) {
|
|
50
|
-
Toast.error(err.message);
|
|
51
|
-
} finally {
|
|
52
48
|
setConfirmSetting(null);
|
|
49
|
+
} finally {
|
|
53
50
|
setLoading(false);
|
|
54
51
|
}
|
|
55
52
|
};
|
|
@@ -69,6 +66,7 @@ export default function AddDomainAlias({
|
|
|
69
66
|
component: "div",
|
|
70
67
|
children: /*#__PURE__*/_jsx(TextField, {
|
|
71
68
|
label: t('router.domainAlias.add.domainDescription'),
|
|
69
|
+
helperText: t('router.domainAlias.add.helperText'),
|
|
72
70
|
autoComplete: "off",
|
|
73
71
|
variant: "outlined",
|
|
74
72
|
name: "domain",
|
|
@@ -128,4 +128,20 @@ export const isSpecialDomain = name => {
|
|
|
128
128
|
specialDomains.push(window.location.hostname);
|
|
129
129
|
}
|
|
130
130
|
return specialDomains.includes(name);
|
|
131
|
+
};
|
|
132
|
+
export const parseDomainFromURL = tmpDomain => {
|
|
133
|
+
if (!tmpDomain || typeof tmpDomain !== 'string') {
|
|
134
|
+
return tmpDomain;
|
|
135
|
+
}
|
|
136
|
+
let domain = tmpDomain.trim();
|
|
137
|
+
try {
|
|
138
|
+
domain = domain.toLowerCase();
|
|
139
|
+
if (domain.startsWith('http://') || domain.startsWith('https://')) {
|
|
140
|
+
return new URL(domain).hostname;
|
|
141
|
+
}
|
|
142
|
+
return domain;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
console.error('format domain failed', error);
|
|
145
|
+
return domain;
|
|
146
|
+
}
|
|
131
147
|
};
|
package/es/locales/en.js
CHANGED
|
@@ -820,13 +820,14 @@ module.exports = {
|
|
|
820
820
|
rewriteUrlRequired: 'Rewrite URL is required'
|
|
821
821
|
},
|
|
822
822
|
domain: {
|
|
823
|
+
addSite: 'Add Site',
|
|
823
824
|
validate: {
|
|
824
825
|
emptyTip: 'Site domain cannot be empty',
|
|
825
826
|
suffixTip: 'Site domain cannot include {suffix}'
|
|
826
827
|
},
|
|
827
828
|
add: {
|
|
828
|
-
title: 'Add
|
|
829
|
-
description: 'Please provide a valid
|
|
829
|
+
title: 'Add Domain Name',
|
|
830
|
+
description: 'Please provide a valid domain name',
|
|
830
831
|
confirm: 'Add',
|
|
831
832
|
cancel: 'Cancel',
|
|
832
833
|
blocklet: 'Select Blocklet',
|
|
@@ -861,7 +862,8 @@ module.exports = {
|
|
|
861
862
|
add: {
|
|
862
863
|
title: 'Add Additional Domain',
|
|
863
864
|
domainDescription: 'Please provide a valid domain name',
|
|
864
|
-
forceTip: 'Force add if domain name already exists'
|
|
865
|
+
forceTip: 'Force add if domain name already exists',
|
|
866
|
+
helperText: 'If an HTTP or HTTPS URL is entered, it will be automatically converted into a domain name.'
|
|
865
867
|
},
|
|
866
868
|
delete: {
|
|
867
869
|
title: 'Delete',
|
package/es/locales/zh.js
CHANGED
|
@@ -823,13 +823,14 @@ module.exports = {
|
|
|
823
823
|
rewriteUrlRequired: '重写到 URL 是必填的'
|
|
824
824
|
},
|
|
825
825
|
domain: {
|
|
826
|
+
addSite: '添加站点',
|
|
826
827
|
validate: {
|
|
827
828
|
emptyTip: '站点域名不能为空',
|
|
828
829
|
suffixTip: '站点域名不能包含 {suffix}'
|
|
829
830
|
},
|
|
830
831
|
add: {
|
|
831
|
-
title: '
|
|
832
|
-
description: '
|
|
832
|
+
title: '添加域名',
|
|
833
|
+
description: '请填写你所拥有的合法的域名',
|
|
833
834
|
confirm: '添加',
|
|
834
835
|
cancel: '取消',
|
|
835
836
|
blocklet: '选择基石程序',
|
|
@@ -864,7 +865,8 @@ module.exports = {
|
|
|
864
865
|
add: {
|
|
865
866
|
title: '添加额外域名',
|
|
866
867
|
domainDescription: '请填写有效的域名',
|
|
867
|
-
forceTip: '当域名已存在时强制添加'
|
|
868
|
+
forceTip: '当域名已存在时强制添加',
|
|
869
|
+
helperText: '如果输入 HTTP 或者 HTTPS URL, 则会被自动转换为域名。'
|
|
868
870
|
},
|
|
869
871
|
delete: {
|
|
870
872
|
title: '删除',
|
package/es/subscription.js
CHANGED
|
@@ -15,6 +15,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
15
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
16
|
const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
|
|
17
17
|
function Subscription({
|
|
18
|
+
launcherUrl,
|
|
18
19
|
chainHost,
|
|
19
20
|
nftId,
|
|
20
21
|
retention,
|
|
@@ -33,8 +34,18 @@ function Subscription({
|
|
|
33
34
|
sx = {},
|
|
34
35
|
...rest
|
|
35
36
|
} = props;
|
|
36
|
-
const
|
|
37
|
-
|
|
37
|
+
const asyncState = useAsyncRetry(async () => {
|
|
38
|
+
const [asset, subscriptionURL] = await Promise.all([getAsset(chainHost, nftId), getSubscriptionURL({
|
|
39
|
+
launcherUrl,
|
|
40
|
+
nftId,
|
|
41
|
+
locale
|
|
42
|
+
})]);
|
|
43
|
+
return {
|
|
44
|
+
asset,
|
|
45
|
+
subscriptionURL
|
|
46
|
+
};
|
|
47
|
+
}, [locale]);
|
|
48
|
+
if (asyncState.loading) {
|
|
38
49
|
return /*#__PURE__*/_jsxs(Box, {
|
|
39
50
|
sx: {
|
|
40
51
|
display: 'flex',
|
|
@@ -49,8 +60,8 @@ function Subscription({
|
|
|
49
60
|
}), t('expiration.loading')]
|
|
50
61
|
});
|
|
51
62
|
}
|
|
52
|
-
if (
|
|
53
|
-
console.error(
|
|
63
|
+
if (asyncState.error) {
|
|
64
|
+
console.error(asyncState.error);
|
|
54
65
|
return /*#__PURE__*/_jsx(Chip, {
|
|
55
66
|
label: t('expiration.loadFailed'),
|
|
56
67
|
color: "error",
|
|
@@ -60,11 +71,10 @@ function Subscription({
|
|
|
60
71
|
...sx
|
|
61
72
|
},
|
|
62
73
|
...rest,
|
|
63
|
-
onClick: () =>
|
|
74
|
+
onClick: () => asyncState.retry()
|
|
64
75
|
});
|
|
65
76
|
}
|
|
66
|
-
const expirationDate = getAssetExpiration(
|
|
67
|
-
const launcherUrl = assetState.value?.data?.value?.launcherUrl;
|
|
77
|
+
const expirationDate = getAssetExpiration(asyncState.value?.asset);
|
|
68
78
|
const isExpired = dayjs(expirationDate).isBefore(dayjs());
|
|
69
79
|
const validityMs = dayjs(expirationDate).diff(dayjs(), 'ms');
|
|
70
80
|
let status = 'success';
|
|
@@ -122,11 +132,7 @@ function Subscription({
|
|
|
122
132
|
style: {
|
|
123
133
|
border: 0
|
|
124
134
|
},
|
|
125
|
-
src:
|
|
126
|
-
launcherUrl,
|
|
127
|
-
nftId,
|
|
128
|
-
locale
|
|
129
|
-
})
|
|
135
|
+
src: asyncState.value?.subscriptionURL
|
|
130
136
|
})
|
|
131
137
|
})]
|
|
132
138
|
});
|
|
@@ -135,10 +141,13 @@ Subscription.propTypes = {
|
|
|
135
141
|
chainHost: PropTypes.string.isRequired,
|
|
136
142
|
nftId: PropTypes.string.isRequired,
|
|
137
143
|
sx: PropTypes.object,
|
|
138
|
-
retention: PropTypes.number
|
|
144
|
+
retention: PropTypes.number,
|
|
145
|
+
launcherUrl: PropTypes.string
|
|
139
146
|
};
|
|
140
147
|
Subscription.defaultProps = {
|
|
141
148
|
sx: {},
|
|
142
|
-
retention: 0
|
|
149
|
+
retention: 0,
|
|
150
|
+
launcherUrl: 'https://launcher.arcblock.io/' // 兼容: 旧版本的 blocklet.controller 没有 launcherUrl 字段
|
|
143
151
|
};
|
|
152
|
+
|
|
144
153
|
export default Subscription;
|
package/es/util/index.js
CHANGED
|
@@ -590,9 +590,27 @@ export const getRenewBlockletURL = ({
|
|
|
590
590
|
nftId = '',
|
|
591
591
|
locale = 'en'
|
|
592
592
|
}) => joinUrl(launcherUrl, `/instances/${nftId}/renewal?locale=${locale}&return-url=${encodeURIComponent(window.location.href)}`);
|
|
593
|
-
export const getSubscriptionURL = ({
|
|
593
|
+
export const getSubscriptionURL = async ({
|
|
594
594
|
launcherUrl = '',
|
|
595
595
|
nftId = '',
|
|
596
596
|
locale = 'en'
|
|
597
|
-
}) =>
|
|
597
|
+
}) => {
|
|
598
|
+
if (!launcherUrl) {
|
|
599
|
+
return '';
|
|
600
|
+
}
|
|
601
|
+
let baseUrl = joinUrl(launcherUrl, '/instances');
|
|
602
|
+
try {
|
|
603
|
+
const {
|
|
604
|
+
data: appMeta
|
|
605
|
+
} = await axios.get(joinUrl(launcherUrl, '__blocklet__.js?type=json'), {
|
|
606
|
+
timeout: 5000
|
|
607
|
+
});
|
|
608
|
+
const mountPoint = appMeta.componentMountPoints?.find(item => item.did === 'z8iZy4P83i6AgnNdNUexsh2kBcsDHoqcwPavn');
|
|
609
|
+
const launcherUrlObj = new URL(launcherUrl);
|
|
610
|
+
baseUrl = joinUrl(launcherUrlObj.origin, mountPoint?.mountPoint, '/nfts');
|
|
611
|
+
} catch (error) {
|
|
612
|
+
console.error(error);
|
|
613
|
+
}
|
|
614
|
+
return joinUrl(baseUrl, `/${nftId}/subscription?locale=${locale}&return-url=${encodeURIComponent(window.location.href)}`);
|
|
615
|
+
};
|
|
598
616
|
export const nanoid = (length = 16) => [...Array(length)].map(() => Math.random().toString(36)[2]).join('');
|
|
@@ -12,7 +12,6 @@ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
|
12
12
|
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
13
13
|
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
14
14
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
15
|
-
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
16
15
|
var _confirm = _interopRequireDefault(require("../../../confirm"));
|
|
17
16
|
var _util = require("../../../util");
|
|
18
17
|
var _node = require("../../../contexts/node");
|
|
@@ -52,15 +51,13 @@ function AddDomainAlias(_ref) {
|
|
|
52
51
|
await api.addDomainAlias({
|
|
53
52
|
input: {
|
|
54
53
|
id,
|
|
55
|
-
domainAlias: params.domain
|
|
54
|
+
domainAlias: (0, _util2.parseDomainFromURL)(params.domain),
|
|
56
55
|
teamDid
|
|
57
56
|
}
|
|
58
57
|
});
|
|
59
58
|
await (0, _util.sleep)(2000);
|
|
60
|
-
} catch (err) {
|
|
61
|
-
_Toast.default.error(err.message);
|
|
62
|
-
} finally {
|
|
63
59
|
setConfirmSetting(null);
|
|
60
|
+
} finally {
|
|
64
61
|
setLoading(false);
|
|
65
62
|
}
|
|
66
63
|
};
|
|
@@ -80,6 +77,7 @@ function AddDomainAlias(_ref) {
|
|
|
80
77
|
component: "div",
|
|
81
78
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
|
|
82
79
|
label: t('router.domainAlias.add.domainDescription'),
|
|
80
|
+
helperText: t('router.domainAlias.add.helperText'),
|
|
83
81
|
autoComplete: "off",
|
|
84
82
|
variant: "outlined",
|
|
85
83
|
name: "domain",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.validateSite = exports.validateRule = exports.validatePathPrefix = exports.validateDomain = exports.isSpecialDomain = exports.getInitialBlockletDid = void 0;
|
|
6
|
+
exports.validateSite = exports.validateRule = exports.validatePathPrefix = exports.validateDomain = exports.parseDomainFromURL = exports.isSpecialDomain = exports.getInitialBlockletDid = void 0;
|
|
7
7
|
var _constant = require("@abtnode/constant");
|
|
8
8
|
var _isPathPrefixEqual = _interopRequireDefault(require("@abtnode/util/lib/is-path-prefix-equal"));
|
|
9
9
|
var _constant2 = require("@blocklet/constant");
|
|
@@ -143,4 +143,21 @@ const isSpecialDomain = name => {
|
|
|
143
143
|
}
|
|
144
144
|
return specialDomains.includes(name);
|
|
145
145
|
};
|
|
146
|
-
exports.isSpecialDomain = isSpecialDomain;
|
|
146
|
+
exports.isSpecialDomain = isSpecialDomain;
|
|
147
|
+
const parseDomainFromURL = tmpDomain => {
|
|
148
|
+
if (!tmpDomain || typeof tmpDomain !== 'string') {
|
|
149
|
+
return tmpDomain;
|
|
150
|
+
}
|
|
151
|
+
let domain = tmpDomain.trim();
|
|
152
|
+
try {
|
|
153
|
+
domain = domain.toLowerCase();
|
|
154
|
+
if (domain.startsWith('http://') || domain.startsWith('https://')) {
|
|
155
|
+
return new URL(domain).hostname;
|
|
156
|
+
}
|
|
157
|
+
return domain;
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.error('format domain failed', error);
|
|
160
|
+
return domain;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
exports.parseDomainFromURL = parseDomainFromURL;
|
package/lib/locales/en.js
CHANGED
|
@@ -822,13 +822,14 @@ module.exports = {
|
|
|
822
822
|
rewriteUrlRequired: 'Rewrite URL is required'
|
|
823
823
|
},
|
|
824
824
|
domain: {
|
|
825
|
+
addSite: 'Add Site',
|
|
825
826
|
validate: {
|
|
826
827
|
emptyTip: 'Site domain cannot be empty',
|
|
827
828
|
suffixTip: 'Site domain cannot include {suffix}'
|
|
828
829
|
},
|
|
829
830
|
add: {
|
|
830
|
-
title: 'Add
|
|
831
|
-
description: 'Please provide a valid
|
|
831
|
+
title: 'Add Domain Name',
|
|
832
|
+
description: 'Please provide a valid domain name',
|
|
832
833
|
confirm: 'Add',
|
|
833
834
|
cancel: 'Cancel',
|
|
834
835
|
blocklet: 'Select Blocklet',
|
|
@@ -863,7 +864,8 @@ module.exports = {
|
|
|
863
864
|
add: {
|
|
864
865
|
title: 'Add Additional Domain',
|
|
865
866
|
domainDescription: 'Please provide a valid domain name',
|
|
866
|
-
forceTip: 'Force add if domain name already exists'
|
|
867
|
+
forceTip: 'Force add if domain name already exists',
|
|
868
|
+
helperText: 'If an HTTP or HTTPS URL is entered, it will be automatically converted into a domain name.'
|
|
867
869
|
},
|
|
868
870
|
delete: {
|
|
869
871
|
title: 'Delete',
|
package/lib/locales/zh.js
CHANGED
|
@@ -825,13 +825,14 @@ module.exports = {
|
|
|
825
825
|
rewriteUrlRequired: '重写到 URL 是必填的'
|
|
826
826
|
},
|
|
827
827
|
domain: {
|
|
828
|
+
addSite: '添加站点',
|
|
828
829
|
validate: {
|
|
829
830
|
emptyTip: '站点域名不能为空',
|
|
830
831
|
suffixTip: '站点域名不能包含 {suffix}'
|
|
831
832
|
},
|
|
832
833
|
add: {
|
|
833
|
-
title: '
|
|
834
|
-
description: '
|
|
834
|
+
title: '添加域名',
|
|
835
|
+
description: '请填写你所拥有的合法的域名',
|
|
835
836
|
confirm: '添加',
|
|
836
837
|
cancel: '取消',
|
|
837
838
|
blocklet: '选择基石程序',
|
|
@@ -866,7 +867,8 @@ module.exports = {
|
|
|
866
867
|
add: {
|
|
867
868
|
title: '添加额外域名',
|
|
868
869
|
domainDescription: '请填写有效的域名',
|
|
869
|
-
forceTip: '当域名已存在时强制添加'
|
|
870
|
+
forceTip: '当域名已存在时强制添加',
|
|
871
|
+
helperText: '如果输入 HTTP 或者 HTTPS URL, 则会被自动转换为域名。'
|
|
870
872
|
},
|
|
871
873
|
delete: {
|
|
872
874
|
title: '删除',
|
package/lib/subscription.js
CHANGED
|
@@ -17,7 +17,7 @@ var _useAsyncRetry = _interopRequireDefault(require("react-use/lib/useAsyncRetry
|
|
|
17
17
|
var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
|
|
18
18
|
var _util = require("./util");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
const _excluded = ["chainHost", "nftId", "retention"],
|
|
20
|
+
const _excluded = ["launcherUrl", "chainHost", "nftId", "retention"],
|
|
21
21
|
_excluded2 = ["sx"];
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
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; }
|
|
@@ -29,8 +29,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
29
29
|
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; }
|
|
30
30
|
const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
|
|
31
31
|
function Subscription(_ref) {
|
|
32
|
-
var
|
|
32
|
+
var _asyncState$value, _asyncState$value2;
|
|
33
33
|
let {
|
|
34
|
+
launcherUrl,
|
|
34
35
|
chainHost,
|
|
35
36
|
nftId,
|
|
36
37
|
retention
|
|
@@ -49,8 +50,18 @@ function Subscription(_ref) {
|
|
|
49
50
|
sx = {}
|
|
50
51
|
} = props,
|
|
51
52
|
rest = _objectWithoutProperties(props, _excluded2);
|
|
52
|
-
const
|
|
53
|
-
|
|
53
|
+
const asyncState = (0, _useAsyncRetry.default)(async () => {
|
|
54
|
+
const [asset, subscriptionURL] = await Promise.all([(0, _util.getAsset)(chainHost, nftId), (0, _util.getSubscriptionURL)({
|
|
55
|
+
launcherUrl,
|
|
56
|
+
nftId,
|
|
57
|
+
locale
|
|
58
|
+
})]);
|
|
59
|
+
return {
|
|
60
|
+
asset,
|
|
61
|
+
subscriptionURL
|
|
62
|
+
};
|
|
63
|
+
}, [locale]);
|
|
64
|
+
if (asyncState.loading) {
|
|
54
65
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, _objectSpread(_objectSpread({
|
|
55
66
|
sx: _objectSpread({
|
|
56
67
|
display: 'flex',
|
|
@@ -64,8 +75,8 @@ function Subscription(_ref) {
|
|
|
64
75
|
}), t('expiration.loading')]
|
|
65
76
|
}));
|
|
66
77
|
}
|
|
67
|
-
if (
|
|
68
|
-
console.error(
|
|
78
|
+
if (asyncState.error) {
|
|
79
|
+
console.error(asyncState.error);
|
|
69
80
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
70
81
|
label: t('expiration.loadFailed'),
|
|
71
82
|
color: "error",
|
|
@@ -74,11 +85,10 @@ function Subscription(_ref) {
|
|
|
74
85
|
cursor: 'pointer'
|
|
75
86
|
}, sx)
|
|
76
87
|
}, rest), {}, {
|
|
77
|
-
onClick: () =>
|
|
88
|
+
onClick: () => asyncState.retry()
|
|
78
89
|
}));
|
|
79
90
|
}
|
|
80
|
-
const expirationDate = (0, _util.getAssetExpiration)(
|
|
81
|
-
const launcherUrl = (_assetState$value = assetState.value) === null || _assetState$value === void 0 ? void 0 : (_assetState$value$dat = _assetState$value.data) === null || _assetState$value$dat === void 0 ? void 0 : (_assetState$value$dat2 = _assetState$value$dat.value) === null || _assetState$value$dat2 === void 0 ? void 0 : _assetState$value$dat2.launcherUrl;
|
|
91
|
+
const expirationDate = (0, _util.getAssetExpiration)((_asyncState$value = asyncState.value) === null || _asyncState$value === void 0 ? void 0 : _asyncState$value.asset);
|
|
82
92
|
const isExpired = (0, _dayjs.default)(expirationDate).isBefore((0, _dayjs.default)());
|
|
83
93
|
const validityMs = (0, _dayjs.default)(expirationDate).diff((0, _dayjs.default)(), 'ms');
|
|
84
94
|
let status = 'success';
|
|
@@ -135,11 +145,7 @@ function Subscription(_ref) {
|
|
|
135
145
|
style: {
|
|
136
146
|
border: 0
|
|
137
147
|
},
|
|
138
|
-
src: (0
|
|
139
|
-
launcherUrl,
|
|
140
|
-
nftId,
|
|
141
|
-
locale
|
|
142
|
-
})
|
|
148
|
+
src: (_asyncState$value2 = asyncState.value) === null || _asyncState$value2 === void 0 ? void 0 : _asyncState$value2.subscriptionURL
|
|
143
149
|
})
|
|
144
150
|
})]
|
|
145
151
|
});
|
|
@@ -148,11 +154,13 @@ Subscription.propTypes = {
|
|
|
148
154
|
chainHost: _propTypes.default.string.isRequired,
|
|
149
155
|
nftId: _propTypes.default.string.isRequired,
|
|
150
156
|
sx: _propTypes.default.object,
|
|
151
|
-
retention: _propTypes.default.number
|
|
157
|
+
retention: _propTypes.default.number,
|
|
158
|
+
launcherUrl: _propTypes.default.string
|
|
152
159
|
};
|
|
153
160
|
Subscription.defaultProps = {
|
|
154
161
|
sx: {},
|
|
155
|
-
retention: 0
|
|
162
|
+
retention: 0,
|
|
163
|
+
launcherUrl: 'https://launcher.arcblock.io/' // 兼容: 旧版本的 blocklet.controller 没有 launcherUrl 字段
|
|
156
164
|
};
|
|
157
165
|
var _default = Subscription;
|
|
158
166
|
exports.default = _default;
|
package/lib/util/index.js
CHANGED
|
@@ -695,13 +695,30 @@ const getRenewBlockletURL = _ref7 => {
|
|
|
695
695
|
return (0, _urlJoin.default)(launcherUrl, "/instances/".concat(nftId, "/renewal?locale=").concat(locale, "&return-url=").concat(encodeURIComponent(window.location.href)));
|
|
696
696
|
};
|
|
697
697
|
exports.getRenewBlockletURL = getRenewBlockletURL;
|
|
698
|
-
const getSubscriptionURL = _ref8 => {
|
|
698
|
+
const getSubscriptionURL = async _ref8 => {
|
|
699
699
|
let {
|
|
700
700
|
launcherUrl = '',
|
|
701
701
|
nftId = '',
|
|
702
702
|
locale = 'en'
|
|
703
703
|
} = _ref8;
|
|
704
|
-
|
|
704
|
+
if (!launcherUrl) {
|
|
705
|
+
return '';
|
|
706
|
+
}
|
|
707
|
+
let baseUrl = (0, _urlJoin.default)(launcherUrl, '/instances');
|
|
708
|
+
try {
|
|
709
|
+
var _appMeta$componentMou;
|
|
710
|
+
const {
|
|
711
|
+
data: appMeta
|
|
712
|
+
} = await _axios.default.get((0, _urlJoin.default)(launcherUrl, '__blocklet__.js?type=json'), {
|
|
713
|
+
timeout: 5000
|
|
714
|
+
});
|
|
715
|
+
const mountPoint = (_appMeta$componentMou = appMeta.componentMountPoints) === null || _appMeta$componentMou === void 0 ? void 0 : _appMeta$componentMou.find(item => item.did === 'z8iZy4P83i6AgnNdNUexsh2kBcsDHoqcwPavn');
|
|
716
|
+
const launcherUrlObj = new URL(launcherUrl);
|
|
717
|
+
baseUrl = (0, _urlJoin.default)(launcherUrlObj.origin, mountPoint === null || mountPoint === void 0 ? void 0 : mountPoint.mountPoint, '/nfts');
|
|
718
|
+
} catch (error) {
|
|
719
|
+
console.error(error);
|
|
720
|
+
}
|
|
721
|
+
return (0, _urlJoin.default)(baseUrl, "/".concat(nftId, "/subscription?locale=").concat(locale, "&return-url=").concat(encodeURIComponent(window.location.href)));
|
|
705
722
|
};
|
|
706
723
|
exports.getSubscriptionURL = getSubscriptionURL;
|
|
707
724
|
const nanoid = function nanoid() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.15-beta-
|
|
3
|
+
"version": "1.16.15-beta-18951729",
|
|
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.15-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.15-beta-
|
|
32
|
-
"@abtnode/util": "1.16.15-beta-
|
|
30
|
+
"@abtnode/auth": "1.16.15-beta-18951729",
|
|
31
|
+
"@abtnode/constant": "1.16.15-beta-18951729",
|
|
32
|
+
"@abtnode/util": "1.16.15-beta-18951729",
|
|
33
33
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
34
34
|
"@arcblock/did": "^1.18.89",
|
|
35
35
|
"@arcblock/did-connect": "^2.7.6",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@arcblock/react-hooks": "^2.7.6",
|
|
40
40
|
"@arcblock/terminal": "^2.7.6",
|
|
41
41
|
"@arcblock/ux": "^2.7.6",
|
|
42
|
-
"@blocklet/constant": "1.16.15-beta-
|
|
42
|
+
"@blocklet/constant": "1.16.15-beta-18951729",
|
|
43
43
|
"@blocklet/launcher-layout": "2.1.93",
|
|
44
44
|
"@blocklet/list": "^0.12.27",
|
|
45
|
-
"@blocklet/meta": "1.16.15-beta-
|
|
45
|
+
"@blocklet/meta": "1.16.15-beta-18951729",
|
|
46
46
|
"@blocklet/ui-react": "^2.7.6",
|
|
47
47
|
"@emotion/react": "^11.10.4",
|
|
48
48
|
"@emotion/styled": "^11.10.4",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"babel-plugin-inline-react-svg": "^1.1.2",
|
|
99
99
|
"glob": "^10.3.3"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "6ba076bcc138a3b9948771deae0f723a5104f70f",
|
|
102
102
|
"exports": {
|
|
103
103
|
".": {
|
|
104
104
|
"import": "./es/index.js",
|