@arcblock/ux 3.1.28 → 3.1.31

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 (50) hide show
  1. package/lib/SessionUser/components/logged-in.js +41 -39
  2. package/lib/UserCard/Cards/avatar-only.js +11 -22
  3. package/lib/UserCard/Cards/index.js +4 -12
  4. package/lib/UserCard/Cards/social-actions.d.ts +7 -0
  5. package/lib/UserCard/Cards/social-actions.js +112 -0
  6. package/lib/UserCard/Content/minimal.js +62 -47
  7. package/lib/UserCard/index.d.ts +2 -0
  8. package/lib/UserCard/index.js +31 -28
  9. package/lib/UserCard/types.d.ts +8 -1
  10. package/lib/UserCard/types.js +4 -4
  11. package/lib/UserCard/use-follow.d.ts +16 -0
  12. package/lib/UserCard/use-follow.js +67 -0
  13. package/lib/Util/index.d.ts +15 -0
  14. package/lib/Util/index.js +191 -171
  15. package/lib/package.json.js +9 -0
  16. package/lib/withTracker/action/bind-wallet.d.ts +14 -0
  17. package/lib/withTracker/action/bind-wallet.js +1 -0
  18. package/lib/withTracker/action/login.d.ts +15 -0
  19. package/lib/withTracker/action/login.js +1 -0
  20. package/lib/withTracker/action/pay.d.ts +12 -0
  21. package/lib/withTracker/action/pay.js +1 -0
  22. package/lib/withTracker/action/switch-passport.d.ts +18 -0
  23. package/lib/withTracker/action/switch-passport.js +1 -0
  24. package/lib/withTracker/constant/index.d.ts +3 -0
  25. package/lib/withTracker/constant/index.js +6 -0
  26. package/lib/withTracker/env.d.ts +1 -0
  27. package/lib/withTracker/env.js +4 -0
  28. package/lib/withTracker/index.d.ts +2 -0
  29. package/lib/withTracker/index.js +21 -17
  30. package/package.json +10 -8
  31. package/src/SessionUser/components/logged-in.tsx +2 -0
  32. package/src/UserCard/Cards/avatar-only.tsx +1 -15
  33. package/src/UserCard/Cards/index.tsx +2 -11
  34. package/src/UserCard/Cards/social-actions.tsx +196 -0
  35. package/src/UserCard/Content/minimal.tsx +43 -31
  36. package/src/UserCard/UserCard.stories.jsx +1 -0
  37. package/src/UserCard/index.tsx +6 -0
  38. package/src/UserCard/types.ts +10 -1
  39. package/src/UserCard/use-follow.tsx +119 -0
  40. package/src/Util/index.ts +67 -0
  41. package/src/withTracker/action/bind-wallet.tsx +17 -0
  42. package/src/withTracker/action/login.tsx +18 -0
  43. package/src/withTracker/action/pay.tsx +14 -0
  44. package/src/withTracker/action/switch-passport.tsx +20 -0
  45. package/src/withTracker/constant/index.tsx +3 -0
  46. package/src/withTracker/env.tsx +1 -0
  47. package/src/withTracker/index.tsx +8 -11
  48. package/lib/UserCard/Cards/name-only.d.ts +0 -5
  49. package/lib/UserCard/Cards/name-only.js +0 -13
  50. package/src/UserCard/Cards/name-only.tsx +0 -17
@@ -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;
package/lib/Util/index.js CHANGED
@@ -1,70 +1,72 @@
1
- import { lazy as x } from "react";
2
- import l from "lodash/padStart";
3
- import { colors as g, getDIDMotifInfo as E } from "@arcblock/did-motif";
4
- import { mergeAllThemeOptions as vt } from "@blocklet/theme";
5
- import y from "lodash/isNil";
6
- import j from "lodash/omitBy";
7
- import k from "p-retry";
8
- import u from "js-cookie";
9
- import O from "color-convert";
1
+ import { lazy as j } from "react";
2
+ import u from "lodash/padStart";
3
+ import { colors as w, getDIDMotifInfo as x } from "@arcblock/did-motif";
4
+ import { mergeAllThemeOptions as Ke } from "@blocklet/theme";
5
+ import I from "lodash/isNil";
6
+ import E from "lodash/omitBy";
7
+ import U from "p-retry";
8
+ import m from "js-cookie";
9
+ import v from "color-convert";
10
10
  import a from "dayjs";
