@blocklet/discuss-kit-ux 2.0.99 → 2.0.100

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.
@@ -14,8 +14,10 @@ interface Session {
14
14
  initialized: boolean;
15
15
  user: SessionContextUser;
16
16
  login: (...args: any[]) => void;
17
+ switchPassport: (...args: any[]) => void;
17
18
  }
18
19
  export declare const useSessionContext: () => {
20
+ isAuthenticated: boolean;
19
21
  isAdmin: boolean;
20
22
  isMember: boolean;
21
23
  isBlogEditor: boolean;
@@ -4,7 +4,7 @@ import { OnContentChangePlugin } from "@blocklet/editor/lib/ext/OnContentChangeP
4
4
  import { CtrlsShortcutPlugin } from "@blocklet/editor/lib/ext/ShortcutPlugin";
5
5
  import { SafeAreaPlugin } from "@blocklet/editor/lib/ext/SafeAreaPlugin";
6
6
  import { lazy } from "react";
7
- import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-CEddDr2z.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-BQ_vgrJf.mjs";
8
8
  const BlockletEditor = lazy(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- var _a, _b, _c;
7
+ var _a, _b, _c, _d;
8
8
  import { Labels2, LabelPicker } from "@blocklet/labels";
9
9
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
10
10
  import { useTheme, ThemeProvider, styled } from "@mui/material/styles";
@@ -1053,15 +1053,16 @@ function Badge({
1053
1053
  ] }) : null;
1054
1054
  }
1055
1055
  const useSessionContext = () => {
1056
- var _a2, _b2, _c2, _d;
1056
+ var _a2, _b2, _c2, _d2, _e;
1057
1057
  const ctx = useContext(SessionContext) || {};
1058
1058
  const loginRole = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.role;
1059
1059
  const permissionSet = useMemo(() => {
1060
1060
  var _a3, _b3;
1061
1061
  return new Set(((_b3 = (_a3 = ctx.session) == null ? void 0 : _a3.user) == null ? void 0 : _b3.permissions) || []);
1062
- }, [(_d = (_c2 = ctx.session) == null ? void 0 : _c2.user) == null ? void 0 : _d.permissions]);
1062
+ }, [(_d2 = (_c2 = ctx.session) == null ? void 0 : _c2.user) == null ? void 0 : _d2.permissions]);
1063
1063
  return {
1064
1064
  ...ctx,
1065
+ isAuthenticated: !!((_e = ctx.session) == null ? void 0 : _e.user),
1065
1066
  isAdmin: ["admin", "owner"].includes(loginRole),
1066
1067
  isMember: ["member"].includes(loginRole),
1067
1068
  isBlogEditor: ["blogEditor"].includes(loginRole),
@@ -2235,7 +2236,7 @@ const preferences = {
2235
2236
  maxDiscussionLength: parseInt(`${prefs.maxDiscussionLength}`, 10),
2236
2237
  maxPinLimit: parseInt(`${prefs.maxPinLimit}`, 10),
2237
2238
  maxFeaturedLimit: parseInt(`${prefs.maxFeaturedLimit}`, 10),
2238
- assignmentAuthorizedPassports: prefs.assignmentAuthorizedPassports.split(",").map((x) => x.trim())
2239
+ assignmentAuthorizedPassports: (_d = prefs.assignmentAuthorizedPassports) == null ? void 0 : _d.split(",").map((x) => x.trim())
2239
2240
  };
2240
2241
  function Confirm({
2241
2242
  open,
@@ -4308,7 +4309,7 @@ function NotificationMessage({ chat, message, prevMessage }) {
4308
4309
  return null;
4309
4310
  };
4310
4311
  const render = () => {
4311
- var _a2, _b2, _c2, _d;
4312
+ var _a2, _b2, _c2, _d2;
4312
4313
  const baseCardSx = {
4313
4314
  py: 1.5,
4314
4315
  px: 2,
@@ -4451,7 +4452,7 @@ function NotificationMessage({ chat, message, prevMessage }) {
4451
4452
  ]
4452
4453
  }
4453
4454
  ),
4454
- /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { fontSize: 16 }, children: (_d = (_b2 = message == null ? void 0 : message.comment) == null ? void 0 : _b2.excerpt) == null ? void 0 : _d.replace((_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.fullName, "") }),
4455
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { fontSize: 16 }, children: (_d2 = (_b2 = message == null ? void 0 : message.comment) == null ? void 0 : _b2.excerpt) == null ? void 0 : _d2.replace((_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.fullName, "") }),
4455
4456
  renderQuote(message.post)
4456
4457
  ]
