@abtnode/ux 1.16.25-next-be3a37f4 → 1.16.25-next-0ba03ffc
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/actions.js +8 -9
- package/es/subscription/blocklet.js +174 -0
- package/es/subscription/chip-label.js +22 -0
- package/es/{subscription.js → subscription/server.js} +23 -28
- package/es/util/index.js +42 -5
- package/lib/blocklet/actions.js +8 -9
- package/lib/subscription/blocklet.js +186 -0
- package/lib/subscription/chip-label.js +29 -0
- package/lib/{subscription.js → subscription/server.js} +29 -35
- package/lib/util/index.js +51 -13
- package/package.json +7 -7
package/es/blocklet/actions.js
CHANGED
|
@@ -22,14 +22,13 @@ import Alert from '@mui/material/Alert';
|
|
|
22
22
|
import Button from '@arcblock/ux/lib/Button';
|
|
23
23
|
import { getAppMissingConfigs, isDeletableBlocklet, hasRunnableComponent, getDisplayName, isInProgress } from '@blocklet/meta/lib/util';
|
|
24
24
|
import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
25
|
-
import { BLOCKLET_CONTROLLER_STATUS, BLOCKLET_MODES
|
|
25
|
+
import { BLOCKLET_CONTROLLER_STATUS, BLOCKLET_MODES } from '@blocklet/constant';
|
|
26
26
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
27
27
|
import { sleep, formatError, isDownloading } from '../util';
|
|
28
28
|
import { getServerUrl } from './util';
|
|
29
29
|
import { useNodeContext } from '../contexts/node';
|
|
30
30
|
import Confirm from '../confirm';
|
|
31
31
|
import Icons from './icons';
|
|
32
|
-
import { useBlockletContext } from '../contexts/blocklet';
|
|
33
32
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
33
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
34
|
export default function BlockletActions({
|
|
@@ -55,14 +54,14 @@ export default function BlockletActions({
|
|
|
55
54
|
loading: recommendedUrlLoading,
|
|
56
55
|
recommendedUrl
|
|
57
56
|
} = useBlockletUrlEvaluation(blocklet);
|
|
58
|
-
const {
|
|
59
|
-
nftState
|
|
60
|
-
} = useBlockletContext();
|
|
61
57
|
const inProgress = isInProgress(blocklet.status);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
const disableStart = blocklet?.controller?.status?.value === BLOCKLET_CONTROLLER_STATUS.suspended;
|
|
59
|
+
|
|
60
|
+
// TODO: PaymentKitV2 过期恢复后需要能立即启动
|
|
61
|
+
// if (!nftState?.expired && blocklet?.controller?.status?.reason === SUSPENDED_REASON.expired) {
|
|
62
|
+
// disableStart = false;
|
|
63
|
+
// }
|
|
64
|
+
|
|
66
65
|
const {
|
|
67
66
|
inService
|
|
68
67
|
} = node;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
2
|
+
import dayjs from '@abtnode/util/lib/dayjs';
|
|
3
|
+
import Chip from '@mui/material/Chip';
|
|
4
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
5
|
+
import Popover from '@mui/material/Popover';
|
|
6
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import prettyMs from 'pretty-ms-i18n';
|
|
9
|
+
import { useRef } from 'react';
|
|
10
|
+
import useAsyncRetry from 'react-use/lib/useAsyncRetry';
|
|
11
|
+
import useSetState from 'react-use/lib/useSetState';
|
|
12
|
+
import { useNodeContext } from '../contexts/node';
|
|
13
|
+
import { formatPrettyMsLocale, getSubscriptionUrlV2 } from '../util';
|
|
14
|
+
import ChipLabel from './chip-label';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
const DEFAULT_LAUNCHER_URL = 'https://launcher.arcblock.io/'; // 兼容: 旧版本的 blocklet.controller 没有 launcherUrl 字段
|
|
19
|
+
|
|
20
|
+
const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
|
|
21
|
+
function SubscriptionBlocklet({
|
|
22
|
+
launcherUrl,
|
|
23
|
+
chainHost,
|
|
24
|
+
nftId,
|
|
25
|
+
launcherSessionId,
|
|
26
|
+
...props
|
|
27
|
+
}) {
|
|
28
|
+
const {
|
|
29
|
+
t,
|
|
30
|
+
locale
|
|
31
|
+
} = useLocaleContext();
|
|
32
|
+
const node = useNodeContext();
|
|
33
|
+
const [state, setState] = useSetState({
|
|
34
|
+
safeIframeRef: null,
|
|
35
|
+
popoverAnchorEl: null
|
|
36
|
+
});
|
|
37
|
+
const iframeRef = useRef(null);
|
|
38
|
+
const isMobile = useMediaQuery(x => x.breakpoints.down('md'));
|
|
39
|
+
const {
|
|
40
|
+
sx = {},
|
|
41
|
+
...rest
|
|
42
|
+
} = props;
|
|
43
|
+
const typoKey = isMobile ? 'mobile' : 'desktop';
|
|
44
|
+
const asyncState = useAsyncRetry(async () => {
|
|
45
|
+
const [data, subscriptionURL] = await Promise.all([node.api.getLauncherSession({
|
|
46
|
+
input: {
|
|
47
|
+
launcherSessionId,
|
|
48
|
+
launcherUrl
|
|
49
|
+
}
|
|
50
|
+
}), getSubscriptionUrlV2({
|
|
51
|
+
launcherUrl: launcherUrl || DEFAULT_LAUNCHER_URL,
|
|
52
|
+
nftDid: nftId,
|
|
53
|
+
launcherSessionId,
|
|
54
|
+
locale
|
|
55
|
+
})]);
|
|
56
|
+
return {
|
|
57
|
+
launcherSession: data.launcherSession,
|
|
58
|
+
subscriptionURL
|
|
59
|
+
};
|
|
60
|
+
}, [locale]);
|
|
61
|
+
if (asyncState.loading) {
|
|
62
|
+
return /*#__PURE__*/_jsx(Chip, {
|
|
63
|
+
label: /*#__PURE__*/_jsxs(ChipLabel, {
|
|
64
|
+
children: [!isMobile && t('expiration.desktop.loading'), /*#__PURE__*/_jsx(CircularProgress, {
|
|
65
|
+
size: 16
|
|
66
|
+
})]
|
|
67
|
+
}),
|
|
68
|
+
variant: "success",
|
|
69
|
+
sx: {
|
|
70
|
+
cursor: 'pointer',
|
|
71
|
+
...sx
|
|
72
|
+
},
|
|
73
|
+
...rest
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (asyncState.error) {
|
|
77
|
+
console.error(asyncState.error);
|
|
78
|
+
return /*#__PURE__*/_jsx(Chip, {
|
|
79
|
+
label: /*#__PURE__*/_jsx(ChipLabel, {
|
|
80
|
+
children: t(`expiration.${typoKey}.loadFailed`)
|
|
81
|
+
}),
|
|
82
|
+
color: "error",
|
|
83
|
+
variant: "success",
|
|
84
|
+
sx: {
|
|
85
|
+
cursor: 'pointer',
|
|
86
|
+
...sx
|
|
87
|
+
},
|
|
88
|
+
...rest,
|
|
89
|
+
onClick: () => asyncState.retry()
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const handlePopoverClick = event => {
|
|
93
|
+
setState({
|
|
94
|
+
popoverAnchorEl: event.currentTarget
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const handlePopoverClose = () => {
|
|
98
|
+
setState({
|
|
99
|
+
popoverAnchorEl: null
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const launcherSession = asyncState.value?.launcherSession;
|
|
103
|
+
let status = 'success';
|
|
104
|
+
if (['expired', 'terminated'].includes(asyncState.value?.launcherSession?.statusText)) {
|
|
105
|
+
status = 'error';
|
|
106
|
+
}
|
|
107
|
+
let validity = null;
|
|
108
|
+
if (launcherSession.expirationDate && !launcherSession.subscription) {
|
|
109
|
+
const validityMs = dayjs(launcherSession.expirationDate).diff(dayjs(), 'ms');
|
|
110
|
+
validity = t(`expiration.${typoKey}.tips.${status}`, {
|
|
111
|
+
validity: prettyMs(validityMs, {
|
|
112
|
+
locale: formatPrettyMsLocale(locale),
|
|
113
|
+
compact: true,
|
|
114
|
+
verbose: true
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
if (validityMs > 0 && validityMs <= ALERT_THRESHOLD_MS) {
|
|
118
|
+
status = 'warning';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
122
|
+
children: [/*#__PURE__*/_jsx(Chip, {
|
|
123
|
+
label: /*#__PURE__*/_jsx(ChipLabel, {
|
|
124
|
+
children: validity || launcherSession?.subscription?.product?.name || t('common.subscription')
|
|
125
|
+
}),
|
|
126
|
+
color: status,
|
|
127
|
+
variant: status !== 'success' ? 'contained' : 'outlined',
|
|
128
|
+
sx: {
|
|
129
|
+
cursor: 'pointer',
|
|
130
|
+
...sx
|
|
131
|
+
},
|
|
132
|
+
...rest,
|
|
133
|
+
onClick: handlePopoverClick
|
|
134
|
+
}), /*#__PURE__*/_jsx(Popover, {
|
|
135
|
+
id: "popover-info",
|
|
136
|
+
open: Boolean(state.popoverAnchorEl),
|
|
137
|
+
anchorEl: state.popoverAnchorEl,
|
|
138
|
+
onClose: handlePopoverClose,
|
|
139
|
+
anchorOrigin: {
|
|
140
|
+
vertical: 'bottom',
|
|
141
|
+
horizontal: 'right'
|
|
142
|
+
},
|
|
143
|
+
transformOrigin: {
|
|
144
|
+
vertical: 'top',
|
|
145
|
+
horizontal: 'right'
|
|
146
|
+
},
|
|
147
|
+
children: /*#__PURE__*/_jsx("iframe", {
|
|
148
|
+
ref: iframeRef,
|
|
149
|
+
title: t('common.subscription'),
|
|
150
|
+
width: "360px",
|
|
151
|
+
height: "600px",
|
|
152
|
+
style: {
|
|
153
|
+
border: 0
|
|
154
|
+
},
|
|
155
|
+
src: asyncState.value?.subscriptionURL
|
|
156
|
+
})
|
|
157
|
+
})]
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
SubscriptionBlocklet.propTypes = {
|
|
161
|
+
chainHost: PropTypes.string.isRequired,
|
|
162
|
+
nftId: PropTypes.string,
|
|
163
|
+
launcherSessionId: PropTypes.string,
|
|
164
|
+
sx: PropTypes.object,
|
|
165
|
+
retention: PropTypes.number,
|
|
166
|
+
launcherUrl: PropTypes.string.isRequired
|
|
167
|
+
};
|
|
168
|
+
SubscriptionBlocklet.defaultProps = {
|
|
169
|
+
sx: {},
|
|
170
|
+
retention: 0,
|
|
171
|
+
nftId: '',
|
|
172
|
+
launcherSessionId: ''
|
|
173
|
+
};
|
|
174
|
+
export default SubscriptionBlocklet;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
export default function ChipLabel({
|
|
7
|
+
children
|
|
8
|
+
}) {
|
|
9
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
10
|
+
sx: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
gap: 1
|
|
14
|
+
},
|
|
15
|
+
children: [/*#__PURE__*/_jsx(AccessTimeIcon, {
|
|
16
|
+
fontSize: "small"
|
|
17
|
+
}), children]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
ChipLabel.propTypes = {
|
|
21
|
+
children: PropTypes.node.isRequired
|
|
22
|
+
};
|
|
@@ -1,43 +1,28 @@
|
|
|
1
1
|
import dayjs from '@abtnode/util/lib/dayjs';
|
|
2
2
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
-
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
|
4
|
-
import Box from '@mui/material/Box';
|
|
5
3
|
import Chip from '@mui/material/Chip';
|
|
6
4
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
7
5
|
import Popover from '@mui/material/Popover';
|
|
6
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
8
7
|
import prettyMs from 'pretty-ms-i18n';
|
|
9
8
|
import PropTypes from 'prop-types';
|
|
10
9
|
import { useRef } from 'react';
|
|
11
10
|
import useAsyncRetry from 'react-use/lib/useAsyncRetry';
|
|
12
11
|
import useSetState from 'react-use/lib/useSetState';
|
|
13
|
-
import
|
|
14
|
-
import { formatPrettyMsLocale,
|
|
12
|
+
import { useNodeContext } from '../contexts/node';
|
|
13
|
+
import { formatPrettyMsLocale, getAssetExpiration, getSubscriptionUrlV2 } from '../util';
|
|
14
|
+
import ChipLabel from './chip-label';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
18
|
const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
|
|
19
19
|
const DEFAULT_LAUNCHER_URL = 'https://launcher.arcblock.io/'; // 兼容: 旧版本的 blocklet.controller 没有 launcherUrl 字段
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
function ChipLabel({
|
|
23
|
-
children
|
|
24
|
-
}) {
|
|
25
|
-
return /*#__PURE__*/_jsxs(Box, {
|
|
26
|
-
sx: {
|
|
27
|
-
display: 'flex',
|
|
28
|
-
alignItems: 'center',
|
|
29
|
-
gap: 1
|
|
30
|
-
},
|
|
31
|
-
children: [/*#__PURE__*/_jsx(AccessTimeIcon, {
|
|
32
|
-
fontSize: "small"
|
|
33
|
-
}), children]
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function Subscription({
|
|
21
|
+
function SubscriptionServer({
|
|
37
22
|
launcherUrl,
|
|
38
23
|
chainHost,
|
|
39
24
|
nftId,
|
|
40
|
-
|
|
25
|
+
launcherSessionId,
|
|
41
26
|
...props
|
|
42
27
|
}) {
|
|
43
28
|
const {
|
|
@@ -50,15 +35,22 @@ function Subscription({
|
|
|
50
35
|
});
|
|
51
36
|
const iframeRef = useRef(null);
|
|
52
37
|
const isMobile = useMediaQuery(x => x.breakpoints.down('md'));
|
|
38
|
+
const node = useNodeContext();
|
|
53
39
|
const {
|
|
54
40
|
sx = {},
|
|
55
41
|
...rest
|
|
56
42
|
} = props;
|
|
57
43
|
const typoKey = isMobile ? 'mobile' : 'desktop';
|
|
58
44
|
const asyncState = useAsyncRetry(async () => {
|
|
59
|
-
const [asset, subscriptionURL] = await Promise.all([
|
|
45
|
+
const [asset, subscriptionURL] = await Promise.all([node.api.getLauncherSession({
|
|
46
|
+
input: {
|
|
47
|
+
launcherSessionId,
|
|
48
|
+
launcherUrl
|
|
49
|
+
}
|
|
50
|
+
}), getSubscriptionUrlV2({
|
|
60
51
|
launcherUrl: launcherUrl || DEFAULT_LAUNCHER_URL,
|
|
61
|
-
nftId,
|
|
52
|
+
nftDid: nftId,
|
|
53
|
+
launcherSessionId,
|
|
62
54
|
locale
|
|
63
55
|
})]);
|
|
64
56
|
return {
|
|
@@ -162,15 +154,18 @@ function Subscription({
|
|
|
162
154
|
})]
|
|
163
155
|
});
|
|
164
156
|
}
|
|
165
|
-
|
|
157
|
+
SubscriptionServer.propTypes = {
|
|
166
158
|
chainHost: PropTypes.string.isRequired,
|
|
167
|
-
nftId: PropTypes.string
|
|
159
|
+
nftId: PropTypes.string,
|
|
160
|
+
launcherSessionId: PropTypes.string,
|
|
168
161
|
sx: PropTypes.object,
|
|
169
162
|
retention: PropTypes.number,
|
|
170
163
|
launcherUrl: PropTypes.string.isRequired
|
|
171
164
|
};
|
|
172
|
-
|
|
165
|
+
SubscriptionServer.defaultProps = {
|
|
173
166
|
sx: {},
|
|
174
|
-
retention: 0
|
|
167
|
+
retention: 0,
|
|
168
|
+
nftId: '',
|
|
169
|
+
launcherSessionId: ''
|
|
175
170
|
};
|
|
176
|
-
export default
|
|
171
|
+
export default SubscriptionServer;
|
package/es/util/index.js
CHANGED
|
@@ -621,11 +621,25 @@ export const sortDomains = domains => {
|
|
|
621
621
|
});
|
|
622
622
|
};
|
|
623
623
|
export const formatMountPoint = value => normalizePathPrefix(urlPathFriendly(value));
|
|
624
|
-
|
|
625
|
-
launcherUrl
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
624
|
+
const getLauncherBaseURL = async launcherUrl => {
|
|
625
|
+
if (!launcherUrl) {
|
|
626
|
+
return '';
|
|
627
|
+
}
|
|
628
|
+
let baseUrl = launcherUrl;
|
|
629
|
+
try {
|
|
630
|
+
const {
|
|
631
|
+
data: appMeta
|
|
632
|
+
} = await axios.get(joinUrl(launcherUrl, '__blocklet__.js?type=json'), {
|
|
633
|
+
timeout: 5000
|
|
634
|
+
});
|
|
635
|
+
const mountPoint = appMeta.componentMountPoints?.find(item => item.did === 'z8iZkFBbrVQxZHvcWWB3Sa2TrfGmSeFz9MSU7');
|
|
636
|
+
const launcherUrlObj = new URL(launcherUrl);
|
|
637
|
+
baseUrl = joinUrl(launcherUrlObj.origin, mountPoint?.mountPoint);
|
|
638
|
+
} catch (error) {
|
|
639
|
+
console.error(error);
|
|
640
|
+
}
|
|
641
|
+
return baseUrl;
|
|
642
|
+
};
|
|
629
643
|
export const getSubscriptionURL = async ({
|
|
630
644
|
launcherUrl = '',
|
|
631
645
|
nftId = '',
|
|
@@ -649,6 +663,29 @@ export const getSubscriptionURL = async ({
|
|
|
649
663
|
}
|
|
650
664
|
return joinUrl(baseUrl, `/${nftId}/subscription?locale=${locale}&return-url=${encodeURIComponent(window.location.href)}`);
|
|
651
665
|
};
|
|
666
|
+
export const getSubscriptionUrlV2 = async ({
|
|
667
|
+
launcherUrl = '',
|
|
668
|
+
launcherSessionId = '',
|
|
669
|
+
nftDid,
|
|
670
|
+
locale = 'en'
|
|
671
|
+
}) => {
|
|
672
|
+
if (!launcherUrl) {
|
|
673
|
+
return '';
|
|
674
|
+
}
|
|
675
|
+
const baseUrl = await getLauncherBaseURL(launcherUrl);
|
|
676
|
+
return joinUrl(baseUrl, `/embed/subscription?launcherSessionId=${launcherSessionId}&nftDid=${nftDid}&locale=${locale}`); // nftDid 是兼容字段
|
|
677
|
+
};
|
|
678
|
+
export const getManageSubscriptionURL = async ({
|
|
679
|
+
launcherUrl = '',
|
|
680
|
+
launcherSessionId = '',
|
|
681
|
+
locale = 'en'
|
|
682
|
+
}) => {
|
|
683
|
+
if (!launcherUrl) {
|
|
684
|
+
return '';
|
|
685
|
+
}
|
|
686
|
+
const baseUrl = await getLauncherBaseURL(launcherUrl);
|
|
687
|
+
return joinUrl(baseUrl, `/embed/manage-subscription?launcherSessionId=${launcherSessionId}&locale=${locale}`);
|
|
688
|
+
};
|
|
652
689
|
export const nanoid = (length = 16) => [...Array(length)].map(() => Math.random().toString(36)[2]).join('');
|
|
653
690
|
export const getSystemDomains = domains => domains.filter(x => x.isProtected);
|
|
654
691
|
export const getLogoHash = logo => encodeURIComponent((logo || '').split('/').slice(-1)[0].slice(0, 7));
|
package/lib/blocklet/actions.js
CHANGED
|
@@ -33,7 +33,6 @@ var _util3 = require("./util");
|
|
|
33
33
|
var _node = require("../contexts/node");
|
|
34
34
|
var _confirm = _interopRequireDefault(require("../confirm"));
|
|
35
35
|
var _icons = _interopRequireDefault(require("./icons"));
|
|
36
|
-
var _blocklet = require("../contexts/blocklet");
|
|
37
36
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
38
37
|
var _templateObject;
|
|
39
38
|
const _excluded = ["blocklet", "onStart", "onComplete", "variant", "hasPermission", "useBlockletUrlEvaluation"];
|
|
@@ -49,7 +48,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
49
48
|
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; }
|
|
50
49
|
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; }
|
|
51
50
|
function BlockletActions(_ref) {
|
|
52
|
-
var _blocklet$controller, _blocklet$controller
|
|
51
|
+
var _blocklet$controller, _blocklet$controller$;
|
|
53
52
|
let {
|
|
54
53
|
blocklet,
|
|
55
54
|
onStart,
|
|
@@ -73,14 +72,14 @@ function BlockletActions(_ref) {
|
|
|
73
72
|
loading: recommendedUrlLoading,
|
|
74
73
|
recommendedUrl
|
|
75
74
|
} = useBlockletUrlEvaluation(blocklet);
|
|
76
|
-
const {
|
|
77
|
-
nftState
|
|
78
|
-
} = (0, _blocklet.useBlockletContext)();
|
|
79
75
|
const inProgress = (0, _util.isInProgress)(blocklet.status);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
const disableStart = (blocklet === null || blocklet === void 0 ? void 0 : (_blocklet$controller = blocklet.controller) === null || _blocklet$controller === void 0 ? void 0 : (_blocklet$controller$ = _blocklet$controller.status) === null || _blocklet$controller$ === void 0 ? void 0 : _blocklet$controller$.value) === _constant.BLOCKLET_CONTROLLER_STATUS.suspended;
|
|
77
|
+
|
|
78
|
+
// TODO: PaymentKitV2 过期恢复后需要能立即启动
|
|
79
|
+
// if (!nftState?.expired && blocklet?.controller?.status?.reason === SUSPENDED_REASON.expired) {
|
|
80
|
+
// disableStart = false;
|
|
81
|
+
// }
|
|
82
|
+
|
|
84
83
|
const {
|
|
85
84
|
inService
|
|
86
85
|
} = node;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
8
|
+
var _dayjs = _interopRequireDefault(require("@abtnode/util/lib/dayjs"));
|
|
9
|
+
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
10
|
+
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
11
|
+
var _Popover = _interopRequireDefault(require("@mui/material/Popover"));
|
|
12
|
+
var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _prettyMsI18n = _interopRequireDefault(require("pretty-ms-i18n"));
|
|
15
|
+
var _react = require("react");
|
|
16
|
+
var _useAsyncRetry = _interopRequireDefault(require("react-use/lib/useAsyncRetry"));
|
|
17
|
+
var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
|
|
18
|
+
var _node = require("../contexts/node");
|
|
19
|
+
var _util = require("../util");
|
|
20
|
+
var _chipLabel = _interopRequireDefault(require("./chip-label"));
|
|
21
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _excluded = ["launcherUrl", "chainHost", "nftId", "launcherSessionId"],
|
|
23
|
+
_excluded2 = ["sx"];
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
26
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
27
|
+
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; }
|
|
28
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
29
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
30
|
+
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; }
|
|
31
|
+
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; }
|
|
32
|
+
const DEFAULT_LAUNCHER_URL = 'https://launcher.arcblock.io/'; // 兼容: 旧版本的 blocklet.controller 没有 launcherUrl 字段
|
|
33
|
+
|
|
34
|
+
const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
|
|
35
|
+
function SubscriptionBlocklet(_ref) {
|
|
36
|
+
var _asyncState$value, _asyncState$value2, _asyncState$value2$la, _launcherSession$subs, _launcherSession$subs2, _asyncState$value3;
|
|
37
|
+
let {
|
|
38
|
+
launcherUrl,
|
|
39
|
+
chainHost,
|
|
40
|
+
nftId,
|
|
41
|
+
launcherSessionId
|
|
42
|
+
} = _ref,
|
|
43
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
44
|
+
const {
|
|
45
|
+
t,
|
|
46
|
+
locale
|
|
47
|
+
} = (0, _context.useLocaleContext)();
|
|
48
|
+
const node = (0, _node.useNodeContext)();
|
|
49
|
+
const [state, setState] = (0, _useSetState.default)({
|
|
50
|
+
safeIframeRef: null,
|
|
51
|
+
popoverAnchorEl: null
|
|
52
|
+
});
|
|
53
|
+
const iframeRef = (0, _react.useRef)(null);
|
|
54
|
+
const isMobile = (0, _useMediaQuery.default)(x => x.breakpoints.down('md'));
|
|
55
|
+
const {
|
|
56
|
+
sx = {}
|
|
57
|
+
} = props,
|
|
58
|
+
rest = _objectWithoutProperties(props, _excluded2);
|
|
59
|
+
const typoKey = isMobile ? 'mobile' : 'desktop';
|
|
60
|
+
const asyncState = (0, _useAsyncRetry.default)(async () => {
|
|
61
|
+
const [data, subscriptionURL] = await Promise.all([node.api.getLauncherSession({
|
|
62
|
+
input: {
|
|
63
|
+
launcherSessionId,
|
|
64
|
+
launcherUrl
|
|
65
|
+
}
|
|
66
|
+
}), (0, _util.getSubscriptionUrlV2)({
|
|
67
|
+
launcherUrl: launcherUrl || DEFAULT_LAUNCHER_URL,
|
|
68
|
+
nftDid: nftId,
|
|
69
|
+
launcherSessionId,
|
|
70
|
+
locale
|
|
71
|
+
})]);
|
|
72
|
+
return {
|
|
73
|
+
launcherSession: data.launcherSession,
|
|
74
|
+
subscriptionURL
|
|
75
|
+
};
|
|
76
|
+
}, [locale]);
|
|
77
|
+
if (asyncState.loading) {
|
|
78
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread({
|
|
79
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_chipLabel.default, {
|
|
80
|
+
children: [!isMobile && t('expiration.desktop.loading'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
|
|
81
|
+
size: 16
|
|
82
|
+
})]
|
|
83
|
+
}),
|
|
84
|
+
variant: "success",
|
|
85
|
+
sx: _objectSpread({
|
|
86
|
+
cursor: 'pointer'
|
|
87
|
+
}, sx)
|
|
88
|
+
}, rest));
|
|
89
|
+
}
|
|
90
|
+
if (asyncState.error) {
|
|
91
|
+
console.error(asyncState.error);
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
93
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_chipLabel.default, {
|
|
94
|
+
children: t("expiration.".concat(typoKey, ".loadFailed"))
|
|
95
|
+
}),
|
|
96
|
+
color: "error",
|
|
97
|
+
variant: "success",
|
|
98
|
+
sx: _objectSpread({
|
|
99
|
+
cursor: 'pointer'
|
|
100
|
+
}, sx)
|
|
101
|
+
}, rest), {}, {
|
|
102
|
+
onClick: () => asyncState.retry()
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
const handlePopoverClick = event => {
|
|
106
|
+
setState({
|
|
107
|
+
popoverAnchorEl: event.currentTarget
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const handlePopoverClose = () => {
|
|
111
|
+
setState({
|
|
112
|
+
popoverAnchorEl: null
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
const launcherSession = (_asyncState$value = asyncState.value) === null || _asyncState$value === void 0 ? void 0 : _asyncState$value.launcherSession;
|
|
116
|
+
let status = 'success';
|
|
117
|
+
if (['expired', 'terminated'].includes((_asyncState$value2 = asyncState.value) === null || _asyncState$value2 === void 0 ? void 0 : (_asyncState$value2$la = _asyncState$value2.launcherSession) === null || _asyncState$value2$la === void 0 ? void 0 : _asyncState$value2$la.statusText)) {
|
|
118
|
+
status = 'error';
|
|
119
|
+
}
|
|
120
|
+
let validity = null;
|
|
121
|
+
if (launcherSession.expirationDate && !launcherSession.subscription) {
|
|
122
|
+
const validityMs = (0, _dayjs.default)(launcherSession.expirationDate).diff((0, _dayjs.default)(), 'ms');
|
|
123
|
+
validity = t("expiration.".concat(typoKey, ".tips.").concat(status), {
|
|
124
|
+
validity: (0, _prettyMsI18n.default)(validityMs, {
|
|
125
|
+
locale: (0, _util.formatPrettyMsLocale)(locale),
|
|
126
|
+
compact: true,
|
|
127
|
+
verbose: true
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
if (validityMs > 0 && validityMs <= ALERT_THRESHOLD_MS) {
|
|
131
|
+
status = 'warning';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
135
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
136
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_chipLabel.default, {
|
|
137
|
+
children: validity || (launcherSession === null || launcherSession === void 0 ? void 0 : (_launcherSession$subs = launcherSession.subscription) === null || _launcherSession$subs === void 0 ? void 0 : (_launcherSession$subs2 = _launcherSession$subs.product) === null || _launcherSession$subs2 === void 0 ? void 0 : _launcherSession$subs2.name) || t('common.subscription')
|
|
138
|
+
}),
|
|
139
|
+
color: status,
|
|
140
|
+
variant: status !== 'success' ? 'contained' : 'outlined',
|
|
141
|
+
sx: _objectSpread({
|
|
142
|
+
cursor: 'pointer'
|
|
143
|
+
}, sx)
|
|
144
|
+
}, rest), {}, {
|
|
145
|
+
onClick: handlePopoverClick
|
|
146
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popover.default, {
|
|
147
|
+
id: "popover-info",
|
|
148
|
+
open: Boolean(state.popoverAnchorEl),
|
|
149
|
+
anchorEl: state.popoverAnchorEl,
|
|
150
|
+
onClose: handlePopoverClose,
|
|
151
|
+
anchorOrigin: {
|
|
152
|
+
vertical: 'bottom',
|
|
153
|
+
horizontal: 'right'
|
|
154
|
+
},
|
|
155
|
+
transformOrigin: {
|
|
156
|
+
vertical: 'top',
|
|
157
|
+
horizontal: 'right'
|
|
158
|
+
},
|
|
159
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
|
|
160
|
+
ref: iframeRef,
|
|
161
|
+
title: t('common.subscription'),
|
|
162
|
+
width: "360px",
|
|
163
|
+
height: "600px",
|
|
164
|
+
style: {
|
|
165
|
+
border: 0
|
|
166
|
+
},
|
|
167
|
+
src: (_asyncState$value3 = asyncState.value) === null || _asyncState$value3 === void 0 ? void 0 : _asyncState$value3.subscriptionURL
|
|
168
|
+
})
|
|
169
|
+
})]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
SubscriptionBlocklet.propTypes = {
|
|
173
|
+
chainHost: _propTypes.default.string.isRequired,
|
|
174
|
+
nftId: _propTypes.default.string,
|
|
175
|
+
launcherSessionId: _propTypes.default.string,
|
|
176
|
+
sx: _propTypes.default.object,
|
|
177
|
+
retention: _propTypes.default.number,
|
|
178
|
+
launcherUrl: _propTypes.default.string.isRequired
|
|
179
|
+
};
|
|
180
|
+
SubscriptionBlocklet.defaultProps = {
|
|
181
|
+
sx: {},
|
|
182
|
+
retention: 0,
|
|
183
|
+
nftId: '',
|
|
184
|
+
launcherSessionId: ''
|
|
185
|
+
};
|
|
186
|
+
var _default = exports.default = SubscriptionBlocklet;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ChipLabel;
|
|
7
|
+
var _AccessTime = _interopRequireDefault(require("@mui/icons-material/AccessTime"));
|
|
8
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function ChipLabel(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
children
|
|
15
|
+
} = _ref;
|
|
16
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
17
|
+
sx: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
gap: 1
|
|
21
|
+
},
|
|
22
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AccessTime.default, {
|
|
23
|
+
fontSize: "small"
|
|
24
|
+
}), children]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
ChipLabel.propTypes = {
|
|
28
|
+
children: _propTypes.default.node.isRequired
|
|
29
|
+
};
|
|
@@ -6,20 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _dayjs = _interopRequireDefault(require("@abtnode/util/lib/dayjs"));
|
|
8
8
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
|
-
var _AccessTime = _interopRequireDefault(require("@mui/icons-material/AccessTime"));
|
|
10
|
-
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
11
9
|
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
12
10
|
var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
|
|
13
11
|
var _Popover = _interopRequireDefault(require("@mui/material/Popover"));
|
|
12
|
+
var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
|
|
14
13
|
var _prettyMsI18n = _interopRequireDefault(require("pretty-ms-i18n"));
|
|
15
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
15
|
var _react = require("react");
|
|
17
16
|
var _useAsyncRetry = _interopRequireDefault(require("react-use/lib/useAsyncRetry"));
|
|
18
17
|
var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
|
|
19
|
-
var
|
|
20
|
-
var _util = require("
|
|
18
|
+
var _node = require("../contexts/node");
|
|
19
|
+
var _util = require("../util");
|
|
20
|
+
var _chipLabel = _interopRequireDefault(require("./chip-label"));
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["launcherUrl", "chainHost", "nftId", "
|
|
22
|
+
const _excluded = ["launcherUrl", "chainHost", "nftId", "launcherSessionId"],
|
|
23
23
|
_excluded2 = ["sx"];
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -32,31 +32,15 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
32
32
|
const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
|
|
33
33
|
const DEFAULT_LAUNCHER_URL = 'https://launcher.arcblock.io/'; // 兼容: 旧版本的 blocklet.controller 没有 launcherUrl 字段
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
function ChipLabel(_ref) {
|
|
37
|
-
let {
|
|
38
|
-
children
|
|
39
|
-
} = _ref;
|
|
40
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
41
|
-
sx: {
|
|
42
|
-
display: 'flex',
|
|
43
|
-
alignItems: 'center',
|
|
44
|
-
gap: 1
|
|
45
|
-
},
|
|
46
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AccessTime.default, {
|
|
47
|
-
fontSize: "small"
|
|
48
|
-
}), children]
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function Subscription(_ref2) {
|
|
35
|
+
function SubscriptionServer(_ref) {
|
|
52
36
|
var _asyncState$value, _asyncState$value2;
|
|
53
37
|
let {
|
|
54
38
|
launcherUrl,
|
|
55
39
|
chainHost,
|
|
56
40
|
nftId,
|
|
57
|
-
|
|
58
|
-
} =
|
|
59
|
-
props = _objectWithoutProperties(
|
|
41
|
+
launcherSessionId
|
|
42
|
+
} = _ref,
|
|
43
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
60
44
|
const {
|
|
61
45
|
t,
|
|
62
46
|
locale
|
|
@@ -67,15 +51,22 @@ function Subscription(_ref2) {
|
|
|
67
51
|
});
|
|
68
52
|
const iframeRef = (0, _react.useRef)(null);
|
|
69
53
|
const isMobile = (0, _useMediaQuery.default)(x => x.breakpoints.down('md'));
|
|
54
|
+
const node = (0, _node.useNodeContext)();
|
|
70
55
|
const {
|
|
71
56
|
sx = {}
|
|
72
57
|
} = props,
|
|
73
58
|
rest = _objectWithoutProperties(props, _excluded2);
|
|
74
59
|
const typoKey = isMobile ? 'mobile' : 'desktop';
|
|
75
60
|
const asyncState = (0, _useAsyncRetry.default)(async () => {
|
|
76
|
-
const [asset, subscriptionURL] = await Promise.all([
|
|
61
|
+
const [asset, subscriptionURL] = await Promise.all([node.api.getLauncherSession({
|
|
62
|
+
input: {
|
|
63
|
+
launcherSessionId,
|
|
64
|
+
launcherUrl
|
|
65
|
+
}
|
|
66
|
+
}), (0, _util.getSubscriptionUrlV2)({
|
|
77
67
|
launcherUrl: launcherUrl || DEFAULT_LAUNCHER_URL,
|
|
78
|
-
nftId,
|
|
68
|
+
nftDid: nftId,
|
|
69
|
+
launcherSessionId,
|
|
79
70
|
locale
|
|
80
71
|
})]);
|
|
81
72
|
return {
|
|
@@ -85,7 +76,7 @@ function Subscription(_ref2) {
|
|
|
85
76
|
}, [locale]);
|
|
86
77
|
if (asyncState.loading) {
|
|
87
78
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread({
|
|
88
|
-
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
79
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_chipLabel.default, {
|
|
89
80
|
children: [!isMobile && t('expiration.desktop.loading'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
|
|
90
81
|
size: 16
|
|
91
82
|
})]
|
|
@@ -99,7 +90,7 @@ function Subscription(_ref2) {
|
|
|
99
90
|
if (asyncState.error) {
|
|
100
91
|
console.error(asyncState.error);
|
|
101
92
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
102
|
-
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
93
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_chipLabel.default, {
|
|
103
94
|
children: t("expiration.".concat(typoKey, ".loadFailed"))
|
|
104
95
|
}),
|
|
105
96
|
color: "error",
|
|
@@ -133,7 +124,7 @@ function Subscription(_ref2) {
|
|
|
133
124
|
};
|
|
134
125
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
135
126
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
136
|
-
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
127
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_chipLabel.default, {
|
|
137
128
|
children: t("expiration.".concat(typoKey, ".tips.").concat(status), {
|
|
138
129
|
validity: (0, _prettyMsI18n.default)(validityMs, {
|
|
139
130
|
locale: (0, _util.formatPrettyMsLocale)(locale),
|
|
@@ -175,15 +166,18 @@ function Subscription(_ref2) {
|
|
|
175
166
|
})]
|
|
176
167
|
});
|
|
177
168
|
}
|
|
178
|
-
|
|
169
|
+
SubscriptionServer.propTypes = {
|
|
179
170
|
chainHost: _propTypes.default.string.isRequired,
|
|
180
|
-
nftId: _propTypes.default.string
|
|
171
|
+
nftId: _propTypes.default.string,
|
|
172
|
+
launcherSessionId: _propTypes.default.string,
|
|
181
173
|
sx: _propTypes.default.object,
|
|
182
174
|
retention: _propTypes.default.number,
|
|
183
175
|
launcherUrl: _propTypes.default.string.isRequired
|
|
184
176
|
};
|
|
185
|
-
|
|
177
|
+
SubscriptionServer.defaultProps = {
|
|
186
178
|
sx: {},
|
|
187
|
-
retention: 0
|
|
179
|
+
retention: 0,
|
|
180
|
+
nftId: '',
|
|
181
|
+
launcherSessionId: ''
|
|
188
182
|
};
|
|
189
|
-
var _default = exports.default =
|
|
183
|
+
var _default = exports.default = SubscriptionServer;
|
package/lib/util/index.js
CHANGED
|
@@ -30,7 +30,7 @@ exports.getBlockletUrl = getBlockletUrl;
|
|
|
30
30
|
exports.getBlockletUrlParams = void 0;
|
|
31
31
|
exports.getBlockletUrls = getBlockletUrls;
|
|
32
32
|
exports.getExplorerLink = getExplorerLink;
|
|
33
|
-
exports.getTransferAppLink = exports.getSystemDomains = exports.getSubscriptionURL = exports.getStoreList = exports.
|
|
33
|
+
exports.getTransferAppLink = exports.getSystemDomains = exports.getSubscriptionUrlV2 = exports.getSubscriptionURL = exports.getStoreList = exports.getPathPrefix = exports.getManageSubscriptionURL = exports.getLogoHash = exports.getIssuePassportLink = exports.getInviteLink = void 0;
|
|
34
34
|
exports.getWebWalletUrl = getWebWalletUrl;
|
|
35
35
|
exports.isNewStoreUrl = exports.isInstalling = exports.isDownloading = exports.isChrome = exports.isCertificateMatch = exports.isBlockletDev = exports.hasRequiredSteps = void 0;
|
|
36
36
|
exports.isProtectedRole = isProtectedRole;
|
|
@@ -715,33 +715,44 @@ const sortDomains = domains => {
|
|
|
715
715
|
exports.sortDomains = sortDomains;
|
|
716
716
|
const formatMountPoint = value => (0, _normalizePathPrefix.default)((0, _urlPathFriendly.default)(value));
|
|
717
717
|
exports.formatMountPoint = formatMountPoint;
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
718
|
+
const getLauncherBaseURL = async launcherUrl => {
|
|
719
|
+
if (!launcherUrl) {
|
|
720
|
+
return '';
|
|
721
|
+
}
|
|
722
|
+
let baseUrl = launcherUrl;
|
|
723
|
+
try {
|
|
724
|
+
var _appMeta$componentMou;
|
|
725
|
+
const {
|
|
726
|
+
data: appMeta
|
|
727
|
+
} = await _axios.default.get((0, _urlJoin.default)(launcherUrl, '__blocklet__.js?type=json'), {
|
|
728
|
+
timeout: 5000
|
|
729
|
+
});
|
|
730
|
+
const mountPoint = (_appMeta$componentMou = appMeta.componentMountPoints) === null || _appMeta$componentMou === void 0 ? void 0 : _appMeta$componentMou.find(item => item.did === 'z8iZkFBbrVQxZHvcWWB3Sa2TrfGmSeFz9MSU7');
|
|
731
|
+
const launcherUrlObj = new URL(launcherUrl);
|
|
732
|
+
baseUrl = (0, _urlJoin.default)(launcherUrlObj.origin, mountPoint === null || mountPoint === void 0 ? void 0 : mountPoint.mountPoint);
|
|
733
|
+
} catch (error) {
|
|
734
|
+
console.error(error);
|
|
735
|
+
}
|
|
736
|
+
return baseUrl;
|
|
725
737
|
};
|
|
726
|
-
|
|
727
|
-
const getSubscriptionURL = async _ref8 => {
|
|
738
|
+
const getSubscriptionURL = async _ref7 => {
|
|
728
739
|
let {
|
|
729
740
|
launcherUrl = '',
|
|
730
741
|
nftId = '',
|
|
731
742
|
locale = 'en'
|
|
732
|
-
} =
|
|
743
|
+
} = _ref7;
|
|
733
744
|
if (!launcherUrl) {
|
|
734
745
|
return '';
|
|
735
746
|
}
|
|
736
747
|
let baseUrl = (0, _urlJoin.default)(launcherUrl, '/instances');
|
|
737
748
|
try {
|
|
738
|
-
var _appMeta$
|
|
749
|
+
var _appMeta$componentMou2;
|
|
739
750
|
const {
|
|
740
751
|
data: appMeta
|
|
741
752
|
} = await _axios.default.get((0, _urlJoin.default)(launcherUrl, '__blocklet__.js?type=json'), {
|
|
742
753
|
timeout: 5000
|
|
743
754
|
});
|
|
744
|
-
const mountPoint = (_appMeta$
|
|
755
|
+
const mountPoint = (_appMeta$componentMou2 = appMeta.componentMountPoints) === null || _appMeta$componentMou2 === void 0 ? void 0 : _appMeta$componentMou2.find(item => item.did === 'z8iZy4P83i6AgnNdNUexsh2kBcsDHoqcwPavn');
|
|
745
756
|
const launcherUrlObj = new URL(launcherUrl);
|
|
746
757
|
baseUrl = (0, _urlJoin.default)(launcherUrlObj.origin, mountPoint === null || mountPoint === void 0 ? void 0 : mountPoint.mountPoint, '/nfts');
|
|
747
758
|
} catch (error) {
|
|
@@ -750,6 +761,33 @@ const getSubscriptionURL = async _ref8 => {
|
|
|
750
761
|
return (0, _urlJoin.default)(baseUrl, "/".concat(nftId, "/subscription?locale=").concat(locale, "&return-url=").concat(encodeURIComponent(window.location.href)));
|
|
751
762
|
};
|
|
752
763
|
exports.getSubscriptionURL = getSubscriptionURL;
|
|
764
|
+
const getSubscriptionUrlV2 = async _ref8 => {
|
|
765
|
+
let {
|
|
766
|
+
launcherUrl = '',
|
|
767
|
+
launcherSessionId = '',
|
|
768
|
+
nftDid,
|
|
769
|
+
locale = 'en'
|
|
770
|
+
} = _ref8;
|
|
771
|
+
if (!launcherUrl) {
|
|
772
|
+
return '';
|
|
773
|
+
}
|
|
774
|
+
const baseUrl = await getLauncherBaseURL(launcherUrl);
|
|
775
|
+
return (0, _urlJoin.default)(baseUrl, "/embed/subscription?launcherSessionId=".concat(launcherSessionId, "&nftDid=").concat(nftDid, "&locale=").concat(locale)); // nftDid 是兼容字段
|
|
776
|
+
};
|
|
777
|
+
exports.getSubscriptionUrlV2 = getSubscriptionUrlV2;
|
|
778
|
+
const getManageSubscriptionURL = async _ref9 => {
|
|
779
|
+
let {
|
|
780
|
+
launcherUrl = '',
|
|
781
|
+
launcherSessionId = '',
|
|
782
|
+
locale = 'en'
|
|
783
|
+
} = _ref9;
|
|
784
|
+
if (!launcherUrl) {
|
|
785
|
+
return '';
|
|
786
|
+
}
|
|
787
|
+
const baseUrl = await getLauncherBaseURL(launcherUrl);
|
|
788
|
+
return (0, _urlJoin.default)(baseUrl, "/embed/manage-subscription?launcherSessionId=".concat(launcherSessionId, "&locale=").concat(locale));
|
|
789
|
+
};
|
|
790
|
+
exports.getManageSubscriptionURL = getManageSubscriptionURL;
|
|
753
791
|
const nanoid = exports.nanoid = function nanoid() {
|
|
754
792
|
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
|
755
793
|
return [...Array(length)].map(() => Math.random().toString(36)[2]).join('');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/ux",
|
|
3
|
-
"version": "1.16.25-next-
|
|
3
|
+
"version": "1.16.25-next-0ba03ffc",
|
|
4
4
|
"description": "UX components shared across abtnode packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@abtnode/auth": "1.16.25-next-
|
|
32
|
-
"@abtnode/constant": "1.16.25-next-
|
|
33
|
-
"@abtnode/util": "1.16.25-next-
|
|
31
|
+
"@abtnode/auth": "1.16.25-next-0ba03ffc",
|
|
32
|
+
"@abtnode/constant": "1.16.25-next-0ba03ffc",
|
|
33
|
+
"@abtnode/util": "1.16.25-next-0ba03ffc",
|
|
34
34
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
35
35
|
"@arcblock/did": "^1.18.113",
|
|
36
36
|
"@arcblock/did-connect": "^2.9.54",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@arcblock/react-hooks": "^2.9.54",
|
|
41
41
|
"@arcblock/terminal": "^2.9.54",
|
|
42
42
|
"@arcblock/ux": "^2.9.54",
|
|
43
|
-
"@blocklet/constant": "1.16.25-next-
|
|
43
|
+
"@blocklet/constant": "1.16.25-next-0ba03ffc",
|
|
44
44
|
"@blocklet/launcher-layout": "2.2.54",
|
|
45
45
|
"@blocklet/list": "^0.12.76",
|
|
46
|
-
"@blocklet/meta": "1.16.25-next-
|
|
46
|
+
"@blocklet/meta": "1.16.25-next-0ba03ffc",
|
|
47
47
|
"@blocklet/ui-react": "^2.9.54",
|
|
48
48
|
"@blocklet/uploader": "^0.0.74",
|
|
49
49
|
"@emotion/react": "^11.10.4",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"jest": "^29.7.0",
|
|
108
108
|
"jest-environment-jsdom": "^29.7.0"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "4003cb3e4d32c47cdf097b00b551959db4d5d31a",
|
|
111
111
|
"exports": {
|
|
112
112
|
".": {
|
|
113
113
|
"import": "./es/index.js",
|