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