4457
4458
  }
@@ -4774,7 +4775,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
4774
4775
  }
4775
4776
  const tablerSend = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14L21 3m0 0l-6.5 18a.55.55 0 0 1-1 0L10 14l-7-3.5a.55.55 0 0 1 0-1z" }) });
4776
4777
  const tablerLetterCase = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0-7 0M3 19V8.5a3.5 3.5 0 0 1 7 0V19m-7-6h7m11-1v7" }) });
4777
- const Editor = lazy(() => import("./editor-xTxzS1UN.mjs"));
4778
+ const Editor = lazy(() => import("./editor-DI-qfaZA.mjs"));
4778
4779
  function LazyEditor(props) {
4779
4780
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4780
4781
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -5668,7 +5669,7 @@ function Empty({ sx }) {
5668
5669
  ] });
5669
5670
  }
5670
5671
  function ChatListInWallet({ sx, ...rest }) {
5671
- var _a2, _b2, _c2, _d;
5672
+ var _a2, _b2, _c2, _d2;
5672
5673
  const { session } = useSessionContext();
5673
5674
  const { initialized, chats, activeChatId } = useChatContext();
5674
5675
  const { unread } = useUnreadNotification();
@@ -5769,7 +5770,7 @@ function ChatListInWallet({ sx, ...rest }) {
5769
5770
  sx: {
5770
5771
  width: 1,
5771
5772
  height: 1,
5772
- ...((_d = window.chatInWallet) == null ? void 0 : _d.safeAreaInsetTop) && {
5773
+ ...((_d2 = window.chatInWallet) == null ? void 0 : _d2.safeAreaInsetTop) && {
5773
5774
  pt: `${window.chatInWallet.safeAreaInsetTop}px`
5774
5775
  }
5775
5776
  },
@@ -11880,14 +11881,14 @@ function create(prefix2) {
11880
11881
  }
11881
11882
  });
11882
11883
  }
