@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.
- package/lib/SessionUser/components/logged-in.js +41 -39
- package/lib/UserCard/Cards/avatar-only.js +11 -22
- package/lib/UserCard/Cards/index.js +4 -12
- package/lib/UserCard/Cards/social-actions.d.ts +7 -0
- package/lib/UserCard/Cards/social-actions.js +112 -0
- package/lib/UserCard/Content/minimal.js +62 -47
- package/lib/UserCard/index.d.ts +2 -0
- package/lib/UserCard/index.js +31 -28
- package/lib/UserCard/types.d.ts +8 -1
- package/lib/UserCard/types.js +4 -4
- package/lib/UserCard/use-follow.d.ts +16 -0
- package/lib/UserCard/use-follow.js +67 -0
- package/lib/Util/index.d.ts +15 -0
- package/lib/Util/index.js +191 -171
- package/lib/package.json.js +9 -0
- package/lib/withTracker/action/bind-wallet.d.ts +14 -0
- package/lib/withTracker/action/bind-wallet.js +1 -0
- package/lib/withTracker/action/login.d.ts +15 -0
- package/lib/withTracker/action/login.js +1 -0
- package/lib/withTracker/action/pay.d.ts +12 -0
- package/lib/withTracker/action/pay.js +1 -0
- package/lib/withTracker/action/switch-passport.d.ts +18 -0
- package/lib/withTracker/action/switch-passport.js +1 -0
- package/lib/withTracker/constant/index.d.ts +3 -0
- package/lib/withTracker/constant/index.js +6 -0
- package/lib/withTracker/env.d.ts +1 -0
- package/lib/withTracker/env.js +4 -0
- package/lib/withTracker/index.d.ts +2 -0
- package/lib/withTracker/index.js +21 -17
- package/package.json +10 -8
- package/src/SessionUser/components/logged-in.tsx +2 -0
- package/src/UserCard/Cards/avatar-only.tsx +1 -15
- package/src/UserCard/Cards/index.tsx +2 -11
- package/src/UserCard/Cards/social-actions.tsx +196 -0
- package/src/UserCard/Content/minimal.tsx +43 -31
- package/src/UserCard/UserCard.stories.jsx +1 -0
- package/src/UserCard/index.tsx +6 -0
- package/src/UserCard/types.ts +10 -1
- package/src/UserCard/use-follow.tsx +119 -0
- package/src/Util/index.ts +67 -0
- package/src/withTracker/action/bind-wallet.tsx +17 -0
- package/src/withTracker/action/login.tsx +18 -0
- package/src/withTracker/action/pay.tsx +14 -0
- package/src/withTracker/action/switch-passport.tsx +20 -0
- package/src/withTracker/constant/index.tsx +3 -0
- package/src/withTracker/env.tsx +1 -0
- package/src/withTracker/index.tsx +8 -11
- package/lib/UserCard/Cards/name-only.d.ts +0 -5
- package/lib/UserCard/Cards/name-only.js +0 -13
- package/src/UserCard/Cards/name-only.tsx +0 -17
package/lib/UserCard/types.d.ts
CHANGED
@@ -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
|
}
|
package/lib/UserCard/types.js
CHANGED
@@ -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
|
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 || {}),
|
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
|
-
|
10
|
+
a as AvatarSize,
|
11
11
|
l as CardType,
|
12
12
|
r as DurationEnum,
|
13
|
-
|
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
|
+
};
|
package/lib/Util/index.d.ts
CHANGED
@@ -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
|
2
|
-
import
|
3
|
-
import { colors as
|
4
|
-
import { mergeAllThemeOptions as
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
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
|
13
|
-
import
|
14
|
-
import
|
15
|
-
import
|
16
|
-
import
|
17
|
-
import
|
18
|
-
import {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
25
|
-
if (
|
26
|
-
const o =
|
27
|
-
return
|
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
|
30
|
-
const { host:
|
31
|
-
if (!
|
31
|
+
function ye() {
|
32
|
+
const { host: e } = window.location;
|
33
|
+
if (!e || _.test(e))
|
32
34
|
return "";
|
33
|
-
const o =
|
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 (
|
40
|
+
if (N(n))
|
39
41
|
return `.${o.slice(-3).join(".")}`;
|
40
42
|
}
|
41
43
|
return `.${o.slice(-2).join(".")}`;
|
42
44
|
}
|
43
|
-
function
|
44
|
-
return
|
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
|
48
|
+
return t[n] = i, t;
|
47
49
|
}, {});
|
48
50
|
}
|
49
|
-
function
|
50
|
-
return new URLSearchParams(
|
51
|
+
function be(e = {}) {
|
52
|
+
return new URLSearchParams(e).toString();
|
51
53
|
}
|
52
|
-
function
|
53
|
-
let
|
54
|
-
typeof
|
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:
|
57
|
-
path:
|
58
|
-
domain:
|
59
|
-
sameSite:
|
58
|
+
expires: t.expireInDays,
|
59
|
+
path: t.path,
|
60
|
+
domain: t.domain || "",
|
61
|
+
sameSite: t.sameSite || "Lax",
|
60
62
|
// 允许自定义设置为 false,默认是 true
|
61
|
-
secure:
|
63
|
+
secure: t.secure !== !1
|
62
64
|
};
|
63
|
-
return (typeof window > "u" ||
|
65
|
+
return (typeof window > "u" || t.domain || t.returnDomain === !1) && t.returnDomain === !1 && delete o.domain, o;
|
64
66
|
}
|
65
|
-
const
|
66
|
-
function
|
67
|
-
const n = Object.assign({},
|
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
|
81
|
-
const
|
82
|
-
return `${
|
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
|
85
|
-
let
|
86
|
-
for (let n = 0; n <
|
87
|
-
|
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 =
|
92
|
+
const i = t >> n * 8 & 255;
|
91
93
|
o += `00${i.toString(16)}`.substr(-2);
|
92
94
|
}
|
93
95
|
return o;
|
94
|
-
},
|
95
|
-
const
|
96
|
-
return `${
|
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
|
99
|
-
|
100
|
+
function X(e) {
|
101
|
+
l = e;
|
100
102
|
}
|
101
|
-
function
|
102
|
-
return
|
103
|
+
function Ee() {
|
104
|
+
return l;
|
103
105
|
}
|
104
|
-
const
|
105
|
-
if (
|
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
|
-
}),
|
124
|
+
}), X(a)), I(t) || t === "")
|
123
125
|
return "-";
|
124
|
-
let r =
|
125
|
-
return n && (r = r.tz(n)), i && (r = r.utc()), typeof o < "u" && (r = r.locale(o)), r.format(
|
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
|
128
|
-
return
|
129
|
+
function Ue(e, { locale: t = "en", tz: o } = {}) {
|
130
|
+
return S("ll")(e, { locale: t, tz: o });
|
129
131
|
}
|
130
|
-
function
|
131
|
-
locale:
|
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
|
138
|
+
return S(i)(e, { locale: t, tz: o, isUtc: n });
|
137
139
|
}
|
138
|
-
function
|
139
|
-
const
|
140
|
-
return
|
140
|
+
function K() {
|
141
|
+
const e = window?.ABT_DEV || window.ABT;
|
142
|
+
return e && typeof e.open == "function" ? e : null;
|
141
143
|
}
|
142
|
-
function
|
143
|
-
webWalletUrl:
|
144
|
-
action:
|
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:
|
151
|
+
memberAppInfo: f
|
150
152
|
}) {
|
151
|
-
const h =
|
153
|
+
const h = K();
|
152
154
|
if (h)
|
153
155
|
return h.open({
|
154
|
-
action:
|
156
|
+
action: t,
|
155
157
|
locale: o,
|
156
158
|
url: encodeURIComponent(n),
|
157
159
|
appInfo: {
|
158
160
|
...r
|
159
161
|
},
|
160
162
|
memberAppInfo: {
|
161
|
-
...
|
163
|
+
...f
|
162
164
|
}
|
163
165
|
}), { type: "extension" };
|
164
|
-
const
|
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
|
-
},
|
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 =
|
177
|
-
c.left = s +
|
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
|
184
|
-
return window.open(
|
185
|
+
const $ = Object.keys(c).map((s) => `${s}=${c[s]}`).join(",");
|
186
|
+
return window.open(k, "targetWindow", $), { type: "web" };
|
185
187
|
}
|
186
|
-
const
|
187
|
-
const
|
188
|
-
return !!/^(0x)?[0-9a-f]{40}$/i.test(
|
189
|
-
},
|
190
|
-
if (!
|
191
|
-
return
|
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(
|
194
|
-
return Object.keys(
|
195
|
-
o.searchParams.set(n, String(
|
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
|
200
|
+
return e;
|
199
201
|
}
|
200
|
-
},
|
202
|
+
}, Ae = (e, t = 48) => e && (e.indexOf(C) >= 0 ? Q(e, {
|
201
203
|
imageFilter: "resize",
|
202
|
-
w:
|
203
|
-
h:
|
204
|
-
}) :
|
204
|
+
w: t,
|
205
|
+
h: t
|
206
|
+
}) : e), Pe = (e = 0) => new Promise((t) => {
|
205
207
|
setTimeout(() => {
|
206
|
-
|
207
|
-
},
|
208
|
-
}),
|
209
|
-
|
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
|
-
}) :
|
214
|
+
}) : m.set(p, e, {
|
213
215
|
sameSite: "None",
|
214
216
|
secure: !0,
|
215
217
|
expires: 365
|
216
218
|
});
|
217
|
-
},
|
218
|
-
let
|
219
|
-
if (
|
220
|
-
if (!
|
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
|
-
|
225
|
+
e = window.crypto.randomUUID();
|
224
226
|
else {
|
225
|
-
const
|
227
|
+
const t = new Uint8Array(16);
|
226
228
|
if (window.crypto && typeof window.crypto.getRandomValues == "function")
|
227
|
-
window.crypto.getRandomValues(
|
229
|
+
window.crypto.getRandomValues(t);
|
228
230
|
else
|
229
231
|
for (let n = 0; n < 16; n++)
|
230
|
-
|
231
|
-
const o = Array.from(
|
232
|
-
|
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
|
-
|
243
|
+
e = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
242
244
|
}
|
243
|
-
|
245
|
+
e && y(e);
|
244
246
|
}
|
245
|
-
},
|
246
|
-
if (
|
247
|
-
const
|
248
|
-
|
249
|
-
).slice(0, 8).reduce((o, n) => o + n, 0) %
|
250
|
-
return
|
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
|
255
|
+
return x(e)?.color;
|
254
256
|
} catch {
|
255
257
|
return null;
|
256
258
|
}
|
257
|
-
},
|
259
|
+
}, Ce = (e, t, o = {}) => {
|
258
260
|
const { fallbackLocale: n = "en", defaultValue: i = "unknown" } = o;
|
259
|
-
if (typeof
|
260
|
-
return
|
261
|
+
if (typeof e == "string")
|
262
|
+
return e;
|
261
263
|
let r;
|
262
|
-
return
|
263
|
-
},
|
264
|
-
() =>
|
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
|
268
|
-
} catch (
|
269
|
-
throw
|
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
|
-
),
|
276
|
-
function
|
277
|
-
const [o, n, i] =
|
278
|
-
return `rgba(${o}, ${n}, ${i}, ${
|
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
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
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
|
};
|