@arcblock/ux 2.1.44 → 2.1.45
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/lib/NFTDisplay/index.js +11 -5
- package/package.json +4 -4
- package/src/NFTDisplay/index.js +9 -4
package/lib/NFTDisplay/index.js
CHANGED
|
@@ -114,9 +114,10 @@ function NFTDisplay(_ref) {
|
|
|
114
114
|
children: children
|
|
115
115
|
}));
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
const parsed = (0, _react.useRef)(data); // 如果是 raw data 先解析
|
|
117
|
+
const parsed = (0, _react.useRef)(data);
|
|
119
118
|
|
|
119
|
+
try {
|
|
120
|
+
// 如果是 raw data 先解析
|
|
120
121
|
if (typeof parsed.current === 'string') {
|
|
121
122
|
parsed.current = JSON.parse(data); // console.log('[debug] parse data')
|
|
122
123
|
}
|
|
@@ -208,7 +209,7 @@ function NFTDisplay(_ref) {
|
|
|
208
209
|
const svg = _buffer.Buffer.from(buffer).toString('utf8');
|
|
209
210
|
|
|
210
211
|
if (checkSvg && !(0, _isSvg.default)(svg)) {
|
|
211
|
-
throw new Error(
|
|
212
|
+
throw new Error('Invalid SVG of type svg_gzipped');
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
const Embedder = getSvgEmbedder(preferredSvgEmbedder);
|
|
@@ -220,7 +221,7 @@ function NFTDisplay(_ref) {
|
|
|
220
221
|
case 'svg':
|
|
221
222
|
{
|
|
222
223
|
if (checkSvg && !(0, _isSvg.default)(content)) {
|
|
223
|
-
throw new Error(
|
|
224
|
+
throw new Error('Invalid SVG of type svg');
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
const Embedder = getSvgEmbedder(preferredSvgEmbedder);
|
|
@@ -246,7 +247,12 @@ function NFTDisplay(_ref) {
|
|
|
246
247
|
children: [(state.loading || !minimumLoadingReady) && (renderLoading ? renderLoading() : /*#__PURE__*/(0, _jsxRuntime.jsx)(_loading.default, {})), renderNFT()]
|
|
247
248
|
}));
|
|
248
249
|
} catch (e) {
|
|
249
|
-
|
|
250
|
+
var _parsed$current;
|
|
251
|
+
|
|
252
|
+
console.error(e === null || e === void 0 ? void 0 : e.message, {
|
|
253
|
+
nftId: address,
|
|
254
|
+
vcId: parsed === null || parsed === void 0 ? void 0 : (_parsed$current = parsed.current) === null || _parsed$current === void 0 ? void 0 : _parsed$current.vcId
|
|
255
|
+
});
|
|
250
256
|
return wrapRoot(renderError ? renderError() : /*#__PURE__*/(0, _jsxRuntime.jsx)(_broken.default, {}));
|
|
251
257
|
}
|
|
252
258
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.45",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"react": ">=18.1.0",
|
|
53
53
|
"react-ga": "^2.7.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "84b9e6665af4066a5fa3087aeeebcd1414f270f4",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^2.1.
|
|
58
|
-
"@arcblock/react-hooks": "^2.1.
|
|
57
|
+
"@arcblock/icons": "^2.1.45",
|
|
58
|
+
"@arcblock/react-hooks": "^2.1.45",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@emotion/react": "^11.9.0",
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
package/src/NFTDisplay/index.js
CHANGED
|
@@ -69,13 +69,15 @@ function NFTDisplay({
|
|
|
69
69
|
</Root>
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
+
const parsed = useRef(data);
|
|
73
|
+
|
|
72
74
|
try {
|
|
73
|
-
const parsed = useRef(data);
|
|
74
75
|
// 如果是 raw data 先解析
|
|
75
76
|
if (typeof parsed.current === 'string') {
|
|
76
77
|
parsed.current = JSON.parse(data);
|
|
77
78
|
// console.log('[debug] parse data')
|
|
78
79
|
}
|
|
80
|
+
|
|
79
81
|
const { vcId } = parsed.current;
|
|
80
82
|
// 需要兼容新旧两种类型的数据结构, nft data 有 credentialSubject 属性, 说明是旧 nft data, 否则是新 nft data
|
|
81
83
|
const display = parsed.current.credentialSubject
|
|
@@ -147,14 +149,14 @@ function NFTDisplay({
|
|
|
147
149
|
const buffer = pako.ungzip(fromBase64(content), {});
|
|
148
150
|
const svg = Buffer.from(buffer).toString('utf8');
|
|
149
151
|
if (checkSvg && !isSvg(svg)) {
|
|
150
|
-
throw new Error(
|
|
152
|
+
throw new Error('Invalid SVG of type svg_gzipped');
|
|
151
153
|
}
|
|
152
154
|
const Embedder = getSvgEmbedder(preferredSvgEmbedder);
|
|
153
155
|
return <Embedder svg={svg} />;
|
|
154
156
|
}
|
|
155
157
|
case 'svg': {
|
|
156
158
|
if (checkSvg && !isSvg(content)) {
|
|
157
|
-
throw new Error(
|
|
159
|
+
throw new Error('Invalid SVG of type svg');
|
|
158
160
|
}
|
|
159
161
|
const Embedder = getSvgEmbedder(preferredSvgEmbedder);
|
|
160
162
|
return <Embedder svg={content} />;
|
|
@@ -176,7 +178,10 @@ function NFTDisplay({
|
|
|
176
178
|
</>
|
|
177
179
|
);
|
|
178
180
|
} catch (e) {
|
|
179
|
-
console.error(e
|
|
181
|
+
console.error(e?.message, {
|
|
182
|
+
nftId: address,
|
|
183
|
+
vcId: parsed?.current?.vcId,
|
|
184
|
+
});
|
|
180
185
|
return wrapRoot(renderError ? renderError() : <DefaultBrokenImage />);
|
|
181
186
|
}
|
|
182
187
|
}
|