11
11
  import "dayjs/locale/zh-cn";
12
- import U from "dayjs/plugin/utc";
13
- import A from "dayjs/plugin/timezone";
14
- import F from "dayjs/plugin/relativeTime";
15
- import R from "dayjs/plugin/updateLocale";
16
- import W from "dayjs/plugin/localizedFormat";
17
- import { DID_PREFIX as L, BLOCKLET_SERVICE_PATH_PREFIX as P } from "./constant.js";
18
- import { getFederatedEnabled as v } from "./federated.js";
19
- let f = null;
20
- const C = /^(\d{1,3}\.){3}\d{1,3}(:\d+)?$/, M = /* @__PURE__ */ new Set(["co", "com", "net", "org", "gov", "edu", "ac"]), V = /* @__PURE__ */ new Set(["uk", "au", "cn", "nz", "za", "in", "br", "mx", "fr", "it", "ca"]);
21
- function _(t) {
22
- if (!t)
12
+ import F from "dayjs/plugin/utc";
13
+ import O from "dayjs/plugin/timezone";
14
+ import A from "dayjs/plugin/relativeTime";
15
+ import P from "dayjs/plugin/updateLocale";
16
+ import R from "dayjs/plugin/localizedFormat";
17
+ import W from "semver";
18
+ import { DID_PREFIX as L, BLOCKLET_SERVICE_PATH_PREFIX as C } from "./constant.js";
19
+ import b from "../package.json.js";
20
+ import { getFederatedEnabled as M } from "./federated.js";
21
+ let l = null;
22
+ const _ = /^(\d{1,3}\.){3}\d{1,3}(:\d+)?$/, z = /* @__PURE__ */ new Set(["co", "com", "net", "org", "gov", "edu", "ac"]), B = /* @__PURE__ */ new Set(["uk", "au", "cn", "nz", "za", "in", "br", "mx", "fr", "it", "ca"]);
23
+ function N(e) {
24
+ if (!e)
23
25
  return !1;
24
- const e = t.split(".");
25
- if (e.length < 2) return !1;
26
- const o = e[e.length - 2], n = e[e.length - 1];
27
- return M.has(o) && V.has(n);
26
+ const t = e.split(".");
27
+ if (t.length < 2) return !1;
28
+ const o = t[t.length - 2], n = t[t.length - 1];
29
+ return z.has(o) && B.has(n);
28
30
  }
29
- function lt() {
30
- const { host: t } = window.location;
31
- if (!t || C.test(t))
31
+ function ye() {
32
+ const { host: e } = window.location;
33
+ if (!e || _.test(e))
32
34
  return "";
33
- const o = t.split(":")[0].split(".");
35
+ const o = e.split(":")[0].split(".");
34
36
  if (o.length === 1)
35
37
  return "";
36
38
  if (o.length > 2) {
37
39
  const n = o.slice(-2).join(".");
38
- if (_(n))
40
+ if (N(n))
39
41
  return `.${o.slice(-3).join(".")}`;
40
42
  }
41
43
  return `.${o.slice(-2).join(".")}`;
42
44
  }
43
- function ut(t) {
44
- return t.replace(/^\?/, "").split("&").map((e) => e.split("=")).filter(([e]) => !!e).reduce((e, o) => {
45
+ function Ie(e) {
46
+ return e.replace(/^\?/, "").split("&").map((t) => t.split("=")).filter(([t]) => !!t).reduce((t, o) => {
45
47
  const n = o[0], i = decodeURIComponent(o[1]) || !0;
46
- return e[n] = i, e;
48
+ return t[n] = i, t;
47
49
  }, {});
48
50
  }
49
- function mt(t = {}) {
50
- return new URLSearchParams(t).toString();
51
+ function be(e = {}) {
52
+ return new URLSearchParams(e).toString();
51
53
  }
52
- function dt(t = 1) {
53
- let e = t;
54
- typeof e == "number" && (e = { expireInDays: e }), e.path === void 0 && (e.path = "/"), e.expireInDays || (e.expireInDays = 1);
54
+ function Se(e = 1) {
55
+ let t = e;
56
+ typeof t == "number" && (t = { expireInDays: t }), t.path === void 0 && (t.path = "/"), t.expireInDays || (t.expireInDays = 1);
55
57
  const o = {
56
- expires: e.expireInDays,
57
- path: e.path,
58
- domain: e.domain || "",
59
- sameSite: e.sameSite || "Lax",
58
+ expires: t.expireInDays,
59
+ path: t.path,
60
+ domain: t.domain || "",
61
+ sameSite: t.sameSite || "Lax",
60
62
  // 允许自定义设置为 false,默认是 true
61
- secure: e.secure !== !1
63
+ secure: t.secure !== !1
62
64
  };
63
- return (typeof window > "u" || e.domain || e.returnDomain === !1) && e.returnDomain === !1 && delete o.domain, o;
65
+ return (typeof window > "u" || t.domain || t.returnDomain === !1) && t.returnDomain === !1 && delete o.domain, o;
64
66
  }
65
- const pt = (t) => t.color ? t.color : t.dark ? t.theme.palette.common.white : t.theme.palette.text.primary, ht = (t) => t.background ? t.background : t.dark ? t.theme.palette.common.black : t.theme.palette.common.white;
66
- function gt(t, e, o = []) {
67
- const n = Object.assign({}, t), i = e.defaultProps || {};
67
+ const De = (e) => e.color ? e.color : e.dark ? e.theme.palette.common.white : e.theme.palette.text.primary, ke = (e) => e.background ? e.background : e.dark ? e.theme.palette.common.black : e.theme.palette.common.white;
68
+ function Ve(e, t, o = []) {
69
+ const n = Object.assign({}, e), i = t.defaultProps || {};
68
70
  return Object.keys(i).forEach((r) => {
69
71
  typeof n[r] == "string" && n[r].indexOf("::prop::") === 0 && (n[r] = i[r]);
70
72
  }), Array.isArray(o) && o.forEach((r) => {
@@ -77,32 +79,32 @@ function gt(t, e, o = []) {
77
79
  typeof n[r] == "string" && n[r].indexOf("::prop::") === 0 && (n[r] = "");
78
80
  }), n;
79
81
  }
80
- function wt(t = 2017) {
81
- const e = (/* @__PURE__ */ new Date()).getFullYear();
82
- return `${e}` == `${t}` ? `© ArcBlock ${e}` : `© ArcBlock ${t} - ${e}`;
82
+ function $e(e = 2017) {
83
+ const t = (/* @__PURE__ */ new Date()).getFullYear();
84
+ return `${t}` == `${e}` ? `© ArcBlock ${t}` : `© ArcBlock ${e} - ${t}`;
83
85
  }
84
- const yt = () => typeof Intl == "object" && typeof Intl.DateTimeFormat == "function" && typeof Intl.DateTimeFormat().resolvedOptions == "function" ? Intl.DateTimeFormat().resolvedOptions().timeZone : "", It = (t) => {
85
- let e = 0;
86
- for (let n = 0; n < t.length; n++)
87
- e = t.charCodeAt(n) + ((e << 5) - e);
86
+ const Te = () => typeof Intl == "object" && typeof Intl.DateTimeFormat == "function" && typeof Intl.DateTimeFormat().resolvedOptions == "function" ? Intl.DateTimeFormat().resolvedOptions().timeZone : "", je = (e) => {
87
+ let t = 0;
88
+ for (let n = 0; n < e.length; n++)
89
+ t = e.charCodeAt(n) + ((t << 5) - t);
88
90
  let o = "#";
89
91
  for (let n = 0; n < 3; n++) {
90
- const i = e >> n * 8 & 255;
92
+ const i = t >> n * 8 & 255;
91
93
  o += `00${i.toString(16)}`.substr(-2);
92
94
  }
93
95
  return o;
94
- }, bt = (t) => {
95
- const e = Math.round(t / 1e3), o = Math.floor(e / 3600), n = Math.floor((e - o * 3600) / 60), i = e % 60;
96
- return `${l(o, 2, "0")}:${l(n, 2, "0")}:${l(i, 2, "0")}`;
96
+ }, xe = (e) => {
97
+ const t = Math.round(e / 1e3), o = Math.floor(t / 3600), n = Math.floor((t - o * 3600) / 60), i = t % 60;
98
+ return `${u(o, 2, "0")}:${u(n, 2, "0")}:${u(i, 2, "0")}`;
97
99
  };
98
- function z(t) {
99
- f = t;
100
+ function X(e) {
101
+ l = e;
100
102
  }
101
- function Dt() {
102
- return f;
103
+ function Ee() {
104
+ return l;
103
105
  }
104
- const I = (t) => (e, { locale: o, tz: n, isUtc: i } = {}) => {
105
- if (f === null && (a.extend(W), a.extend(U), a.extend(A), a.extend(R), a.extend(F), a.updateLocale("zh-cn", {
106
+ const S = (e) => (t, { locale: o, tz: n, isUtc: i } = {}) => {
107
+ if (l === null && (a.extend(R), a.extend(F), a.extend(O), a.extend(P), a.extend(A), a.updateLocale("zh-cn", {
106
108
  // copy with https://github.com/iamkun/dayjs/blob/dev/src/locale/zh-cn.js
107
109
  relativeTime: {
108
110
  future: "%s后",
@@ -119,49 +121,49 @@ const I = (t) => (e, { locale: o, tz: n, isUtc: i } = {}) => {
119
121
  y: "1 年",
120
122
  yy: "%d 年"
121
123
  }
122
- }), z(a)), y(e) || e === "")
124
+ }), X(a)), I(t) || t === "")
123
125
  return "-";
124
- let r = f(e);
125
- return n && (r = r.tz(n)), i && (r = r.utc()), typeof o < "u" && (r = r.locale(o)), r.format(t);
126
+ let r = l(t);
127
+ return n && (r = r.tz(n)), i && (r = r.utc()), typeof o < "u" && (r = r.locale(o)), r.format(e);
126
128
  };
127
- function $t(t, { locale: e = "en", tz: o } = {}) {
128
- return I("ll")(t, { locale: e, tz: o });
129
+ function Ue(e, { locale: t = "en", tz: o } = {}) {
130
+ return S("ll")(e, { locale: t, tz: o });
129
131
  }
130
- function Tt(t, {
131
- locale: e = "en",
132
+ function ve(e, {
133
+ locale: t = "en",
132
134
  tz: o,
133
135
  isUtc: n = !1,
134
136
  format: i = "lll"
135
137
  } = {}) {
136
- return I(i)(t, { locale: e, tz: o, isUtc: n });
138
+ return S(i)(e, { locale: t, tz: o, isUtc: n });
137
139
  }
138
- function B() {
139
- const t = window?.ABT_DEV || window.ABT;
140
- return t && typeof t.open == "function" ? t : null;
140
+ function K() {
141
+ const e = window?.ABT_DEV || window.ABT;
142
+ return e && typeof e.open == "function" ? e : null;
141
143
  }
142
- function St({
143
- webWalletUrl: t,
144
- action: e = "login",
144
+ function Fe({
145
+ webWalletUrl: e,
146
+ action: t = "login",
145
147
  locale: o = "en",
146
148
  url: n,
147
149
  windowFeatures: i,
148
150
  appInfo: r,
149
- memberAppInfo: p
151
+ memberAppInfo: f
150
152
  }) {
151
- const h = B();
153
+ const h = K();
152
154
  if (h)
153
155
  return h.open({
154
- action: e,
156
+ action: t,
155
157
  locale: o,
156
158
  url: encodeURIComponent(n),
157
159
  appInfo: {
158
160
  ...r
159
161
  },
160
162
  memberAppInfo: {
161
- ...p
163
+ ...f
162
164
  }
163
165
  }), { type: "extension" };
164
- const b = {
166
+ const D = {
165
167
  toolbar: "no",
166
168
  location: "no",
167
169
  status: "no",
@@ -171,65 +173,65 @@ function St({
171
173
  // iphone 8plus size
172
174
  width: 414,
173
175
  height: 736
174
- }, D = `${t}?action=${e}&locale=${o}&url=${encodeURIComponent(n)}`, c = Object.assign({}, b, i), $ = (s) => s.innerWidth || s.document.documentElement.clientWidth || s.document.body.clientWidth;
176
+ }, k = `${e}?action=${t}&locale=${o}&url=${encodeURIComponent(n)}`, c = Object.assign({}, D, i), V = (s) => s.innerWidth || s.document.documentElement.clientWidth || s.document.body.clientWidth;
175
177
  if (!("left" in c)) {
176
- const s = $(window.top || window), S = window.screenLeft || window.screenX;
177
- c.left = s + S - c.width;
178
+ const s = V(window.top || window), T = window.screenLeft || window.screenX;
179
+ c.left = s + T - c.width;
178
180
  }
179
181
  if (!("top" in c)) {
180
182
  const s = window.screenTop || window.screenY;
181
183
  c.top = s;
182
184
  }
183
- const T = Object.keys(c).map((s) => `${s}=${c[s]}`).join(",");
184
- return window.open(D, "targetWindow", T), { type: "web" };
185
+ const $ = Object.keys(c).map((s) => `${s}=${c[s]}`).join(",");
186
+ return window.open(k, "targetWindow", $), { type: "web" };
185
187
  }
186
- const xt = (t) => t && Number(t) >= 12 ? `${Number(t)}px` : "inherit", N = (t) => {
187
- const e = t.replace(L, "");
188
- return !!/^(0x)?[0-9a-f]{40}$/i.test(e);
189
- }, X = (t, e) => {
190
- if (!e)
191
- return t;
188
+ const Oe = (e) => e && Number(e) >= 12 ? `${Number(e)}px` : "inherit", J = (e) => {
189
+ const t = e.replace(L, "");
190
+ return !!/^(0x)?[0-9a-f]{40}$/i.test(t);
191
+ }, Q = (e, t) => {
192
+ if (!t)
193
+ return e;
192
194
  try {
193
- const o = new URL(t, window.location.origin);
194
- return Object.keys(e).forEach((n) => {
195
- o.searchParams.set(n, String(e[n]));
195
+ const o = new URL(e, window.location.origin);
196
+ return Object.keys(t).forEach((n) => {
197
+ o.searchParams.set(n, String(t[n]));
196
198
  }), o.origin === window.location.origin ? o.pathname + o.search : o.href;
197
199
  } catch {
198
- return t;
200
+ return e;
199
201
  }
200
- }, Et = (t, e = 48) => t && (t.indexOf(P) >= 0 ? X(t, {
202
+ }, Ae = (e, t = 48) => e && (e.indexOf(C) >= 0 ? Q(e, {
201
203
  imageFilter: "resize",
202
- w: e,
203
- h: e
204
- }) : t), jt = (t = 0) => new Promise((e) => {
204
+ w: t,
205
+ h: t
206
+ }) : e), Pe = (e = 0) => new Promise((t) => {
205
207
  setTimeout(() => {
206
- e();
207
- }, t);
208
- }), kt = (t) => /^https?:\/\//.test(t), m = "vid", d = "__visitor_id", K = () => u.get(m) || localStorage.getItem(d), w = (t) => {
209
- t === null ? u.remove(m, {
208
+ t();
209
+ }, e);
210
+ }), Re = (e) => /^https?:\/\//.test(e), p = "vid", g = "__visitor_id", Y = () => m.get(p) || localStorage.getItem(g), y = (e) => {
211
+ e === null ? m.remove(p, {
210
212
  sameSite: "None",
211
213
  secure: !0
212
- }) : u.set(m, t, {
214
+ }) : m.set(p, e, {
213
215
  sameSite: "None",
214
216
  secure: !0,
215
217
  expires: 365
216
218
  });
217
- }, Ot = () => {
218
- let t = localStorage.getItem(d);
219
- if (t && (localStorage.removeItem(d), w(t)), !K()) {
220
- if (!v())
219
+ }, We = () => {
220
+ let e = localStorage.getItem(g);
221
+ if (e && (localStorage.removeItem(g), y(e)), !Y()) {
222
+ if (!M())
221
223
  try {
222
224
  if (window.crypto && typeof window.crypto.randomUUID == "function")
223
- t = window.crypto.randomUUID();
225
+ e = window.crypto.randomUUID();
224
226
  else {
225
- const e = new Uint8Array(16);
227
+ const t = new Uint8Array(16);
226
228
  if (window.crypto && typeof window.crypto.getRandomValues == "function")
227
- window.crypto.getRandomValues(e);
229
+ window.crypto.getRandomValues(t);
228
230
  else
229
231
  for (let n = 0; n < 16; n++)
230
- e[n] = Math.floor(Math.random() * 256);
231
- const o = Array.from(e).map((n) => n.toString(16).padStart(2, "0"));
232
- t = [
232
+ t[n] = Math.floor(Math.random() * 256);
233
+ const o = Array.from(t).map((n) => n.toString(16).padStart(2, "0"));
234
+ e = [
233
235
  o.slice(0, 4).join(""),
234
236
  o.slice(4, 6).join(""),
235
237
  o.slice(6, 8).join(""),
@@ -238,77 +240,95 @@ const xt = (t) => t && Number(t) >= 12 ? `${Number(t)}px` : "inherit", N = (t) =
238
240
  ].join("-");
239
241
  }
240
242
  } catch {
241
- t = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
243
+ e = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
242
244
  }
243
- t && w(t);
245
+ e && y(e);
244
246
  }
245
- }, Ut = (t) => {
246
- if (N(t)) {
247
- const e = Uint8Array.from(
248
- t.slice(2).match(/.{1,2}/g).map((o) => parseInt(o, 16))
249
- ).slice(0, 8).reduce((o, n) => o + n, 0) % g.length;
250
- return g[e];
247
+ }, Le = (e) => {
248
+ if (J(e)) {
249
+ const t = Uint8Array.from(
250
+ e.slice(2).match(/.{1,2}/g).map((o) => parseInt(o, 16))
251
+ ).slice(0, 8).reduce((o, n) => o + n, 0) % w.length;
252
+ return w[t];
251
253
  }
252
254
  try {
253
- return E(t)?.color;
255
+ return x(e)?.color;
254
256
  } catch {
255
257
  return null;
256
258
  }
257
- }, At = (t, e, o = {}) => {
259
+ }, Ce = (e, t, o = {}) => {
258
260
  const { fallbackLocale: n = "en", defaultValue: i = "unknown" } = o;
259
- if (typeof t == "string")
260
- return t;
261
+ if (typeof e == "string")
262
+ return e;
261
263
  let r;
262
- return e && (r = t[e]), (!r || typeof r != "string") && (r = t[n]), (!r || typeof r != "string") && (r = i), r;
263
- }, Ft = (t) => x(
264
- () => k(
264
+ return t && (r = e[t]), (!r || typeof r != "string") && (r = e[n]), (!r || typeof r != "string") && (r = i), r;
265
+ }, Me = (e) => j(
266
+ () => U(
265
267
  async () => {
266
268
  try {
267
- return await t();
268
- } catch (e) {
269
- throw e instanceof TypeError && !e.message.includes("Failed to fetch") ? e : e instanceof Error ? new Error(e.message) : new Error("Unknown error");
269
+ return await e();
270
+ } catch (t) {
271
+ throw t instanceof TypeError && !t.message.includes("Failed to fetch") ? t : t instanceof Error ? new Error(t.message) : new Error("Unknown error");
270
272
  }
271
273
  },
272
274
  // 只需要重试两次,加上原本的一次,总共三次
273
275
  { retries: 2 }
274
276
  )
275
- ), Rt = (t) => j(t, y);
276
- function Wt(t, e = 1) {
277
- const [o, n, i] = O.hex.rgb(t);
278
- return `rgba(${o}, ${n}, ${i}, ${e})`;
277
+ ), _e = (e) => E(e, I);
278
+ function ze(e, t = 1) {
279
+ const [o, n, i] = v.hex.rgb(e);
280
+ return `rgba(${o}, ${n}, ${i}, ${t})`;
279
281
  }
282
+ const G = () => window.blocklet?.serverVersion || "", H = () => b.version, Z = () => (b.dependencies?.["@blocklet/js-sdk"]).replace(/^[\^~>=<]+/, ""), d = (e, t) => {
283
+ const o = (r) => {
284
+ const f = r.match(/^(\d+\.\d+\.\d+(?:-[^-]+?-\d{8}))/);
285
+ return f ? f[1] : r;
286
+ }, n = o(e), i = o(t);
287
+ return n === i && e !== t ? !1 : W.gte(n, i);
288
+ }, Be = () => {
289
+ const e = G(), t = H(), o = Z();
290
+ if (!e || !t || !o)
291
+ return !1;
292
+ const n = d(t, "3.1.29"), i = d(e, "1.16.49-beta-20250822-070545-6d3344cc"), r = d(o, "1.16.49-beta-20250822-070545-6d3344cc");
293
+ return n && i && r;
294
+ };
280
295
  export {
281
- X as appendParams,
282
- Rt as cleanedObj,
283
- vt as deepmergeAll,
284
- B as detectWalletExtension,
285
- Ot as ensureVisitorId,
286
- $t as formatToDate,
287
- Tt as formatToDatetime,
288
- bt as formatUptime,
289
- ht as getBackground,
290
- pt as getColor,
291
- dt as getCookieOptions,
292
- wt as getCopyright,
293
- Ut as getDIDColor,
294
- Dt as getDateTool,
295
- xt as getFontSize,
296
- yt as getTimezone,
297
- At as getTranslation,
298
- Et as getUserAvatar,
299
- K as getVisitorId,
300
- Wt as hexToRgba,
301
- N as isEthereumDid,
302
- _ as isTwoSegmentTLD,
303
- kt as isUrl,
304
- Ft as lazyRetry,
305
- gt as mergeProps,
306
- St as openWebWallet,
307
- ut as parseQuery,
308
- lt as resolveRootDomain,
309
- z as setDateTool,
310
- w as setVisitorId,
311
- jt as sleep,
312
- It as str2color,
313
- mt as stringifyQuery
296
+ Q as appendParams,
297
+ _e as cleanedObj,
298
+ d as compareVersions,
299
+ Ke as deepmergeAll,
300
+ K as detectWalletExtension,
301
+ We as ensureVisitorId,
302
+ Ue as formatToDate,
303
+ ve as formatToDatetime,
304
+ xe as formatUptime,
305
+ ke as getBackground,
306
+ De as getColor,
307
+ Se as getCookieOptions,
308
+ $e as getCopyright,
309
+ Le as getDIDColor,
310
+ Ee as getDateTool,
311
+ Oe as getFontSize,
312
+ Z as getJsSdkVersion,
313
+ G as getServerVersion,
314
+ Te as getTimezone,
315
+ Ce as getTranslation,
316
+ Ae as getUserAvatar,
317
+ H as getUxPackageVersion,
318
+ Y as getVisitorId,
319
+ ze as hexToRgba,
320
+ J as isEthereumDid,
321
+ Be as isSupportFollow,
322
+ N as isTwoSegmentTLD,
323
+ Re as isUrl,
324
+ Me as lazyRetry,
325
+ Ve as mergeProps,
326
+ Fe as openWebWallet,
327
+ Ie as parseQuery,
328
+ ye as resolveRootDomain,
329
+ X as setDateTool,
330
+ y as setVisitorId,
331
+ Pe as sleep,
332
+ je as str2color,
333
+ be as stringifyQuery
314
334
  };