@abtnode/ux 1.16.25-next-3d78a4cb → 1.16.25-next-bc2f4c63

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.
@@ -51,6 +51,9 @@ function SubscriptionBlocklet({
51
51
  launcherSessionId,
52
52
  locale
53
53
  })]);
54
+ if (data?.error) {
55
+ throw new Error(data.error);
56
+ }
54
57
  return {
55
58
  launcherSession: data.launcherSession,
56
59
  subscriptionURL
@@ -10,7 +10,7 @@ import { useRef } from 'react';
10
10
  import useAsyncRetry from 'react-use/lib/useAsyncRetry';
11
11
  import useSetState from 'react-use/lib/useSetState';
12
12
  import { useNodeContext } from '../contexts/node';
13
- import { formatPrettyMsLocale, getAssetExpiration, getSubscriptionUrlV2 } from '../util';
13
+ import { formatPrettyMsLocale, getSubscriptionUrlV2 } from '../util';
14
14
  import ChipLabel from './chip-label';
15
15
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
16
16
  const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
@@ -40,9 +40,12 @@ function SubscriptionServer({
40
40
  } = props;
41
41
  const typoKey = isMobile ? 'mobile' : 'desktop';
42
42
  const asyncState = useAsyncRetry(async () => {
43
- const [asset, subscriptionURL] = await Promise.all([node.api.getLauncherSession({
43
+ const [data, subscriptionURL] = await Promise.all([
44
+ // 新 Launch 的 Server 会有 launcherSessionId 信息,旧的 Server 只有 nftId
45
+ // 这里做兼容处理,优先使用 launcherSessionId, 如果没有则使用 nftId
46
+ node.api.getLauncherSession({
44
47
  input: {
45
- launcherSessionId,
48
+ launcherSessionId: launcherSessionId || nftId,
46
49
  launcherUrl
47
50
  }
48
51
  }), getSubscriptionUrlV2({
@@ -51,8 +54,11 @@ function SubscriptionServer({
51
54
  launcherSessionId,
52
55
  locale
53
56
  })]);
57
+ if (data?.error) {
58
+ throw new Error(data.error);
59
+ }
54
60
  return {
55
- asset,
61
+ launcherSession: data.launcherSession,
56
62
  subscriptionURL
57
63
  };
58
64
  }, [locale]);
@@ -87,7 +93,7 @@ function SubscriptionServer({
87
93
  onClick: () => asyncState.retry()
88
94
  });
89
95
  }
90
- const expirationDate = getAssetExpiration(asyncState.value?.asset);
96
+ const expirationDate = asyncState.value?.launcherSession?.expirationDate;
91
97
  const isExpired = dayjs(expirationDate).isBefore(dayjs());
92
98
  const validityMs = dayjs(expirationDate).diff(dayjs(), 'ms');
93
99
  let status = 'success';
package/es/util/index.js CHANGED
@@ -6,7 +6,6 @@ import filesize from 'filesize';
6
6
  import humanizeUrl from 'humanize-url';
7
7
  import isUrl from 'is-url';
8
8
  import get from 'lodash/get';
9
- import last from 'lodash/last';
10
9
  import trimEnd from 'lodash/trimEnd';
11
10
  import qs from 'querystring';
12
11
  import joinUrl from 'url-join';
@@ -531,9 +530,6 @@ export async function getAsset(chainHost, address) {
531
530
  }
532
531
  return state;
533
532
  }
534
- export function getAssetExpiration(asset) {
535
- return last(get(asset, 'data.value.expirationDate', []));
536
- }
537
533
 
538
534
  /**
539
535
  * 检查url是否 未添加到 store list 中
@@ -69,6 +69,9 @@ function SubscriptionBlocklet(_ref) {
69
69
  launcherSessionId,
70
70
  locale
71
71
  })]);
72
+ if (data !== null && data !== void 0 && data.error) {
73
+ throw new Error(data.error);
74
+ }
72
75
  return {
73
76
  launcherSession: data.launcherSession,
74
77
  subscriptionURL
@@ -58,9 +58,12 @@ function SubscriptionServer(_ref) {
58
58
  rest = _objectWithoutProperties(props, _excluded2);
59
59
  const typoKey = isMobile ? 'mobile' : 'desktop';
60
60
  const asyncState = (0, _useAsyncRetry.default)(async () => {
61
- const [asset, subscriptionURL] = await Promise.all([node.api.getLauncherSession({
61
+ const [data, subscriptionURL] = await Promise.all([
62
+ // 新 Launch 的 Server 会有 launcherSessionId 信息,旧的 Server 只有 nftId
63
+ // 这里做兼容处理,优先使用 launcherSessionId, 如果没有则使用 nftId
64
+ node.api.getLauncherSession({
62
65
  input: {
63
- launcherSessionId,
66
+ launcherSessionId: launcherSessionId || nftId,
64
67
  launcherUrl
65
68
  }
66
69
  }), (0, _util.getSubscriptionUrlV2)({
@@ -69,8 +72,11 @@ function SubscriptionServer(_ref) {
69
72
  launcherSessionId,
70
73
  locale
71
74
  })]);
75
+ if (data !== null && data !== void 0 && data.error) {
76
+ throw new Error(data.error);
77
+ }
72
78
  return {
73
- asset,
79
+ launcherSession: data.launcherSession,
74
80
  subscriptionURL
75
81
  };
76
82
  }, [locale]);
@@ -102,7 +108,7 @@ function SubscriptionServer(_ref) {
102
108
  onClick: () => asyncState.retry()
103
109
  }));
104
110
  }
105
- const expirationDate = (0, _util.getAssetExpiration)((_asyncState$value = asyncState.value) === null || _asyncState$value === void 0 ? void 0 : _asyncState$value.asset);
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;
106
112
  const isExpired = (0, _dayjs.default)(expirationDate).isBefore((0, _dayjs.default)());
107
113
  const validityMs = (0, _dayjs.default)(expirationDate).diff((0, _dayjs.default)(), 'ms');
108
114
  let status = 'success';
package/lib/util/index.js CHANGED
@@ -23,7 +23,6 @@ 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;
@@ -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 中
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.25-next-3d78a4cb",
3
+ "version": "1.16.25-next-bc2f4c63",
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-3d78a4cb",
32
- "@abtnode/constant": "1.16.25-next-3d78a4cb",
33
- "@abtnode/util": "1.16.25-next-3d78a4cb",
31
+ "@abtnode/auth": "1.16.25-next-bc2f4c63",
32
+ "@abtnode/constant": "1.16.25-next-bc2f4c63",
33
+ "@abtnode/util": "1.16.25-next-bc2f4c63",
34
34
  "@ahooksjs/use-url-state": "^3.5.1",
35
35
  "@arcblock/did": "^1.18.113",
36
36
  "@arcblock/did-connect": "^2.9.60",
@@ -40,10 +40,10 @@
40
40
  "@arcblock/react-hooks": "^2.9.60",
41
41
  "@arcblock/terminal": "^2.9.60",
42
42
  "@arcblock/ux": "^2.9.60",
43
- "@blocklet/constant": "1.16.25-next-3d78a4cb",
43
+ "@blocklet/constant": "1.16.25-next-bc2f4c63",
44
44
  "@blocklet/launcher-layout": "2.2.60",
45
45
  "@blocklet/list": "^0.12.78",
46
- "@blocklet/meta": "1.16.25-next-3d78a4cb",
46
+ "@blocklet/meta": "1.16.25-next-bc2f4c63",
47
47
  "@blocklet/ui-react": "^2.9.60",
48
48
  "@blocklet/uploader": "^0.0.75",
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": "26b43891e46756b142bcd6b62c57357c7c23cf2f",
110
+ "gitHead": "499ecf2bde0cdb25dbfdd1cf7807212f5fe37ad9",
111
111
  "exports": {
112
112
  ".": {
113
113
  "import": "./es/index.js",