@arcblock/ux 3.0.9 → 3.0.10
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/Address/did-address.js +47 -49
- package/lib/Address/responsive-did-address.js +53 -57
- package/lib/Avatar/index.js +16 -16
- package/lib/BlockletV2/blocklet.js +64 -64
- package/lib/BlockletV2/components/tooltip-icon.js +26 -27
- package/lib/CardSelector/index.js +1 -2
- package/lib/ClickToCopy/hook.js +10 -11
- package/lib/ClickToCopy/index.js +16 -16
- package/lib/Config/theme-mode-toggle.js +7 -8
- package/lib/DID/index.js +131 -133
- package/lib/DIDConnect/app-info-item.js +18 -18
- package/lib/DIDConnect/auth-apps/index.js +83 -84
- package/lib/DIDConnect/did-connect-container.js +89 -90
- package/lib/DIDConnect/did-connect-footer.js +25 -25
- package/lib/DIDConnect/landing-page.js +17 -17
- package/lib/DIDConnect/powered-by.js +11 -11
- package/lib/DIDConnect/request-storage-access-api-dialog.js +36 -37
- package/lib/DIDConnect/with-container.js +66 -68
- package/lib/Dialog/use-confirm.js +40 -43
- package/lib/Earth/index.js +21 -22
- package/lib/Footer/index.js +15 -16
- package/lib/Header/responsive-header.js +23 -24
- package/lib/Layout/dashboard/index.js +63 -72
- package/lib/Layout/dashboard/sidebar.js +20 -21
- package/lib/Layout/dashboard-legacy/index.js +52 -52
- package/lib/Locale/context.js +36 -37
- package/lib/Locale/selector.js +40 -42
- package/lib/NFTDisplay/index.js +114 -118
- package/lib/NFTDisplay/render-svg.js +12 -12
- package/lib/NavMenu/nav-menu.js +159 -161
- package/lib/NavMenu/sub-container.js +25 -26
- package/lib/PageScroller/index.js +28 -32
- package/lib/Passport/passport.js +11 -11
- package/lib/PhoneInput/country-select.js +38 -38
- package/lib/PhoneInput/index.js +65 -66
- package/lib/Screenshot/index.js +26 -27
- package/lib/SessionBlocklet/index.js +87 -93
- package/lib/SessionPermission/index.js +5 -9
- package/lib/SessionUser/components/did-space.js +24 -25
- package/lib/SessionUser/components/logged-in.js +122 -127
- package/lib/SessionUser/components/quick-login-item.js +41 -42
- package/lib/SessionUser/components/session-user-item.js +35 -36
- package/lib/SessionUser/components/session-user-switch.js +81 -85
- package/lib/SessionUser/components/un-login.js +41 -41
- package/lib/SessionUser/components/user-info.js +43 -47
- package/lib/SessionUser/index.js +1 -1
- package/lib/SessionUser/libs/utils.js +24 -30
- package/lib/SharedBridge/index.js +35 -35
- package/lib/Theme/index.js +16 -16
- package/lib/Theme/theme.js +42 -43
- package/lib/Toast/index.js +24 -25
- package/lib/Typography/index.js +42 -42
- package/lib/UserCard/Content/basic.js +91 -93
- package/lib/UserCard/Content/shorten-label.js +9 -9
- package/lib/UserCard/components.js +15 -15
- package/lib/Util/deprecate.js +1 -1
- package/lib/Util/federated.js +28 -32
- package/lib/Util/iframe.js +9 -10
- package/lib/Util/index.js +134 -135
- package/lib/Util/security.js +9 -10
- package/lib/Util/wallet.js +6 -9
- package/lib/VerificationCode/index.js +26 -28
- package/lib/hooks/use-blocklet-logo.js +11 -14
- package/lib/ux.css +1 -1
- package/lib/withTracker/index.js +13 -14
- package/package.json +9 -10
package/lib/Locale/context.js
CHANGED
@@ -1,81 +1,80 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import { createContext as x, use as k, useState as
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
2
|
+
import { createContext as x, use as k, useState as h, useRef as A, useEffect as R, useCallback as b } from "react";
|
3
3
|
import j from "lodash/get";
|
4
4
|
import i from "js-cookie";
|
5
5
|
import S from "./browser-lang.js";
|
6
6
|
import { translate as U } from "./util.js";
|
7
7
|
import { getCookieOptions as D, resolveRootDomain as E } from "../Util/index.js";
|
8
|
-
const
|
8
|
+
const l = "nf_lang", F = (e, o = window.location.href) => {
|
9
9
|
const t = new URL(o).searchParams.get("locale");
|
10
|
-
return e.find((
|
10
|
+
return e.find((c) => c.code === t) ? t : null;
|
11
11
|
}, O = (e, o = window.location.href) => {
|
12
12
|
const t = new URL(o);
|
13
13
|
t.searchParams.has("locale") && (t.searchParams.set("locale", e), window.history.replaceState({}, "", t.href));
|
14
14
|
}, d = (e = []) => {
|
15
|
-
var t;
|
16
15
|
const o = {
|
17
|
-
languages: e.map((
|
16
|
+
languages: e.map((t) => t.code),
|
18
17
|
// 取 languages 首个元素的 code 值, 如果不存在则取 'en'
|
19
|
-
fallback:
|
18
|
+
fallback: e?.[0]?.code || "en"
|
20
19
|
};
|
21
|
-
return F(e) || i.get(
|
20
|
+
return F(e) || i.get(l) || S(o);
|
22
21
|
}, z = (e) => {
|
23
22
|
const o = D();
|
24
23
|
if (!o.domain) {
|
25
24
|
const t = E();
|
26
|
-
t && i.remove(
|
25
|
+
t && i.remove(l, { path: o.path || "/", domain: t });
|
27
26
|
}
|
28
|
-
i.set(
|
27
|
+
i.set(l, e, o), O(e);
|
29
28
|
}, N = (e) => {
|
30
29
|
const o = j(window, "blocklet.languages");
|
31
30
|
return Array.isArray(o) && o.length ? o : Array.isArray(e) && e.length ? e : [
|
32
31
|
{ code: "en", name: "English" },
|
33
32
|
{ code: "zh", name: "简体中文" }
|
34
33
|
];
|
35
|
-
},
|
34
|
+
}, g = x(null), { Provider: _, Consumer: M } = g;
|
36
35
|
function Q({
|
37
36
|
children: e,
|
38
37
|
locale: o = void 0,
|
39
38
|
fallbackLocale: t = void 0,
|
40
|
-
translations:
|
41
|
-
onLoadingTranslation:
|
42
|
-
languages:
|
43
|
-
...
|
39
|
+
translations: c,
|
40
|
+
onLoadingTranslation: p = void 0,
|
41
|
+
languages: L = [],
|
42
|
+
...P
|
44
43
|
}) {
|
45
|
-
const
|
46
|
-
let [n,
|
47
|
-
const
|
48
|
-
|
44
|
+
const s = N(L);
|
45
|
+
let [n, v] = h(o || d(s));
|
46
|
+
const m = A(t || ""), [, C] = h(0), u = (r) => {
|
47
|
+
v(r), z(r);
|
49
48
|
};
|
50
49
|
if (R(() => {
|
51
|
-
const
|
52
|
-
|
53
|
-
}, [o]), n &&
|
54
|
-
const
|
50
|
+
const r = o || d(s);
|
51
|
+
r !== n && u(r);
|
52
|
+
}, [o]), n && c[n] && typeof c[n] == "function") {
|
53
|
+
const r = n;
|
55
54
|
try {
|
56
|
-
Promise.resolve(r
|
57
|
-
|
55
|
+
Promise.resolve(c[r]()).then((a) => {
|
56
|
+
a && typeof a == "object" && (c[r] = a, C((f) => f > 999 ? 0 : f + 1));
|
58
57
|
});
|
59
|
-
} catch (
|
60
|
-
console.error(
|
58
|
+
} catch (a) {
|
59
|
+
console.error(a);
|
61
60
|
}
|
62
|
-
|
61
|
+
p?.(r, s), n = m.current;
|
63
62
|
} else
|
64
|
-
|
65
|
-
const
|
66
|
-
(
|
67
|
-
[
|
63
|
+
m.current = n;
|
64
|
+
const w = b(
|
65
|
+
(r, a) => U(c, r, n, t, a),
|
66
|
+
[c, n, t]
|
68
67
|
);
|
69
|
-
return /* @__PURE__ */
|
68
|
+
return /* @__PURE__ */ y(_, { value: { locale: n, changeLocale: u, t: w, languages: s, ...P }, children: e });
|
70
69
|
}
|
71
|
-
function
|
72
|
-
return k(
|
70
|
+
function T() {
|
71
|
+
return k(g);
|
73
72
|
}
|
74
73
|
export {
|
75
74
|
M as LocaleConsumer,
|
76
|
-
|
75
|
+
g as LocaleContext,
|
77
76
|
Q as LocaleProvider,
|
78
77
|
d as getLocale,
|
79
78
|
z as setLocale,
|
80
|
-
|
79
|
+
T as useLocaleContext
|
81
80
|
};
|
package/lib/Locale/selector.js
CHANGED
@@ -1,20 +1,18 @@
|
|
1
|
-
import { jsx as n, jsxs as
|
2
|
-
import { use as
|
3
|
-
import { Box as
|
4
|
-
import { Icon as
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import { LocaleContext as
|
8
|
-
import { styled as
|
9
|
-
import { mergeSx as
|
10
|
-
function
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
(i = a.current) != null && i.contains(e.target) || o(!1);
|
17
|
-
}, S = p ? w : B, b = d === "hover" ? {
|
1
|
+
import { jsx as n, jsxs as l } from "react/jsx-runtime";
|
2
|
+
import { use as v, useRef as z, useState as L, useMemo as M } from "react";
|
3
|
+
import { Box as s, Button as N, IconButton as w, Typography as B, Popper as E, Paper as P, ClickAwayListener as j, MenuList as A, MenuItem as R } from "@mui/material";
|
4
|
+
import { Icon as x } from "@iconify/react";
|
5
|
+
import T from "@iconify-icons/material-symbols/check";
|
6
|
+
import $ from "iconify-icons-material-symbols-400/language";
|
7
|
+
import { LocaleContext as H } from "./context.js";
|
8
|
+
import { styled as O } from "../Theme/index.js";
|
9
|
+
import { mergeSx as W } from "../Util/style.js";
|
10
|
+
function Y({ ...t }) {
|
11
|
+
const { showText: a = !0, popperProps: p = {}, popperType: g = "click", icon: r, size: m = 24, ...h } = t, { locale: i, changeLocale: d, languages: f } = v(H), c = z(null), [u, o] = L(!1), y = (e) => {
|
12
|
+
d(e), o(!1), typeof t.onChange == "function" && t.onChange(e);
|
13
|
+
}, I = (e) => {
|
14
|
+
c.current?.contains(e.target) || o(!1);
|
15
|
+
}, k = a ? N : w, C = g === "hover" ? {
|
18
16
|
onMouseEnter: () => {
|
19
17
|
o(!0);
|
20
18
|
},
|
@@ -23,50 +21,50 @@ function Z({ ...t }) {
|
|
23
21
|
}
|
24
22
|
} : {
|
25
23
|
onClick: () => {
|
26
|
-
o(!
|
24
|
+
o(!u);
|
27
25
|
}
|
28
|
-
},
|
26
|
+
}, S = M(() => r ? /* @__PURE__ */ n(r, {}) : /* @__PURE__ */ n(x, { icon: $, fontSize: m, style: { transform: "scale(1.10)" } }), [r, m]);
|
29
27
|
return (
|
30
28
|
// @ts-ignore
|
31
|
-
/* @__PURE__ */
|
32
|
-
/* @__PURE__ */ n(
|
33
|
-
|
29
|
+
/* @__PURE__ */ l(q, { ...h, ...C, children: [
|
30
|
+
/* @__PURE__ */ n(k, { ref: c, className: "trigger", role: "button", "aria-label": "Locale selector button", children: /* @__PURE__ */ l(
|
31
|
+
s,
|
34
32
|
{
|
35
33
|
sx: {
|
36
34
|
display: "flex",
|
37
35
|
alignItems: "center"
|
38
36
|
},
|
39
37
|
children: [
|
40
|
-
|
41
|
-
|
38
|
+
S,
|
39
|
+
a ? /* @__PURE__ */ n(B, { component: "strong", className: "trigger-text", children: f.find((e) => e.code === i)?.name }) : ""
|
42
40
|
]
|
43
41
|
}
|
44
42
|
) }),
|
45
43
|
/* @__PURE__ */ n(
|
46
|
-
|
44
|
+
E,
|
47
45
|
{
|
48
|
-
open:
|
49
|
-
anchorEl:
|
50
|
-
...
|
51
|
-
sx:
|
46
|
+
open: u,
|
47
|
+
anchorEl: c.current,
|
48
|
+
...p,
|
49
|
+
sx: W(
|
52
50
|
// @ts-ignore
|
53
51
|
{ zIndex: (e) => e.zIndex.tooltip + 10 },
|
54
52
|
// @ts-ignore
|
55
|
-
|
53
|
+
p?.sx
|
56
54
|
),
|
57
55
|
children: /* @__PURE__ */ n(
|
58
|
-
|
56
|
+
P,
|
59
57
|
{
|
60
58
|
variant: "outlined",
|
61
59
|
className: "locales",
|
62
60
|
sx: {
|
63
61
|
borderRadius: 1
|
64
62
|
},
|
65
|
-
children: /* @__PURE__ */ n(
|
66
|
-
|
63
|
+
children: /* @__PURE__ */ n(j, { onClickAway: I, children: /* @__PURE__ */ n(A, { children: f.map(({ code: e, name: b }) => /* @__PURE__ */ l(
|
64
|
+
R,
|
67
65
|
{
|
68
66
|
className: "locale-item",
|
69
|
-
onClick: () =>
|
67
|
+
onClick: () => y(e),
|
70
68
|
sx: {
|
71
69
|
fontSize: 16,
|
72
70
|
fontStyle: "normal",
|
@@ -82,18 +80,18 @@ function Z({ ...t }) {
|
|
82
80
|
},
|
83
81
|
children: [
|
84
82
|
/* @__PURE__ */ n(
|
85
|
-
|
83
|
+
s,
|
86
84
|
{
|
87
|
-
component:
|
88
|
-
icon:
|
89
|
-
className: e ===
|
85
|
+
component: x,
|
86
|
+
icon: T,
|
87
|
+
className: e === i ? "check-icon check-icon-visible" : "check-icon",
|
90
88
|
sx: {
|
91
89
|
marginRight: 1,
|
92
|
-
visibility: e ===
|
90
|
+
visibility: e === i ? "visible" : "hidden"
|
93
91
|
}
|
94
92
|
}
|
95
93
|
),
|
96
|
-
|
94
|
+
b
|
97
95
|
]
|
98
96
|
},
|
99
97
|
e
|
@@ -105,7 +103,7 @@ function Z({ ...t }) {
|
|
105
103
|
] })
|
106
104
|
);
|
107
105
|
}
|
108
|
-
const
|
106
|
+
const q = O(s)`
|
109
107
|
display: inline-block;
|
110
108
|
|
111
109
|
.trigger {
|
@@ -123,5 +121,5 @@ const D = W(m)`
|
|
123
121
|
}
|
124
122
|
`;
|
125
123
|
export {
|
126
|
-
|
124
|
+
Y as default
|
127
125
|
};
|
package/lib/NFTDisplay/index.js
CHANGED
@@ -1,99 +1,96 @@
|
|
1
|
-
import { jsx as n, jsxs as
|
2
|
-
import { useRef as
|
3
|
-
import
|
4
|
-
import { Buffer as
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import { Box as
|
11
|
-
import
|
12
|
-
import
|
13
|
-
import
|
14
|
-
import
|
15
|
-
import
|
16
|
-
import { styled as
|
17
|
-
import
|
18
|
-
import
|
19
|
-
function
|
20
|
-
|
21
|
-
return (e == null ? void 0 : e.display) || ((s = e == null ? void 0 : e.data) == null ? void 0 : s.value);
|
1
|
+
import { jsx as n, jsxs as $, Fragment as q } from "react/jsx-runtime";
|
2
|
+
import { useRef as H, useState as S, useEffect as D } from "react";
|
3
|
+
import J from "clsx";
|
4
|
+
import { Buffer as C } from "buffer";
|
5
|
+
import M from "lodash/get";
|
6
|
+
import K from "pako";
|
7
|
+
import Q from "base64-url";
|
8
|
+
import P from "is-svg";
|
9
|
+
import X from "lodash/noop";
|
10
|
+
import { Box as Y } from "@mui/material";
|
11
|
+
import Z from "./aspect-ratio-container.js";
|
12
|
+
import ee from "./svg-embedder/img.js";
|
13
|
+
import te from "./svg-embedder/inline-svg.js";
|
14
|
+
import re from "./loading.js";
|
15
|
+
import A from "./broken.js";
|
16
|
+
import { styled as oe } from "../Theme/index.js";
|
17
|
+
import ne from "./displayApi.js";
|
18
|
+
import se from "./render-svg.js";
|
19
|
+
function Ue(r) {
|
20
|
+
return r?.display || r?.data?.value;
|
22
21
|
}
|
23
|
-
function
|
24
|
-
if (typeof
|
22
|
+
function ie(r) {
|
23
|
+
if (typeof r != "string")
|
25
24
|
throw new Error("fromBase64 requires input to be a string");
|
26
|
-
return
|
25
|
+
return C.from(Q.unescape(r), "base64");
|
27
26
|
}
|
28
|
-
const
|
29
|
-
img:
|
30
|
-
svg:
|
31
|
-
})[
|
32
|
-
function
|
33
|
-
data:
|
34
|
-
address:
|
35
|
-
inset:
|
36
|
-
aspect:
|
37
|
-
component:
|
38
|
-
className:
|
39
|
-
renderError:
|
40
|
-
renderLoading:
|
41
|
-
preferredSvgEmbedder:
|
42
|
-
checkSvg:
|
43
|
-
minimumLoadingTime:
|
44
|
-
onCompleted:
|
45
|
-
imageFilter:
|
46
|
-
...
|
27
|
+
const B = (r) => ({
|
28
|
+
img: ee,
|
29
|
+
svg: te
|
30
|
+
})[r];
|
31
|
+
function ae({
|
32
|
+
data: r,
|
33
|
+
address: i,
|
34
|
+
inset: f,
|
35
|
+
aspect: m,
|
36
|
+
component: v = "span",
|
37
|
+
className: L = "",
|
38
|
+
renderError: T,
|
39
|
+
renderLoading: b,
|
40
|
+
preferredSvgEmbedder: j = "img",
|
41
|
+
checkSvg: E = !1,
|
42
|
+
minimumLoadingTime: d = 0,
|
43
|
+
onCompleted: O = X,
|
44
|
+
imageFilter: x = null,
|
45
|
+
...z
|
47
46
|
}) {
|
48
|
-
|
49
|
-
const F = (l) => (
|
47
|
+
const I = (p) => (
|
50
48
|
// @ts-expect-error
|
51
|
-
/* @__PURE__ */ n(
|
52
|
-
), a =
|
49
|
+
/* @__PURE__ */ n(le, { component: v, ...z, className: J(L, { "nft-display--inset": f }), children: p })
|
50
|
+
), a = H({});
|
53
51
|
try {
|
54
|
-
typeof
|
55
|
-
const { vcId:
|
56
|
-
loading:
|
52
|
+
typeof r == "string" ? a.current = JSON.parse(r) : a.current = r;
|
53
|
+
const { vcId: p } = a.current, F = a.current.credentialSubject ? M(a.current, "credentialSubject.display") : a.current, { content: c, type: g } = F, W = g === "url", [e, l] = S({
|
54
|
+
loading: W,
|
57
55
|
error: !1,
|
58
56
|
loadingUrlType: !0,
|
59
57
|
urlType: null
|
60
|
-
}), [
|
61
|
-
const
|
62
|
-
return window.location.protocol === "https:" &&
|
63
|
-
|
64
|
-
}),
|
65
|
-
},
|
66
|
-
var o, i;
|
58
|
+
}), [h, k] = S(d <= 0), u = ({ useImageFilter: t = !1, t: s } = {}) => {
|
59
|
+
const o = new URL(c);
|
60
|
+
return window.location.protocol === "https:" && o.protocol === "http:" && (o.protocol = "https:"), o.searchParams.has("assetId") || o.searchParams.append("assetId", i), !o.searchParams.has("vcId") && p && o.searchParams.append("vcId", p), t && x && Object.entries(x).forEach(([N, w]) => {
|
61
|
+
o.searchParams.append(N, w);
|
62
|
+
}), s && o.searchParams.append("t", s), o.href;
|
63
|
+
}, G = async () => {
|
67
64
|
try {
|
68
|
-
const
|
69
|
-
url:
|
65
|
+
const s = (await ne({
|
66
|
+
url: u({ useImageFilter: !1, t: "nftdisplay" }),
|
70
67
|
method: "HEAD"
|
71
|
-
})
|
72
|
-
|
73
|
-
} catch (
|
74
|
-
if (console.error("Failed to fetch url content type",
|
75
|
-
|
68
|
+
}))?.headers?.get("Content-Type");
|
69
|
+
l({ ...e, loadingUrlType: !1, urlType: s });
|
70
|
+
} catch (t) {
|
71
|
+
if (console.error("Failed to fetch url content type", t), t?.message?.includes("timeout")) {
|
72
|
+
l({ ...e, loadingUrlType: !1, loading: !1, error: !0 });
|
76
73
|
return;
|
77
74
|
}
|
78
|
-
|
75
|
+
l({ ...e, loadingUrlType: !1, urlType: null });
|
79
76
|
}
|
80
77
|
};
|
81
|
-
if (
|
82
|
-
let
|
83
|
-
return
|
84
|
-
}, []),
|
85
|
-
(!
|
86
|
-
}, [
|
78
|
+
if (D(() => {
|
79
|
+
let t;
|
80
|
+
return d > 0 && (t = setTimeout(() => k(!0), d)), g === "url" && G(), () => clearTimeout(t);
|
81
|
+
}, []), D(() => {
|
82
|
+
(!e.loading && h || e.error) && O();
|
83
|
+
}, [e, h]), e.error)
|
87
84
|
throw new Error("Failed to render NFT Display.");
|
88
|
-
const
|
89
|
-
|
90
|
-
},
|
91
|
-
|
92
|
-
},
|
93
|
-
const
|
94
|
-
return /* @__PURE__ */ n("img", { src:
|
95
|
-
},
|
96
|
-
const
|
85
|
+
const y = () => {
|
86
|
+
e.loading && l({ ...e, loading: !1 });
|
87
|
+
}, R = () => {
|
88
|
+
l({ ...e, error: !0, loading: !1 });
|
89
|
+
}, U = () => {
|
90
|
+
const t = u({ useImageFilter: !0 });
|
91
|
+
return /* @__PURE__ */ n("img", { src: t, onError: R, onLoad: y, alt: "NFT Display", style: { width: "auto", height: "auto" } });
|
92
|
+
}, V = () => {
|
93
|
+
const t = e.urlType || "image/svg+xml", s = u(), o = new URL(s).pathname.toLowerCase();
|
97
94
|
return [
|
98
95
|
".jpg",
|
99
96
|
".jpeg",
|
@@ -109,70 +106,69 @@ function lr({
|
|
109
106
|
".pjpeg",
|
110
107
|
".pjp",
|
111
108
|
".avif"
|
112
|
-
].some((
|
109
|
+
].some((w) => o.endsWith(w)) ? U() : t.includes("text/html;") ? /* @__PURE__ */ n(A, {}) : (
|
113
110
|
// eslint-disable-next-line jsx-a11y/alt-text
|
114
111
|
/* @__PURE__ */ n(
|
115
112
|
"object",
|
116
113
|
{
|
117
|
-
type:
|
118
|
-
data:
|
119
|
-
onErrorCapture:
|
120
|
-
onLoad:
|
114
|
+
type: t,
|
115
|
+
data: s,
|
116
|
+
onErrorCapture: R,
|
117
|
+
onLoad: y,
|
121
118
|
style: { width: "100%", height: "100%", pointerEvents: "none" }
|
122
119
|
},
|
123
|
-
|
120
|
+
s
|
124
121
|
)
|
125
122
|
);
|
126
|
-
},
|
127
|
-
|
128
|
-
|
129
|
-
switch (y) {
|
123
|
+
}, _ = () => {
|
124
|
+
if (c)
|
125
|
+
switch (g) {
|
130
126
|
case "url":
|
131
|
-
return
|
127
|
+
return e.loadingUrlType ? null : e.urlType?.startsWith("image/svg+xml") ? /* @__PURE__ */ n(se, { src: u(), onLoad: y }) : e.urlType?.startsWith("image") ? U() : V();
|
132
128
|
case "uri":
|
133
129
|
return /* @__PURE__ */ n(
|
134
130
|
"img",
|
135
131
|
{
|
136
|
-
src:
|
137
|
-
onError: () =>
|
138
|
-
onLoad: () =>
|
132
|
+
src: c,
|
133
|
+
onError: () => l({ ...e, error: !0 }),
|
134
|
+
onLoad: () => l({ ...e, loading: !1 }),
|
139
135
|
alt: "NFT Display"
|
140
136
|
}
|
141
137
|
);
|
142
138
|
case "svg_gzipped": {
|
143
|
-
const
|
144
|
-
if (
|
139
|
+
const t = K.ungzip(ie(c), {}), s = C.from(t).toString("utf8");
|
140
|
+
if (E && !P(s))
|
145
141
|
throw new Error("Invalid SVG of type svg_gzipped");
|
146
|
-
const
|
147
|
-
return /* @__PURE__ */ n(
|
142
|
+
const o = B(j);
|
143
|
+
return /* @__PURE__ */ n(o, { svg: s });
|
148
144
|
}
|
149
145
|
case "svg": {
|
150
|
-
if (
|
146
|
+
if (E && !P(c))
|
151
147
|
throw new Error("Invalid SVG of type svg");
|
152
|
-
const
|
153
|
-
return /* @__PURE__ */ n(
|
148
|
+
const t = B(j);
|
149
|
+
return /* @__PURE__ */ n(t, { svg: c });
|
154
150
|
}
|
155
151
|
// TODO: 准备测试数据
|
156
152
|
case "html":
|
157
153
|
break;
|
158
154
|
default:
|
159
155
|
}
|
160
|
-
throw new Error(`unsupported display protocol: ${
|
156
|
+
throw new Error(`unsupported display protocol: ${F.type}`);
|
161
157
|
};
|
162
|
-
return
|
163
|
-
/* @__PURE__ */
|
164
|
-
(
|
165
|
-
|
158
|
+
return I(
|
159
|
+
/* @__PURE__ */ $(q, { children: [
|
160
|
+
(e.loading || !h) && (b ? b() : /* @__PURE__ */ n(re, {})),
|
161
|
+
_()
|
166
162
|
] })
|
167
163
|
);
|
168
|
-
} catch (
|
169
|
-
return console.error(
|
170
|
-
nftId:
|
171
|
-
vcId:
|
172
|
-
}),
|
164
|
+
} catch (p) {
|
165
|
+
return console.error(p?.message, {
|
166
|
+
nftId: i,
|
167
|
+
vcId: a?.current?.vcId
|
168
|
+
}), I(T ? T() : /* @__PURE__ */ n(A, {}));
|
173
169
|
}
|
174
170
|
}
|
175
|
-
const
|
171
|
+
const le = oe(Y)`
|
176
172
|
display: flex;
|
177
173
|
justify-content: center;
|
178
174
|
align-items: center;
|
@@ -200,13 +196,13 @@ const cr = nr(Z)`
|
|
200
196
|
height: 100%;
|
201
197
|
}
|
202
198
|
`;
|
203
|
-
function
|
204
|
-
return function({ aspect:
|
205
|
-
return
|
199
|
+
function pe(r) {
|
200
|
+
return function({ aspect: i = void 0, inset: f = !1, ...m }) {
|
201
|
+
return i && i > 0 && !f ? /* @__PURE__ */ n(Z, { aspect: i, children: /* @__PURE__ */ n(r, { inset: !0, ...m }) }) : /* @__PURE__ */ n(r, { inset: f, ...m });
|
206
202
|
};
|
207
203
|
}
|
208
|
-
const
|
204
|
+
const Ne = pe(ae);
|
209
205
|
export {
|
210
|
-
|
211
|
-
|
206
|
+
Ne as default,
|
207
|
+
Ue as getNFTData
|
212
208
|
};
|
@@ -1,16 +1,16 @@
|
|
1
|
-
import { jsx as
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
2
2
|
import m from "dompurify";
|
3
|
-
import { useAsyncEffect as
|
4
|
-
import
|
5
|
-
import { useState as
|
6
|
-
import
|
7
|
-
function
|
8
|
-
const [
|
9
|
-
return
|
10
|
-
const
|
11
|
-
s
|
12
|
-
}, []), /* @__PURE__ */
|
3
|
+
import { useAsyncEffect as a } from "ahooks";
|
4
|
+
import f from "axios";
|
5
|
+
import { useState as c } from "react";
|
6
|
+
import p from "./svg-embedder/inline-svg.js";
|
7
|
+
function x({ src: t, onLoad: o = void 0 }) {
|
8
|
+
const [e, n] = c("");
|
9
|
+
return a(async () => {
|
10
|
+
const r = await f.get(t), s = m.sanitize(r.data);
|
11
|
+
n(s), o?.();
|
12
|
+
}, []), /* @__PURE__ */ i(p, { svg: e });
|
13
13
|
}
|
14
14
|
export {
|
15
|
-
|
15
|
+
x as default
|
16
16
|
};
|