@abtnode/ux 1.16.25-beta-023ec101 → 1.16.25-beta-bc165d9b
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 +19 -10
- package/es/blocklet/component/add-component-core.js +5 -0
- package/es/blocklet/component/component-cell.js +2 -1
- package/es/blocklet/icons.js +3 -1
- package/es/blocklet/overview.js +13 -7
- package/es/blocklet/publish/create-release.js +150 -43
- package/es/blocklet/publish/index.js +0 -4
- package/es/blocklet/publish/project-list.js +133 -29
- package/es/blocklet/publish/release-list.js +18 -4
- package/es/blocklet/publish/resource.js +35 -32
- package/es/blocklet/router/rule-list.js +2 -1
- package/es/locales/ar.js +13 -8
- package/es/locales/de.js +13 -8
- package/es/locales/en.js +12 -7
- package/es/locales/es.js +13 -8
- package/es/locales/fr.js +13 -8
- package/es/locales/hi.js +13 -8
- package/es/locales/i18n.db +0 -0
- package/es/locales/id.js +13 -8
- package/es/locales/ja.js +13 -8
- package/es/locales/ko.js +13 -8
- package/es/locales/pt.js +13 -8
- package/es/locales/ru.js +13 -8
- package/es/locales/th.js +13 -8
- package/es/locales/vi.js +13 -8
- package/es/locales/zh-tw.js +13 -8
- package/es/locales/zh.js +17 -12
- package/es/subscription/blocklet.js +175 -0
- package/es/subscription/chip-label.js +21 -0
- package/es/{subscription.js → subscription/server.js} +31 -30
- package/es/team/members/connections.js +2 -1
- package/es/team/members/member.js +2 -1
- package/es/util/index.js +42 -9
- package/lib/blocklet/actions.js +22 -11
- package/lib/blocklet/component/add-component-core.js +1 -1
- package/lib/blocklet/component/component-cell.js +2 -1
- package/lib/blocklet/icons.js +3 -1
- package/lib/blocklet/overview.js +13 -7
- package/lib/blocklet/publish/create-release.js +154 -43
- package/lib/blocklet/publish/index.js +0 -4
- package/lib/blocklet/publish/project-list.js +133 -29
- package/lib/blocklet/publish/release-list.js +18 -4
- package/lib/blocklet/publish/resource.js +34 -31
- package/lib/blocklet/router/rule-list.js +2 -1
- package/lib/locales/ar.js +13 -8
- package/lib/locales/de.js +13 -8
- package/lib/locales/en.js +12 -7
- package/lib/locales/es.js +13 -8
- package/lib/locales/fr.js +13 -8
- package/lib/locales/hi.js +13 -8
- package/lib/locales/i18n.db +0 -0
- package/lib/locales/id.js +13 -8
- package/lib/locales/ja.js +13 -8
- package/lib/locales/ko.js +13 -8
- package/lib/locales/pt.js +13 -8
- package/lib/locales/ru.js +13 -8
- package/lib/locales/th.js +13 -8
- package/lib/locales/vi.js +13 -8
- package/lib/locales/zh-tw.js +13 -8
- package/lib/locales/zh.js +17 -12
- package/lib/subscription/blocklet.js +189 -0
- package/lib/subscription/chip-label.js +29 -0
- package/lib/{subscription.js → subscription/server.js} +37 -37
- package/lib/team/members/connections.js +2 -1
- package/lib/team/members/member.js +2 -1
- package/lib/util/index.js +51 -18
- package/package.json +16 -16
- package/es/blocklet/publish/create-project.js +0 -205
- package/lib/blocklet/publish/create-project.js +0 -215
|
@@ -0,0 +1,189 @@
|
|
|
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 : 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, _launcherSession$subs, _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
|
+
if (data !== null && data !== void 0 && data.error) {
|
|
73
|
+
throw new Error(data.error);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
launcherSession: data.launcherSession,
|
|
77
|
+
subscriptionURL
|
|
78
|
+
};
|
|
79
|
+
}, [locale]);
|
|
80
|
+
if (asyncState.loading) {
|
|
81
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread({
|
|
82
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_chipLabel.default, {
|
|
83
|
+
children: [!isMobile && t('expiration.desktop.loading'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
|
|
84
|
+
size: 16
|
|
85
|
+
})]
|
|
86
|
+
}),
|
|
87
|
+
variant: "success",
|
|
88
|
+
sx: _objectSpread({
|
|
89
|
+
cursor: 'pointer'
|
|
90
|
+
}, sx)
|
|
91
|
+
}, rest));
|
|
92
|
+
}
|
|
93
|
+
if (asyncState.error) {
|
|
94
|
+
console.error(asyncState.error);
|
|
95
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
96
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_chipLabel.default, {
|
|
97
|
+
children: t("expiration.".concat(typoKey, ".loadFailed"))
|
|
98
|
+
}),
|
|
99
|
+
color: "error",
|
|
100
|
+
variant: "success",
|
|
101
|
+
sx: _objectSpread({
|
|
102
|
+
cursor: 'pointer'
|
|
103
|
+
}, sx)
|
|
104
|
+
}, rest), {}, {
|
|
105
|
+
onClick: () => asyncState.retry()
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
const handlePopoverClick = event => {
|
|
109
|
+
setState({
|
|
110
|
+
popoverAnchorEl: event.currentTarget
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const handlePopoverClose = () => {
|
|
114
|
+
setState({
|
|
115
|
+
popoverAnchorEl: null
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
const launcherSession = (_asyncState$value = asyncState.value) === null || _asyncState$value === void 0 ? void 0 : _asyncState$value.launcherSession;
|
|
119
|
+
let status = 'success';
|
|
120
|
+
if (['expired', 'terminated'].includes((_asyncState$value2 = asyncState.value) === null || _asyncState$value2 === void 0 || (_asyncState$value2 = _asyncState$value2.launcherSession) === null || _asyncState$value2 === void 0 ? void 0 : _asyncState$value2.statusText)) {
|
|
121
|
+
status = 'error';
|
|
122
|
+
}
|
|
123
|
+
let validity = null;
|
|
124
|
+
if (launcherSession.expirationDate && !launcherSession.subscription) {
|
|
125
|
+
const validityMs = (0, _dayjs.default)(launcherSession.expirationDate).diff((0, _dayjs.default)(), 'ms');
|
|
126
|
+
validity = t("expiration.".concat(typoKey, ".tips.").concat(status), {
|
|
127
|
+
validity: (0, _prettyMsI18n.default)(validityMs, {
|
|
128
|
+
locale: (0, _util.formatPrettyMsLocale)(locale),
|
|
129
|
+
compact: true,
|
|
130
|
+
verbose: true
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
if (validityMs > 0 && validityMs <= ALERT_THRESHOLD_MS) {
|
|
134
|
+
status = 'warning';
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
138
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
139
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_chipLabel.default, {
|
|
140
|
+
children: validity || (launcherSession === null || launcherSession === void 0 || (_launcherSession$subs = launcherSession.subscription) === null || _launcherSession$subs === void 0 || (_launcherSession$subs = _launcherSession$subs.product) === null || _launcherSession$subs === void 0 ? void 0 : _launcherSession$subs.name) || t('common.subscription')
|
|
141
|
+
}),
|
|
142
|
+
color: status,
|
|
143
|
+
variant: status !== 'success' ? 'contained' : 'outlined',
|
|
144
|
+
sx: _objectSpread({
|
|
145
|
+
cursor: 'pointer'
|
|
146
|
+
}, sx)
|
|
147
|
+
}, rest), {}, {
|
|
148
|
+
onClick: handlePopoverClick
|
|
149
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popover.default, {
|
|
150
|
+
id: "popover-info",
|
|
151
|
+
open: Boolean(state.popoverAnchorEl),
|
|
152
|
+
anchorEl: state.popoverAnchorEl,
|
|
153
|
+
onClose: handlePopoverClose,
|
|
154
|
+
anchorOrigin: {
|
|
155
|
+
vertical: 'bottom',
|
|
156
|
+
horizontal: 'right'
|
|
157
|
+
},
|
|
158
|
+
transformOrigin: {
|
|
159
|
+
vertical: 'top',
|
|
160
|
+
horizontal: 'right'
|
|
161
|
+
},
|
|
162
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {
|
|
163
|
+
ref: iframeRef,
|
|
164
|
+
title: t('common.subscription'),
|
|
165
|
+
width: "360px",
|
|
166
|
+
height: "600px",
|
|
167
|
+
style: {
|
|
168
|
+
border: 0
|
|
169
|
+
},
|
|
170
|
+
src: (_asyncState$value3 = asyncState.value) === null || _asyncState$value3 === void 0 ? void 0 : _asyncState$value3.subscriptionURL
|
|
171
|
+
})
|
|
172
|
+
})]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
SubscriptionBlocklet.propTypes = {
|
|
176
|
+
chainHost: _propTypes.default.string.isRequired,
|
|
177
|
+
nftId: _propTypes.default.string,
|
|
178
|
+
launcherSessionId: _propTypes.default.string,
|
|
179
|
+
sx: _propTypes.default.object,
|
|
180
|
+
retention: _propTypes.default.number,
|
|
181
|
+
launcherUrl: _propTypes.default.string.isRequired
|
|
182
|
+
};
|
|
183
|
+
SubscriptionBlocklet.defaultProps = {
|
|
184
|
+
sx: {},
|
|
185
|
+
retention: 0,
|
|
186
|
+
nftId: '',
|
|
187
|
+
launcherSessionId: ''
|
|
188
|
+
};
|
|
189
|
+
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,25 +51,38 @@ 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 [
|
|
61
|
+
const [data, subscriptionURL] = await Promise.all([
|
|
62
|
+
// 新 Launch 的 Server 会有 launcherSessionId 信息,旧的 Server 只有 nftId
|
|
63
|
+
// 这里做兼容处理,优先使用 launcherSessionId, 如果没有则使用 nftId
|
|
64
|
+
node.api.getLauncherSession({
|
|
65
|
+
input: {
|
|
66
|
+
launcherSessionId: launcherSessionId || nftId,
|
|
67
|
+
launcherUrl
|
|
68
|
+
}
|
|
69
|
+
}), (0, _util.getSubscriptionUrlV2)({
|
|
77
70
|
launcherUrl: launcherUrl || DEFAULT_LAUNCHER_URL,
|
|
78
|
-
nftId,
|
|
71
|
+
nftDid: nftId,
|
|
72
|
+
launcherSessionId,
|
|
79
73
|
locale
|
|
80
74
|
})]);
|
|
75
|
+
if (data !== null && data !== void 0 && data.error) {
|
|
76
|
+
throw new Error(data.error);
|
|
77
|
+
}
|
|
81
78
|
return {
|
|
82
|
-
|
|
79
|
+
launcherSession: data.launcherSession,
|
|
83
80
|
subscriptionURL
|
|
84
81
|
};
|
|
85
82
|
}, [locale]);
|
|
86
83
|
if (asyncState.loading) {
|
|
87
84
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread({
|
|
88
|
-
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
85
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_chipLabel.default, {
|
|
89
86
|
children: [!isMobile && t('expiration.desktop.loading'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
|
|
90
87
|
size: 16
|
|
91
88
|
})]
|
|
@@ -99,7 +96,7 @@ function Subscription(_ref2) {
|
|
|
99
96
|
if (asyncState.error) {
|
|
100
97
|
console.error(asyncState.error);
|
|
101
98
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
102
|
-
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
99
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_chipLabel.default, {
|
|
103
100
|
children: t("expiration.".concat(typoKey, ".loadFailed"))
|
|
104
101
|
}),
|
|
105
102
|
color: "error",
|
|
@@ -111,7 +108,7 @@ function Subscription(_ref2) {
|
|
|
111
108
|
onClick: () => asyncState.retry()
|
|
112
109
|
}));
|
|
113
110
|
}
|
|
114
|
-
const expirationDate = (
|
|
111
|
+
const expirationDate = (_asyncState$value = asyncState.value) === null || _asyncState$value === void 0 || (_asyncState$value = _asyncState$value.launcherSession) === null || _asyncState$value === void 0 ? void 0 : _asyncState$value.expirationDate;
|
|
115
112
|
const isExpired = (0, _dayjs.default)(expirationDate).isBefore((0, _dayjs.default)());
|
|
116
113
|
const validityMs = (0, _dayjs.default)(expirationDate).diff((0, _dayjs.default)(), 'ms');
|
|
117
114
|
let status = 'success';
|
|
@@ -133,7 +130,7 @@ function Subscription(_ref2) {
|
|
|
133
130
|
};
|
|
134
131
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
135
132
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, _objectSpread(_objectSpread({
|
|
136
|
-
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
133
|
+
label: /*#__PURE__*/(0, _jsxRuntime.jsx)(_chipLabel.default, {
|
|
137
134
|
children: t("expiration.".concat(typoKey, ".tips.").concat(status), {
|
|
138
135
|
validity: (0, _prettyMsI18n.default)(validityMs, {
|
|
139
136
|
locale: (0, _util.formatPrettyMsLocale)(locale),
|
|
@@ -175,15 +172,18 @@ function Subscription(_ref2) {
|
|
|
175
172
|
})]
|
|
176
173
|
});
|
|
177
174
|
}
|
|
178
|
-
|
|
175
|
+
SubscriptionServer.propTypes = {
|
|
179
176
|
chainHost: _propTypes.default.string.isRequired,
|
|
180
|
-
nftId: _propTypes.default.string
|
|
177
|
+
nftId: _propTypes.default.string,
|
|
178
|
+
launcherSessionId: _propTypes.default.string,
|
|
181
179
|
sx: _propTypes.default.object,
|
|
182
180
|
retention: _propTypes.default.number,
|
|
183
181
|
launcherUrl: _propTypes.default.string.isRequired
|
|
184
182
|
};
|
|
185
|
-
|
|
183
|
+
SubscriptionServer.defaultProps = {
|
|
186
184
|
sx: {},
|
|
187
|
-
retention: 0
|
|
185
|
+
retention: 0,
|
|
186
|
+
nftId: '',
|
|
187
|
+
launcherSessionId: ''
|
|
188
188
|
};
|
|
189
|
-
var _default = exports.default =
|
|
189
|
+
var _default = exports.default = SubscriptionServer;
|
package/lib/util/index.js
CHANGED
|
@@ -23,14 +23,13 @@ exports.formatUrl = void 0;
|
|
|
23
23
|
exports.getAccessUrl = getAccessUrl;
|
|
24
24
|
exports.getAccessibleUrl = void 0;
|
|
25
25
|
exports.getAsset = getAsset;
|
|
26
|
-
exports.getAssetExpiration = getAssetExpiration;
|
|
27
26
|
exports.getBlockletLogoUrl = void 0;
|
|
28
27
|
exports.getBlockletMetaUrl = getBlockletMetaUrl;
|
|
29
28
|
exports.getBlockletUrl = getBlockletUrl;
|
|
30
29
|
exports.getBlockletUrlParams = void 0;
|
|
31
30
|
exports.getBlockletUrls = getBlockletUrls;
|
|
32
31
|
exports.getExplorerLink = getExplorerLink;
|
|
33
|
-
exports.getTransferAppLink = exports.getSystemDomains = exports.getSubscriptionURL = exports.getStoreList = exports.
|
|
32
|
+
exports.getTransferAppLink = exports.getSystemDomains = exports.getSubscriptionUrlV2 = exports.getSubscriptionURL = exports.getStoreList = exports.getPathPrefix = exports.getManageSubscriptionURL = exports.getLogoHash = exports.getIssuePassportLink = exports.getInviteLink = void 0;
|
|
34
33
|
exports.getWebWalletUrl = getWebWalletUrl;
|
|
35
34
|
exports.isNewStoreUrl = exports.isInstalling = exports.isDownloading = exports.isChrome = exports.isCertificateMatch = exports.isBlockletDev = exports.hasRequiredSteps = void 0;
|
|
36
35
|
exports.isProtectedRole = isProtectedRole;
|
|
@@ -46,7 +45,6 @@ var _filesize = _interopRequireDefault(require("filesize"));
|
|
|
46
45
|
var _humanizeUrl = _interopRequireDefault(require("humanize-url"));
|
|
47
46
|
var _isUrl = _interopRequireDefault(require("is-url"));
|
|
48
47
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
49
|
-
var _last = _interopRequireDefault(require("lodash/last"));
|
|
50
48
|
var _trimEnd = _interopRequireDefault(require("lodash/trimEnd"));
|
|
51
49
|
var _querystring = _interopRequireDefault(require("querystring"));
|
|
52
50
|
var _urlJoin = _interopRequireDefault(require("url-join"));
|
|
@@ -617,9 +615,6 @@ async function getAsset(chainHost, address) {
|
|
|
617
615
|
}
|
|
618
616
|
return state;
|
|
619
617
|
}
|
|
620
|
-
function getAssetExpiration(asset) {
|
|
621
|
-
return (0, _last.default)((0, _get.default)(asset, 'data.value.expirationDate', []));
|
|
622
|
-
}
|
|
623
618
|
|
|
624
619
|
/**
|
|
625
620
|
* 检查url是否 未添加到 store list 中
|
|
@@ -715,33 +710,44 @@ const sortDomains = domains => {
|
|
|
715
710
|
exports.sortDomains = sortDomains;
|
|
716
711
|
const formatMountPoint = value => (0, _normalizePathPrefix.default)((0, _urlPathFriendly.default)(value));
|
|
717
712
|
exports.formatMountPoint = formatMountPoint;
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
713
|
+
const getLauncherBaseURL = async launcherUrl => {
|
|
714
|
+
if (!launcherUrl) {
|
|
715
|
+
return '';
|
|
716
|
+
}
|
|
717
|
+
let baseUrl = launcherUrl;
|
|
718
|
+
try {
|
|
719
|
+
var _appMeta$componentMou;
|
|
720
|
+
const {
|
|
721
|
+
data: appMeta
|
|
722
|
+
} = await _axios.default.get((0, _urlJoin.default)(launcherUrl, '__blocklet__.js?type=json'), {
|
|
723
|
+
timeout: 5000
|
|
724
|
+
});
|
|
725
|
+
const mountPoint = (_appMeta$componentMou = appMeta.componentMountPoints) === null || _appMeta$componentMou === void 0 ? void 0 : _appMeta$componentMou.find(item => item.did === 'z8iZkFBbrVQxZHvcWWB3Sa2TrfGmSeFz9MSU7');
|
|
726
|
+
const launcherUrlObj = new URL(launcherUrl);
|
|
727
|
+
baseUrl = (0, _urlJoin.default)(launcherUrlObj.origin, mountPoint === null || mountPoint === void 0 ? void 0 : mountPoint.mountPoint);
|
|
728
|
+
} catch (error) {
|
|
729
|
+
console.error(error);
|
|
730
|
+
}
|
|
731
|
+
return baseUrl;
|
|
725
732
|
};
|
|
726
|
-
|
|
727
|
-
const getSubscriptionURL = async _ref8 => {
|
|
733
|
+
const getSubscriptionURL = async _ref7 => {
|
|
728
734
|
let {
|
|
729
735
|
launcherUrl = '',
|
|
730
736
|
nftId = '',
|
|
731
737
|
locale = 'en'
|
|
732
|
-
} =
|
|
738
|
+
} = _ref7;
|
|
733
739
|
if (!launcherUrl) {
|
|
734
740
|
return '';
|
|
735
741
|
}
|
|
736
742
|
let baseUrl = (0, _urlJoin.default)(launcherUrl, '/instances');
|
|
737
743
|
try {
|
|
738
|
-
var _appMeta$
|
|
744
|
+
var _appMeta$componentMou2;
|
|
739
745
|
const {
|
|
740
746
|
data: appMeta
|
|
741
747
|
} = await _axios.default.get((0, _urlJoin.default)(launcherUrl, '__blocklet__.js?type=json'), {
|
|
742
748
|
timeout: 5000
|
|
743
749
|
});
|
|
744
|
-
const mountPoint = (_appMeta$
|
|
750
|
+
const mountPoint = (_appMeta$componentMou2 = appMeta.componentMountPoints) === null || _appMeta$componentMou2 === void 0 ? void 0 : _appMeta$componentMou2.find(item => item.did === 'z8iZy4P83i6AgnNdNUexsh2kBcsDHoqcwPavn');
|
|
745
751
|
const launcherUrlObj = new URL(launcherUrl);
|
|
746
752
|
baseUrl = (0, _urlJoin.default)(launcherUrlObj.origin, mountPoint === null || mountPoint === void 0 ? void 0 : mountPoint.mountPoint, '/nfts');
|
|
747
753
|
} catch (error) {
|
|
@@ -750,6 +756,33 @@ const getSubscriptionURL = async _ref8 => {
|
|
|
750
756
|
return (0, _urlJoin.default)(baseUrl, "/".concat(nftId, "/subscription?locale=").concat(locale, "&return-url=").concat(encodeURIComponent(window.location.href)));
|
|
751
757
|
};
|
|
752
758
|
exports.getSubscriptionURL = getSubscriptionURL;
|
|
759
|
+
const getSubscriptionUrlV2 = async _ref8 => {
|
|
760
|
+
let {
|
|
761
|
+
launcherUrl = '',
|
|
762
|
+
launcherSessionId = '',
|
|
763
|
+
nftDid,
|
|
764
|
+
locale = 'en'
|
|
765
|
+
} = _ref8;
|
|
766
|
+
if (!launcherUrl) {
|
|
767
|
+
return '';
|
|
768
|
+
}
|
|
769
|
+
const baseUrl = await getLauncherBaseURL(launcherUrl);
|
|
770
|
+
return (0, _urlJoin.default)(baseUrl, "/embed/subscription?launcherSessionId=".concat(launcherSessionId, "&nftDid=").concat(nftDid, "&locale=").concat(locale)); // nftDid 是兼容字段
|
|
771
|
+
};
|
|
772
|
+
exports.getSubscriptionUrlV2 = getSubscriptionUrlV2;
|
|
773
|
+
const getManageSubscriptionURL = async _ref9 => {
|
|
774
|
+
let {
|
|
775
|
+
launcherUrl = '',
|
|
776
|
+
launcherSessionId = '',
|
|
777
|
+
locale = 'en'
|
|
778
|
+
} = _ref9;
|
|
779
|
+
if (!launcherUrl) {
|
|
780
|
+
return '';
|
|
781
|
+
}
|
|
782
|
+
const baseUrl = await getLauncherBaseURL(launcherUrl);
|
|
783
|
+
return (0, _urlJoin.default)(baseUrl, "/embed/manage-subscription?launcherSessionId=".concat(launcherSessionId, "&locale=").concat(locale));
|
|
784
|
+
};
|
|
785
|
+
exports.getManageSubscriptionURL = getManageSubscriptionURL;
|
|
753
786
|
const nanoid = exports.nanoid = function nanoid() {
|
|
754
787
|
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
|
755
788
|
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-beta-
|
|
3
|
+
"version": "1.16.25-beta-bc165d9b",
|
|
4
4
|
"description": "UX components shared across abtnode packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,23 +28,23 @@
|
|
|
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-beta-
|
|
32
|
-
"@abtnode/constant": "1.16.25-beta-
|
|
33
|
-
"@abtnode/util": "1.16.25-beta-
|
|
31
|
+
"@abtnode/auth": "1.16.25-beta-bc165d9b",
|
|
32
|
+
"@abtnode/constant": "1.16.25-beta-bc165d9b",
|
|
33
|
+
"@abtnode/util": "1.16.25-beta-bc165d9b",
|
|
34
34
|
"@ahooksjs/use-url-state": "^3.5.1",
|
|
35
35
|
"@arcblock/did": "^1.18.113",
|
|
36
|
-
"@arcblock/did-connect": "^2.9.
|
|
36
|
+
"@arcblock/did-connect": "^2.9.63",
|
|
37
37
|
"@arcblock/did-motif": "^1.1.13",
|
|
38
|
-
"@arcblock/icons": "^2.9.
|
|
39
|
-
"@arcblock/nft-display": "2.9.
|
|
40
|
-
"@arcblock/react-hooks": "^2.9.
|
|
41
|
-
"@arcblock/terminal": "^2.9.
|
|
42
|
-
"@arcblock/ux": "^2.9.
|
|
43
|
-
"@blocklet/constant": "1.16.25-beta-
|
|
44
|
-
"@blocklet/launcher-layout": "2.2.
|
|
45
|
-
"@blocklet/list": "^0.12.
|
|
46
|
-
"@blocklet/meta": "1.16.25-beta-
|
|
47
|
-
"@blocklet/ui-react": "^2.9.
|
|
38
|
+
"@arcblock/icons": "^2.9.63",
|
|
39
|
+
"@arcblock/nft-display": "2.9.63",
|
|
40
|
+
"@arcblock/react-hooks": "^2.9.63",
|
|
41
|
+
"@arcblock/terminal": "^2.9.63",
|
|
42
|
+
"@arcblock/ux": "^2.9.63",
|
|
43
|
+
"@blocklet/constant": "1.16.25-beta-bc165d9b",
|
|
44
|
+
"@blocklet/launcher-layout": "2.2.66",
|
|
45
|
+
"@blocklet/list": "^0.12.79",
|
|
46
|
+
"@blocklet/meta": "1.16.25-beta-bc165d9b",
|
|
47
|
+
"@blocklet/ui-react": "^2.9.63",
|
|
48
48
|
"@blocklet/uploader": "^0.0.75",
|
|
49
49
|
"@emotion/react": "^11.10.4",
|
|
50
50
|
"@emotion/styled": "^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": "a7895ed39e47c8c6bd10d32317804cc1904714ef",
|
|
111
111
|
"exports": {
|
|
112
112
|
".": {
|
|
113
113
|
"import": "./es/index.js",
|