@arcblock/ux 3.1.27 → 3.1.30

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.
@@ -1,29 +1,18 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { InfoType as d } from "../types.js";
3
- import l from "../Content/tooltip-avatar.js";
4
- function u(i) {
5
- const { user: r, infoType: n, avatarSize: o = 48, shouldShowHoverCard: f = !1, renderCardContent: e, ...t } = i;
6
- return n === d.NameOnly ? /* @__PURE__ */ a(
7
- l,
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import d from "../Content/tooltip-avatar.js";
3
+ function p(r) {
4
+ const { user: o, infoType: f, avatarSize: t = 48, shouldShowHoverCard: a = !1, renderCardContent: e, ...n } = r;
5
+ return /* @__PURE__ */ s(
6
+ d,
8
7
  {
9
- user: r,
10
- avatarSize: o,
11
- shouldShowHoverCard: !1,
8
+ user: o,
9
+ avatarSize: t,
10
+ shouldShowHoverCard: a,
12
11
  renderCardContent: e,
13
- tooltipTitle: r.fullName || r.email || r.did,
14
- ...t
15
- }
16
- ) : /* @__PURE__ */ a(
17
- l,
18
- {
19
- user: r,
20
- avatarSize: o,
21
- shouldShowHoverCard: f,
22
- renderCardContent: e,
23
- ...t
12
+ ...n
24
13
  }
25
14
  );
26
15
  }
27
16
  export {
28
- u as default
17
+ p as default
29
18
  };
@@ -1,16 +1,8 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { InfoType as a } from "../types.js";
3
- import i from "./name-only.js";
4
- import m from "./basic-info.js";
5
- function l({ ...r }) {
6
- const { infoType: e = a.Minimal } = r;
7
- switch (e) {
8
- case a.NameOnly:
9
- return /* @__PURE__ */ t(i, { ...r });
10
- default:
11
- return /* @__PURE__ */ t(m, { ...r });
12
- }
2
+ import a from "./basic-info.js";
3
+ function i({ ...r }) {
4
+ return /* @__PURE__ */ t(a, { ...r });
13
5
  }
14
6
  export {
15
- l as default
7
+ i as default
16
8
  };
@@ -0,0 +1,7 @@
1
+ import { User, UserCardProps } from '../types';
2
+ type SocialActionsProps = Pick<UserCardProps, 'showSocialActions' | 'session'> & {
3
+ user: User;
4
+ };
5
+ declare function SocialActions({ showSocialActions, session, user }: SocialActionsProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export default SocialActions;
7
+ export declare const ButtonWrapper: import('@emotion/styled').StyledComponent<import('@mui/material').ButtonOwnProps & Omit<import('@mui/material').ButtonBaseOwnProps, "classes"> & import('@mui/material/OverridableComponent').CommonProps & Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "action" | "disabled" | "color" | "className" | "style" | "classes" | "children" | "sx" | "variant" | "tabIndex" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "href" | "loading" | "loadingIndicator" | "loadingPosition" | "size" | "startIcon"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
@@ -0,0 +1,112 @@
1
+ import { jsxs as m, jsx as s } from "react/jsx-runtime";
2
+ import { useMemo as r } from "react";
3
+ import { styled as C, Button as F, Box as M } from "@mui/material";
4
+ import { useMemoizedFn as u } from "ahooks";
5
+ import { joinURL as N } from "ufo";
6
+ import w from "lodash/noop";
7
+ import { Icon as U } from "@iconify/react";
8
+ import k from "@mui/icons-material/Notifications";
9
+ import v from "@mui/icons-material/NotificationsOff";
10
+ import z from "../use-follow.js";
11
+ import { useLocaleContext as h } from "../../Locale/context.js";
12
+ import { translate as g } from "../../Locale/util.js";
13
+ import { isSupportFollow as L } from "../../Util/index.js";
14
+ const _ = {
15
+ zh: {
16
+ chat: "聊天",
17
+ follow: "关注",
18
+ unfollow: "取消关注",
19
+ follow_success: "关注成功",
20
+ unfollow_success: "取消关注成功"
21
+ },
22
+ en: {
23
+ chat: "Chat",
24
+ follow: "Follow",
25
+ unfollow: "Unfollow",
26
+ follow_success: "Follow success",
27
+ unfollow_success: "Unfollow success"
28
+ }
29
+ }, P = () => {
30
+ const { componentMountPoints: o = [] } = window.blocklet || {};
31
+ return o.find((n) => n.name === "did-comments")?.mountPoint;
32
+ };
33
+ function j({
34
+ user: o,
35
+ showSocialActions: t,
36
+ session: n
37
+ }) {
38
+ const { locale: i } = h() || { locale: "en" }, e = u((a, f = {}) => g(_, a, i, "en", f)), d = r(() => !!n?.user?.did, [n?.user?.did]), l = r(() => P(), []), c = u(() => {
39
+ if (!d) {
40
+ n?.login(w, {
41
+ openMode: "redirect",
42
+ redirect: window.location.href
43
+ });
44
+ return;
45
+ }
46
+ window.open(N(l, `/chat/dm/${o?.did}`), "_blank");
47
+ });
48
+ return r(() => (typeof t == "boolean" ? !!t : t?.chat) && !!l, [t, l]) ? /* @__PURE__ */ m(
49
+ x,
50
+ {
51
+ className: "user-card__social-actions-chat",
52
+ variant: "outlined",
53
+ color: "inherit",
54
+ onClick: c,
55
+ children: [
56
+ /* @__PURE__ */ s(U, { icon: "tabler:message-dots", style: { marginRight: 4 } }),
57
+ e("chat")
58
+ ]
59
+ }
60
+ ) : null;
61
+ }
62
+ function B({
63
+ user: o,
64
+ showSocialActions: t,
65
+ session: n
66
+ }) {
67
+ const { locale: i } = h() || { locale: "en" }, e = u((b, y = {}) => g(_, b, i, "en", y)), d = r(() => !!n?.user?.did, [n?.user?.did]), l = r(() => typeof t == "boolean" ? !!t : t?.follow, [t]), { followed: c, followUser: p, unfollowUser: a } = z({
68
+ user: o,
69
+ t: e,
70
+ isMySelf: !1,
71
+ visible: !!l
72
+ }), f = u(() => {
73
+ if (!d) {
74
+ n?.login(w, {
75
+ openMode: "redirect",
76
+ redirect: window.location.href
77
+ });
78
+ return;
79
+ }
80
+ c ? a(o.did) : p(o.did);
81
+ });
82
+ return l ? /* @__PURE__ */ m(
83
+ x,
84
+ {
85
+ className: "user-card__social-actions-follow",
86
+ variant: "outlined",
87
+ color: "inherit",
88
+ onClick: f,
89
+ children: [
90
+ c ? /* @__PURE__ */ s(v, { sx: { fontSize: 14, mr: 0.5 } }) : /* @__PURE__ */ s(k, { sx: { fontSize: 14, mr: 0.5 } }),
91
+ e(c ? "unfollow" : "follow")
92
+ ]
93
+ }
94
+ ) : null;
95
+ }
96
+ function Q({ showSocialActions: o, session: t, user: n }) {
97
+ const i = r(() => t?.user?.did === n?.did, [t?.user?.did, n?.did]), e = r(() => L(), []);
98
+ return i || !e || !o ? null : /* @__PURE__ */ m(M, { className: "user-card__social-actions", sx: { display: "flex", gap: 1 }, children: [
99
+ /* @__PURE__ */ s(j, { session: t, user: n, showSocialActions: o }),
100
+ /* @__PURE__ */ s(B, { session: t, user: n, showSocialActions: o })
101
+ ] });
102
+ }
103
+ const x = C(F)`
104
+ color: ${({ theme: o }) => o.palette.text.primary};
105
+ font-weight: 500;
106
+ border-color: ${({ theme: o }) => o.palette.grey[300]};
107
+ line-height: 1.5;
108
+ `;
109
+ export {
110
+ x as ButtonWrapper,
111
+ Q as default
112
+ };
@@ -1,27 +1,28 @@
1
- import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
- import { memo as x } from "react";
3
- import { Box as o, Typography as g } from "@mui/material";
1
+ import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
+ import { memo as u } from "react";
3
+ import { Box as r, Typography as g } from "@mui/material";
4
4
  import { DID as y } from "../../DID/index.js";
5
5
  import C from "./tooltip-avatar.js";
6
6
  import { renderTopRight as b } from "../components.js";
7
- import v from "./shorten-label.js";
8
- function W({ ...n }) {
7
+ import S from "./shorten-label.js";
8
+ import v from "../Cards/social-actions.js";
9
+ function w({ ...a }) {
9
10
  const {
10
11
  user: e,
11
- showDid: a,
12
+ showDid: s,
12
13
  didProps: l,
13
- avatarSize: s,
14
- shouldShowHoverCard: d,
15
- renderCardContent: m,
14
+ avatarSize: d,
15
+ shouldShowHoverCard: m,
16
+ renderCardContent: c,
16
17
  renderTopRightContent: p,
17
- topRightMaxWidth: c,
18
- avatarProps: f,
19
- shortenLabelProps: h,
20
- renderName: i,
21
- ...u
22
- } = n;
23
- return /* @__PURE__ */ r(
24
- o,
18
+ topRightMaxWidth: f,
19
+ avatarProps: h,
20
+ shortenLabelProps: x,
21
+ renderName: n,
22
+ ...i
23
+ } = a;
24
+ return /* @__PURE__ */ o(
25
+ r,
25
26
  {
26
27
  className: "user-card__avatar-content",
27
28
  sx: {
@@ -30,56 +31,70 @@ function W({ ...n }) {
30
31
  alignItems: "center"
31
32
  },
32
33
  children: [
33
- /* @__PURE__ */ r(
34
- o,
34
+ /* @__PURE__ */ o(
35
+ r,
35
36
  {
36
37
  sx: {
37
38
  display: "flex",
38
- justifyContent: "flex-start",
39
+ justifyContent: "space-between",
39
40
  alignItems: "center",
40
41
  gap: 1,
41
42
  flex: 1,
42
43
  minWidth: 0
43
44
  },
44
45
  children: [
45
- /* @__PURE__ */ t(
46
- C,
47
- {
48
- user: e,
49
- avatarSize: s,
50
- shouldShowHoverCard: d,
51
- renderCardContent: m,
52
- avatarProps: f,
53
- ...u
54
- }
55
- ),
56
- /* @__PURE__ */ r(o, { children: [
46
+ /* @__PURE__ */ o(r, { sx: { display: "flex", justifyContent: "flex-start", alignItems: "center", gap: 1, flex: 1 }, children: [
57
47
  /* @__PURE__ */ t(
58
- g,
48
+ C,
59
49
  {
60
- variant: "subtitle1",
61
- className: "user-card__full-name-label",
62
- noWrap: !0,
63
- sx: {
64
- fontWeight: 500,
65
- color: "text.primary",
66
- fontSize: 18,
67
- lineHeight: 1.1
68
- },
69
- children: i ? i(e) : /* @__PURE__ */ t(v, { sx: { fontWeight: 500 }, ...h, children: e.fullName || e.email || e.did })
50
+ user: e,
51
+ avatarSize: d,
52
+ shouldShowHoverCard: m,
53
+ renderCardContent: c,
54
+ avatarProps: h,
55
+ ...i
70
56
  }
71
57
  ),
72
- a && e.did ? /* @__PURE__ */ t(y, { did: e.did, size: 14, copyable: !0, compact: !0, locale: "en", sx: { lineHeight: 1.5 }, ...l ?? {} }) : null
73
- ] })
58
+ /* @__PURE__ */ o(r, { children: [
59
+ /* @__PURE__ */ t(
60
+ g,
61
+ {
62
+ variant: "subtitle1",
63
+ className: "user-card__full-name-label",
64
+ noWrap: !0,
65
+ sx: {
66
+ fontWeight: 500,
67
+ color: "text.primary",
68
+ fontSize: 18,
69
+ lineHeight: 1.1
70
+ },
71
+ children: n ? n(e) : /* @__PURE__ */ t(S, { sx: { fontWeight: 500 }, ...x, children: e.fullName || e.email || e.did })
72
+ }
73
+ ),
74
+ s && e.did ? /* @__PURE__ */ t(
75
+ y,
76
+ {
77
+ did: e.did,
78
+ size: 14,
79
+ copyable: !0,
80
+ compact: !0,
81
+ locale: "en",
82
+ sx: { lineHeight: 1.5 },
83
+ ...l ?? {}
84
+ }
85
+ ) : null
86
+ ] })
87
+ ] }),
88
+ /* @__PURE__ */ t(v, { showSocialActions: i.showSocialActions, user: e, session: i.session })
74
89
  ]
75
90
  }
76
91
  ),
77
- b(p, c)
92
+ b(p, f)
78
93
  ]
79
94
  }
80
95
  );
81
96
  }
82
- const D = x(W);
97
+ const D = u(w);
83
98
  export {
84
99
  D as default
85
100
  };
@@ -1,4 +1,6 @@
1
1
  import { User, UserCardProps } from './types';
2
+ import { default as SocialActions } from './Cards/social-actions';
2
3
  export declare function createNameOnlyAvatar(user: User): string | null;
3
4
  declare function UserCard(props: UserCardProps): import("react/jsx-runtime").JSX.Element;
4
5
  export default UserCard;
6
+ export { SocialActions };
@@ -1,11 +1,12 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { useRef as v, useState as C, useEffect as y, useMemo as P } from "react";
3
- import { CardType as o } from "./types.js";
4
- import A from "./Cards/avatar-only.js";
5
- import m from "./Cards/index.js";
6
- import D from "./Container/dialog.js";
7
- import S from "./Container/card.js";
8
- import w from "../Avatar/index.js";
2
+ import { useRef as v, useState as A, useEffect as C, useMemo as S } from "react";
3
+ import { CardType as d } from "./types.js";
4
+ import y from "./Cards/avatar-only.js";
5
+ import c from "./Cards/index.js";
6
+ import w from "./Container/dialog.js";
7
+ import P from "./Container/card.js";
8
+ import D from "../Avatar/index.js";
9
+ import { default as j } from "./Cards/social-actions.js";
9
10
  import { isUserDid as x, getUserByDid as U } from "./utils.js";
10
11
  function L(e) {
11
12
  if (!e) return null;
@@ -13,64 +14,66 @@ function L(e) {
13
14
  return e.fullName ? r = e.fullName.charAt(0).toUpperCase() : e.email ? r = e.email.split("@")[0].charAt(0).toUpperCase() : r = e.did ? e.did.charAt(0).toUpperCase() : "?", r;
14
15
  }
15
16
  function B(e) {
16
- const { cardType: r = o.Detailed, showHoverCard: l } = e, u = l !== void 0 ? l : r === o.AvatarOnly, c = v(null), [i, f] = C(() => e.user || null);
17
- y(() => {
17
+ const { cardType: r = d.Detailed, showHoverCard: l } = e, u = l !== void 0 ? l : r === d.AvatarOnly, m = v(null), [i, s] = A(() => e.user || null);
18
+ C(() => {
18
19
  let a = !0;
19
- return e.user ? f(e.user) : e.did && x(e.did) && !e.user && U(e.did).then((d) => {
20
- a && f(d || { fullName: "Anonymous", did: e.did, avatar: "" });
20
+ return e.user ? s(e.user) : e.did && x(e.did) && !e.user && U(e.did).then((n) => {
21
+ a && s(n || { fullName: "Anonymous", did: e.did, avatar: "" });
21
22
  }), () => {
22
23
  a = !1;
23
24
  };
24
25
  }, [e.did, e.user]);
25
- const n = P(() => {
26
+ const o = S(() => {
26
27
  if (!i)
27
28
  return null;
28
- const { avatar: a = "", ...d } = i;
29
+ const { avatar: a = "", ...n } = i;
29
30
  if (a) {
30
31
  const h = a.split("?")[1] || "";
31
32
  return {
32
- ...d,
33
+ ...n,
33
34
  avatar: h ? a : `${a}?imageFilter=resize&w=48&h=48`
34
35
  };
35
36
  }
36
37
  return i;
37
38
  }, [i]);
38
- if (!n)
39
- return /* @__PURE__ */ t(w, { did: e.did, size: e.avatarSize, useProxyFallback: !0, ...e.avatarProps });
40
- const s = () => /* @__PURE__ */ t(D, { sx: e.popupSx, children: /* @__PURE__ */ t(
41
- m,
39
+ if (!o)
40
+ return /* @__PURE__ */ t(D, { did: e.did, size: e.avatarSize, useProxyFallback: !0, ...e.avatarProps });
41
+ const f = () => /* @__PURE__ */ t(w, { sx: e.popupSx, children: /* @__PURE__ */ t(
42
+ c,
42
43
  {
43
44
  ...e,
44
45
  shouldShowHoverCard: !1,
45
- user: n,
46
+ user: o,
46
47
  avatarProps: e.popupAvatarProps,
47
48
  shortenLabelProps: e.popupShortenLabelProps || e.shortenLabelProps,
48
49
  renderFields: e.popupRenderFields,
49
50
  renderName: e.popupRenderName,
50
51
  infoType: e.popupInfoType || e.infoType,
51
52
  didProps: e.popupDidProps || e.didProps,
52
- showDid: e.popupShowDid || e.showDid
53
+ showDid: e.popupShowDid || e.showDid,
54
+ showSocialActions: e.popupShowSocialActions === void 0 ? e.showSocialActions : e.popupShowSocialActions
53
55
  }
54
56
  ) });
55
- return r === o.AvatarOnly ? /* @__PURE__ */ t(
56
- A,
57
+ return r === d.AvatarOnly ? /* @__PURE__ */ t(
58
+ y,
57
59
  {
58
60
  ...e,
59
61
  shouldShowHoverCard: u,
60
- renderCardContent: s,
61
- user: n
62
+ renderCardContent: f,
63
+ user: o
62
64
  }
63
- ) : /* @__PURE__ */ t(S, { containerRef: c, cardType: r, sx: e.sx, children: /* @__PURE__ */ t(
64
- m,
65
+ ) : /* @__PURE__ */ t(P, { containerRef: m, cardType: r, sx: e.sx, children: /* @__PURE__ */ t(
66
+ c,
65
67
  {
66
68
  ...e,
67
69
  shouldShowHoverCard: u,
68
- renderCardContent: s,
69
- user: n
70
+ renderCardContent: f,
71
+ user: o
70
72
  }
71
73
  ) });
72
74
  }
73
75
  export {
76
+ j as SocialActions,
74
77
  L as createNameOnlyAvatar,
75
78
  B as default
76
79
  };
@@ -3,6 +3,7 @@ import { SxProps, Theme, TooltipProps } from '@mui/material';
3
3
  import { DIDProps } from '../DID';
4
4
  import { AvatarProps } from '../Avatar';
5
5
  import { ShortenLabelProps } from './Content/shorten-label';
6
+ import { Session } from '../type';
6
7
  type UserPublicInfo = {
7
8
  avatar: string;
8
9
  did: string;
@@ -85,11 +86,15 @@ export declare enum CardType {
85
86
  Detailed = "Detailed"
86
87
  }
87
88
  export declare enum InfoType {
88
- NameOnly = "NameOnly",// 仅显示名称
89
89
  Minimal = "Minimal",// 极简模式,显示头像、名称和DID
90
90
  Basic = "Basic"
91
91
  }
92
+ export type SocialActionProps = {
93
+ chat: boolean;
94
+ follow: boolean;
95
+ };
92
96
  export interface UserCardProps {
97
+ session?: Session;
93
98
  user?: User;
94
99
  did?: string;
95
100
  cardType?: CardType;
@@ -114,6 +119,8 @@ export interface UserCardProps {
114
119
  popupRenderFields?: string[];
115
120
  renderTopRightContent?: () => React.ReactNode;
116
121
  topRightMaxWidth?: number;
122
+ showSocialActions?: SocialActionProps | boolean;
123
+ popupShowSocialActions?: SocialActionProps | boolean;
117
124
  renderCustomContent?: () => React.ReactNode;
118
125
  onAvatarClick?: (user: User, e?: React.MouseEvent<HTMLDivElement>) => void;
119
126
  }
@@ -1,15 +1,15 @@
1
1
  var r = /* @__PURE__ */ ((e) => (e.NoClear = "no_clear", e.ThirtyMinutes = "30_minutes", e.OneHour = "1_hour", e.FourHours = "4_hours", e.Today = "today", e.ThisWeek = "this_week", e.Custom = "custom", e))(r || {}), i = /* @__PURE__ */ ((e) => (e.Meeting = "meeting", e.Community = "community", e.Holiday = "holiday", e.OffSick = "off_sick", e.WorkingRemotely = "working_remotely", e))(i || {});
2
- const o = {
2
+ const a = {
3
3
  small: 32,
4
4
  medium: 40,
5
5
  large: 48,
6
6
  xlarge: 64
7
7
  };
8
- var l = /* @__PURE__ */ ((e) => (e.AvatarOnly = "AvatarOnly", e.Detailed = "Detailed", e))(l || {}), a = /* @__PURE__ */ ((e) => (e.NameOnly = "NameOnly", e.Minimal = "Minimal", e.Basic = "Basic", e))(a || {});
8
+ var l = /* @__PURE__ */ ((e) => (e.AvatarOnly = "AvatarOnly", e.Detailed = "Detailed", e))(l || {}), o = /* @__PURE__ */ ((e) => (e.Minimal = "Minimal", e.Basic = "Basic", e))(o || {});
9
9
  export {
10
- o as AvatarSize,
10
+ a as AvatarSize,
11
11
  l as CardType,
12
12
  r as DurationEnum,
13
- a as InfoType,
13
+ o as InfoType,
14
14
  i as StatusEnum
15
15
  };
@@ -0,0 +1,16 @@
1
+ import { AxiosError } from 'axios';
2
+ import { User } from './types';
3
+ export declare const formatAxiosError: (err: AxiosError) => string;
4
+ /**
5
+ * 登录用户与当前用户(userDid)的关注关系
6
+ */
7
+ export default function useFollow({ user, t, isMySelf, visible, }: {
8
+ user: User;
9
+ t: (k: string) => string;
10
+ isMySelf: boolean;
11
+ visible: boolean;
12
+ }): {
13
+ followed: boolean;
14
+ followUser: (this: unknown, followUserDid?: string | undefined) => Promise<void>;
15
+ unfollowUser: (this: unknown, unfollowUserDid?: string | undefined) => Promise<void>;
16
+ };
@@ -0,0 +1,67 @@
1
+ import { useState as y, useMemo as f, useEffect as d } from "react";
2
+ import { useMemoizedFn as w } from "ahooks";
3
+ import U from "lodash/isNil";
4
+ import { BlockletSDK as x } from "@blocklet/js-sdk";
5
+ import u from "../Toast/index.js";
6
+ const F = (r) => {
7
+ const { response: t } = r;
8
+ return t ? `Request failed: ${t.status} ${t.statusText}: ${JSON.stringify(t.data)}` : r.message;
9
+ };
10
+ function z({
11
+ user: r,
12
+ t,
13
+ isMySelf: n,
14
+ visible: m
15
+ }) {
16
+ const [p, c] = y(!1), s = f(() => r?.did, [r]), i = f(() => Object.prototype.hasOwnProperty.call(r, "isFollowing") && !U(r.isFollowing), [r]), e = f(() => {
17
+ let o = null;
18
+ try {
19
+ o = new x();
20
+ } catch (l) {
21
+ console.error("Failed to initialize BlockletSDK:", l), o = null;
22
+ }
23
+ return o;
24
+ }, []), a = w(async () => {
25
+ if (!e) {
26
+ c(!1);
27
+ return;
28
+ }
29
+ try {
30
+ if (n) {
31
+ c(!0);
32
+ return;
33
+ }
34
+ const o = await e.user.isFollowingUser({ userDid: s });
35
+ c(o);
36
+ } catch (o) {
37
+ console.error(o);
38
+ }
39
+ }), g = w(async (o = s) => {
40
+ if (!(!e || n && o === s))
41
+ try {
42
+ await e.user.followUser({ userDid: o }), u.success(t("follow_success")), a();
43
+ } catch (l) {
44
+ console.error(l), u.error(F(l));
45
+ }
46
+ }), h = w(async (o = s) => {
47
+ if (!(!e || n && o === s))
48
+ try {
49
+ await e.user.unfollowUser({ userDid: o }), u.success(t("unfollow_success")), a();
50
+ } catch (l) {
51
+ console.error(l), u.error(F(l));
52
+ }
53
+ });
54
+ return d(() => {
55
+ m && s && !n && e && !i && a();
56
+ }, [a, s, n, e, i, m]), d(() => {
57
+ i && c(r?.isFollowing || !1);
58
+ }, [i, r]), {
59
+ followed: p,
60
+ followUser: g,
61
+ unfollowUser: h
62
+ };
63
+ }
64
+ export {
65
+ z as default,
66
+ F as formatAxiosError
67
+ };
@@ -106,3 +106,18 @@ export declare const cleanedObj: (obj: object) => import('lodash').Dictionary<an
106
106
  * @returns RGBA 颜色字符串 (例如: "rgba(255, 0, 0, 1)")
107
107
  */
108
108
  export declare function hexToRgba(hex: string, alpha?: number): string;
109
+ export declare const getServerVersion: () => any;
110
+ export declare const getUxPackageVersion: () => string;
111
+ export declare const getJsSdkVersion: () => string;
112
+ /**
113
+ * 比较两个版本号,version1 是否大于等于 version2
114
+ * @param {*} version1
115
+ * @param {*} version2
116
+ * @returns boolean
117
+ */
118
+ export declare const compareVersions: (version1: string, version2: string) => boolean;
119
+ /**
120
+ * 是否支持用户的 follow 关系
121
+ * 通过 server 的版本和 ux 的版本共同决定
122
+ */
123
+ export declare const isSupportFollow: () => boolean;