11883
- function getWsClient(prefix2 = ((_d) => (_d = window.blocklet) == null ? void 0 : _d.prefix)() || "/") {
11884
+ function getWsClient(prefix2 = ((_e) => (_e = window.blocklet) == null ? void 0 : _e.prefix)() || "/") {
11884
11885
  if (!client) {
11885
11886
  client = create(prefix2);
11886
11887
  }
11887
11888
  return client;
11888
11889
  }
11889
11890
  const useSubscription = (event, cb = () => {
11890
- }, deps = [], prefix2 = ((_e) => (_e = window.blocklet) == null ? void 0 : _e.prefix)() || "/") => {
11891
+ }, deps = [], prefix2 = ((_f) => (_f = window.blocklet) == null ? void 0 : _f.prefix)() || "/") => {
11891
11892
  useEffect(() => {
11892
11893
  if (event) {
11893
11894
  if (!client) {
@@ -11954,7 +11955,7 @@ function PointUp({ points }) {
11954
11955
  );
11955
11956
  }
11956
11957
  function PointUpProvider({ children }) {
11957
- var _a2, _b2, _c2, _d;
11958
+ var _a2, _b2, _c2, _d2;
11958
11959
  const state = useReactive({
11959
11960
  pointsList: [],
11960
11961
  visible: false,
@@ -12006,7 +12007,7 @@ function PointUpProvider({ children }) {
12006
12007
  }
12007
12008
  }, [JSON.stringify(state.pointsList)]);
12008
12009
  useSubscription(
12009
- (_d = session == null ? void 0 : session.user) == null ? void 0 : _d.did,
12010
+ (_d2 = session == null ? void 0 : session.user) == null ? void 0 : _d2.did,
12010
12011
  ({ event, clientId, data }) => {
12011
12012
  var _a3;
12012
12013
  if (clientId === getDiscussKitClientId()) {
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-CEddDr2z.mjs";
2
+ import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-BQ_vgrJf.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
package/dist/index.umd.js CHANGED
@@ -8,7 +8,7 @@ var __publicField = (obj, key, value) => {
8
8
  return value;
9
9
  };
10
10
 
11
- var _a, _b, _c;
11
+ var _a, _b, _c, _d;
12
12
  const typography = {
13
13
  h1: {
14
14
  fontSize: "1.875rem",
@@ -979,15 +979,16 @@ var __publicField = (obj, key, value) => {
979
979
  ] }) : null;
980
980
  }
981
981
  const useSessionContext = () => {
982
- var _a2, _b2, _c2, _d;
982
+ var _a2, _b2, _c2, _d2, _e;
983
983
  const ctx = react.useContext(Session.SessionContext) || {};
984
984
  const loginRole = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.role;
985
985
  const permissionSet = react.useMemo(() => {
986
986
  var _a3, _b3;
987
987
  return new Set(((_b3 = (_a3 = ctx.session) == null ? void 0 : _a3.user) == null ? void 0 : _b3.permissions) || []);
988
- }, [(_d = (_c2 = ctx.session) == null ? void 0 : _c2.user) == null ? void 0 : _d.permissions]);
988
+ }, [(_d2 = (_c2 = ctx.session) == null ? void 0 : _c2.user) == null ? void 0 : _d2.permissions]);
989
989
  return {
990
990
  ...ctx,
991
+ isAuthenticated: !!((_e = ctx.session) == null ? void 0 : _e.user),
991
992
  isAdmin: ["admin", "owner"].includes(loginRole),
992
993
  isMember: ["member"].includes(loginRole),
993
994
  isBlogEditor: ["blogEditor"].includes(loginRole),
@@ -2161,7 +2162,7 @@ var __publicField = (obj, key, value) => {
2161
2162
  maxDiscussionLength: parseInt(`${prefs.maxDiscussionLength}`, 10),
2162
2163
  maxPinLimit: parseInt(`${prefs.maxPinLimit}`, 10),
2163
2164
  maxFeaturedLimit: parseInt(`${prefs.maxFeaturedLimit}`, 10),
2164
- assignmentAuthorizedPassports: prefs.assignmentAuthorizedPassports.split(",").map((x) => x.trim())
2165
+ assignmentAuthorizedPassports: (_d = prefs.assignmentAuthorizedPassports) == null ? void 0 : _d.split(",").map((x) => x.trim())
2165
2166
  };
2166
2167
  function Confirm({
2167
2168
  open,
@@ -4234,7 +4235,7 @@ var __publicField = (obj, key, value) => {
4234
4235
  return null;
4235
4236
  };
4236
4237
  const render = () => {
4237
- var _a2, _b2, _c2, _d;
4238
+ var _a2, _b2, _c2, _d2;
4238
4239
  const baseCardSx = {
4239
4240
  py: 1.5,
4240
4241
  px: 2,
@@ -4377,7 +4378,7 @@ var __publicField = (obj, key, value) => {
4377
4378
  ]
4378
4379
  }
4379
4380
  ),
4380
- /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body1", sx: { fontSize: 16 }, children: (_d = (_b2 = message == null ? void 0 : message.comment) == null ? void 0 : _b2.excerpt) == null ? void 0 : _d.replace((_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.fullName, "") }),
4381
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body1", sx: { fontSize: 16 }, children: (_d2 = (_b2 = message == null ? void 0 : message.comment) == null ? void 0 : _b2.excerpt) == null ? void 0 : _d2.replace((_c2 = session == null ? void 0 : session.user) == null ? void 0 : _c2.fullName, "") }),
4381
4382
  renderQuote(message.post)
4382
4383
  ]
4383
4384
  }
@@ -5594,7 +5595,7 @@ var __publicField = (obj, key, value) => {
5594
5595
  ] });
5595
5596
  }
5596
5597
  function ChatListInWallet({ sx, ...rest }) {
5597
- var _a2, _b2, _c2, _d;
5598
+ var _a2, _b2, _c2, _d2;
5598
5599
  const { session } = useSessionContext();
5599
5600
  const { initialized, chats, activeChatId } = useChatContext();
5600
5601
  const { unread } = useUnreadNotification();
@@ -5695,7 +5696,7 @@ var __publicField = (obj, key, value) => {
5695
5696
  sx: {
5696
5697
  width: 1,
5697
5698
  height: 1,
5698
- ...((_d = window.chatInWallet) == null ? void 0 : _d.safeAreaInsetTop) && {
5699
+ ...((_d2 = window.chatInWallet) == null ? void 0 : _d2.safeAreaInsetTop) && {
5699
5700
  pt: `${window.chatInWallet.safeAreaInsetTop}px`
5700
5701
  }
5701
5702
  },
@@ -11806,14 +11807,14 @@ var __publicField = (obj, key, value) => {
11806
11807
  }
11807
11808
  });
11808
11809
  }
11809
- function getWsClient(prefix2 = ((_d) => (_d = window.blocklet) == null ? void 0 : _d.prefix)() || "/") {
11810
+ function getWsClient(prefix2 = ((_e) => (_e = window.blocklet) == null ? void 0 : _e.prefix)() || "/") {
11810
11811
  if (!client) {
11811
11812
  client = create(prefix2);
11812
11813
  }
11813
11814
  return client;
11814
11815
  }
11815
11816
  const useSubscription = (event, cb = () => {
11816
- }, deps = [], prefix2 = ((_e) => (_e = window.blocklet) == null ? void 0 : _e.prefix)() || "/") => {
11817
+ }, deps = [], prefix2 = ((_f) => (_f = window.blocklet) == null ? void 0 : _f.prefix)() || "/") => {
11817
11818
  react.useEffect(() => {
11818
11819
  if (event) {
11819
11820
  if (!client) {
@@ -11880,7 +11881,7 @@ var __publicField = (obj, key, value) => {
11880
11881
  );
11881
11882
  }
11882
11883
  function PointUpProvider({ children }) {
11883
- var _a2, _b2, _c2, _d;
11884
+ var _a2, _b2, _c2, _d2;
11884
11885
  const state = ahooks.useReactive({
11885
11886
  pointsList: [],
11886
11887
  visible: false,
@@ -11932,7 +11933,7 @@ var __publicField = (obj, key, value) => {
11932
11933
  }
11933
11934
  }, [JSON.stringify(state.pointsList)]);
11934
11935
  useSubscription(
11935
- (_d = session == null ? void 0 : session.user) == null ? void 0 : _d.did,
11936
+ (_d2 = session == null ? void 0 : session.user) == null ? void 0 : _d2.did,
11936
11937
  ({ event, clientId, data }) => {
11937
11938
  var _a3;
11938
11939
  if (clientId === getDiscussKitClientId()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.0.99",
3
+ "version": "2.0.100",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -31,8 +31,8 @@
31
31
  "@arcblock/bridge": "^2.10.12",
32
32
  "@arcblock/react-hooks": "^2.10.12",
33
33
  "@arcblock/ws": "^1.18.128",
34
- "@blocklet/editor": "2.0.99",
35
- "@blocklet/labels": "2.0.99",
34
+ "@blocklet/editor": "2.0.100",
35
+ "@blocklet/labels": "2.0.100",
36
36
  "@blocklet/uploader": "^0.1.20",
37
37
  "@emotion/css": "^11.10.5",
38
38
  "@emotion/react": "^11.10.5",
@@ -100,5 +100,5 @@
100
100
  "resolutions": {
101
101
  "react": "^18.2.0"
102
102
  },
103
- "gitHead": "9cf729989456de5f3b22b0d9936250d9a072780c"
103
+ "gitHead": "843130ec0c98f4dc0cc08ac7b92fe24d148b884a"
104
104
  }