@blocklet/discuss-kit 2.3.106 → 2.4.0

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,18 +1,18 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import PropTypes from "prop-types";
3
- import Alert from "@mui/material/Alert";
4
- import AlertTitle from "@mui/material/AlertTitle";
5
- function ErrorFallback({ error }) {
6
- const errorMessageElement = process.env.NODE_ENV === "production" ? null : /* @__PURE__ */ jsx("pre", { children: error.message });
7
- return /* @__PURE__ */ jsxs(Alert, { severity: "warning", children: [
8
- /* @__PURE__ */ jsx(AlertTitle, { children: "Oops!" }),
1
+ import { jsx as r, jsxs as s } from "react/jsx-runtime";
2
+ import i from "prop-types";
3
+ import t from "@mui/material/Alert";
4
+ import n from "@mui/material/AlertTitle";
5
+ function p({ error: e }) {
6
+ const o = process.env.NODE_ENV === "production" ? null : /* @__PURE__ */ r("pre", { children: e.message });
7
+ return /* @__PURE__ */ s(t, { severity: "warning", children: [
8
+ /* @__PURE__ */ r(n, { children: "Oops!" }),
9
9
  "Discuss Kit is not working properly.",
10
- errorMessageElement
10
+ o
11
11
  ] });
12
12
  }
13
- ErrorFallback.propTypes = {
14
- error: PropTypes.instanceOf(Error).isRequired
13
+ p.propTypes = {
14
+ error: i.instanceOf(Error).isRequired
15
15
  };
16
16
  export {
17
- ErrorFallback as default
17
+ p as default
18
18
  };
@@ -1,27 +1,24 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import PropTypes from "prop-types";
4
- import { styled } from "@arcblock/ux/lib/Theme";
5
- import IconButton from "@mui/material/IconButton";
6
- import { MoreVert } from "@mui/icons-material";
7
- import Box from "@mui/material/Box";
8
- import MuiMenu from "@mui/material/Menu";
9
- import MuiMenuItem from "@mui/material/MenuItem";
10
- function Menu({ items, ...rest }) {
11
- const [anchorEl, setAnchorEl] = useState(null);
12
- const open = Boolean(anchorEl);
13
- const handleClick = (event) => {
14
- setAnchorEl(event.currentTarget);
1
+ import { jsxs as h, jsx as o } from "react/jsx-runtime";
2
+ import { useState as u } from "react";
3
+ import f from "prop-types";
4
+ import { styled as e } from "@arcblock/ux/lib/Theme";
5
+ import x from "@mui/material/IconButton";
6
+ import { MoreVert as C } from "@mui/icons-material";
7
+ import M from "@mui/material/Box";
8
+ import k from "@mui/material/Menu";
9
+ import y from "@mui/material/MenuItem";
10
+ function g({ items: l, ...m }) {
11
+ const [t, n] = u(null), c = !!t, s = (r) => {
12
+ n(r.currentTarget);
13
+ }, i = () => {
14
+ n(null);
15
15
  };
16
- const handleClose = () => {
17
- setAnchorEl(null);
18
- };
19
- return /* @__PURE__ */ jsxs(Root, { ...rest, children: [
20
- /* @__PURE__ */ jsx(IconButton, { size: "medium", onClick: handleClick, children: /* @__PURE__ */ jsx(MoreVert, { sx: { fontSize: 18 } }) }),
21
- /* @__PURE__ */ jsx(
22
- MuiMenu,
16
+ return /* @__PURE__ */ h(z, { ...m, children: [
17
+ /* @__PURE__ */ o(x, { size: "medium", onClick: s, children: /* @__PURE__ */ o(C, { sx: { fontSize: 18 } }) }),
18
+ /* @__PURE__ */ o(
19
+ k,
23
20
  {
24
- anchorEl,
21
+ anchorEl: t,
25
22
  anchorOrigin: {
26
23
  vertical: "bottom",
27
24
  horizontal: "right"
@@ -30,32 +27,34 @@ function Menu({ items, ...rest }) {
30
27
  vertical: "top",
31
28
  horizontal: "right"
32
29
  },
33
- open,
34
- onClose: handleClose,
35
- children: items.map(({ onClick, text, ...itemProps }, index) => {
36
- const handleClick2 = () => {
37
- onClick();
38
- handleClose();
39
- };
40
- return (
41
- // eslint-disable-next-line react/no-array-index-key
42
- /* @__PURE__ */ jsx(StyledMenuItem, { onClick: handleClick2, ...itemProps, children: /* @__PURE__ */ jsx(Box, { minWidth: 100, children: text }) }, index)
43
- );
44
- })
30
+ open: c,
31
+ onClose: i,
32
+ children: l.map(({ onClick: r, text: a, ...p }, d) => (
33
+ // eslint-disable-next-line react/no-array-index-key
34
+ /* @__PURE__ */ o(v, { onClick: () => {
35
+ r(), i();
36
+ }, ...p, children: /* @__PURE__ */ o(
37
+ M,
38
+ {
39
+ sx: {
40
+ minWidth: 100
41
+ },
42
+ children: a
43
+ }
44
+ ) }, d)
45
+ ))
45
46
  }
46
47
  )
47
48
  ] });
48
49
  }
49
- Menu.propTypes = {
50
- items: PropTypes.array.isRequired
50
+ g.propTypes = {
51
+ items: f.array.isRequired
51
52
  };
52
- Menu.defaultProps = {};
53
- const Root = styled("div")`
53
+ const z = e("div")`
54
54
  display: inline-block;
55
- `;
56
- const StyledMenuItem = styled(MuiMenuItem)`
55
+ `, v = e(y)`
57
56
  font-size: 14px;
58
57
  `;
59
58
  export {
60
- Menu as default
59
+ g as default
61
60
  };
@@ -1,4 +1,4 @@
1
- const DiscussKitDid = "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";
1
+ const i = "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";
2
2
  export {
3
- DiscussKitDid
3
+ i as DiscussKitDid
4
4
  };
@@ -1,17 +1,15 @@
1
- import { useSubscription } from "@blocklet/discuss-kit-ux";
2
- import { discussKitPrefix } from "../lib/utils";
3
- const useCommentsListener = (objectId, handleNewComment) => {
4
- useSubscription(
5
- objectId,
6
- ({ event, data }) => {
7
- if (event === "ADD_COMMENT") {
8
- handleNewComment(data);
9
- }
1
+ import { useSubscription as t } from "@blocklet/discuss-kit-ux";
2
+ import { discussKitPrefix as e } from "../lib/utils.js";
3
+ const n = (i, s) => {
4
+ t(
5
+ i,
6
+ ({ event: r, data: o }) => {
7
+ r === "ADD_COMMENT" && s(o);
10
8
  },
11
- [objectId],
12
- discussKitPrefix
9
+ [i],
10
+ e
13
11
  );
14
12
  };
15
13
  export {
16
- useCommentsListener
14
+ n as useCommentsListener
17
15
  };
@@ -1,22 +1,20 @@
1
- import { useEffect } from "react";
2
- import { utils } from "@blocklet/discuss-kit-ux";
3
- import request from "../api";
4
- import { isInIframe } from "../lib/utils";
5
- const useTopicInfoSync = (options) => {
6
- useEffect(() => {
7
- const sync = () => {
8
- request.put(`/comments/topics/${options.id}`, {
9
- title: options.title,
10
- link: options.link
11
- }).catch((err) => {
12
- console.error(err);
1
+ import { useEffect as r } from "react";
2
+ import { utils as s } from "@blocklet/discuss-kit-ux";
3
+ import c from "../api.js";
4
+ import { isInIframe as e } from "../lib/utils.js";
5
+ const l = (t) => {
6
+ r(() => {
7
+ const i = () => {
8
+ c.put(`/comments/topics/${t.id}`, {
9
+ title: t.title,
10
+ link: t.link
11
+ }).catch((o) => {
12
+ console.error(o);
13
13
  });
14
14
  };
15
- if (!utils.isInDiscussKitApp && !isInIframe()) {
16
- sync();
17
- }
15
+ !s.isInDiscussKitApp && !e() && i();
18
16
  }, []);
19
17
  };
20
18
  export {
21
- useTopicInfoSync
19
+ l as useTopicInfoSync
22
20
  };
package/lib/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { AutoTranslateHeaderAddon, Translate } from "@blocklet/discuss-kit-ux";
2
- import { default as default2 } from "./comments-installer";
3
- import { default as default3 } from "./comments-with-session";
4
- import { useCommentsListener } from "./hooks/comment-listener";
5
- import { CommentsDialog } from "./comments-dialog";
1
+ import { AutoTranslateHeaderAddon as t, Translate as r } from "@blocklet/discuss-kit-ux";
2
+ import { default as s } from "./comments-installer.js";
3
+ import { default as n } from "./comments-with-session.js";
4
+ import { useCommentsListener as d } from "./hooks/comment-listener.js";
5
+ import { CommentsDialog as p } from "./comments-dialog.js";
6
6
  export {
7
- AutoTranslateHeaderAddon,
8
- default2 as Comments,
9
- CommentsDialog,
10
- default3 as CommentsWithSession,
11
- Translate,
12
- useCommentsListener
7
+ t as AutoTranslateHeaderAddon,
8
+ s as Comments,
9
+ p as CommentsDialog,
10
+ n as CommentsWithSession,
11
+ r as Translate,
12
+ d as useCommentsListener
13
13
  };
@@ -1,37 +1,22 @@
1
- var _a, _b;
2
- import joinUrl from "url-join";
3
- const protectLogin = (session, action) => {
4
- if (session.user) {
5
- return action();
6
- }
7
- return new Promise((resolve) => {
8
- session.login(() => resolve(action()));
9
- });
10
- };
11
- const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
12
- const minDelay = (promise, ms) => {
13
- return Promise.all([promise, sleep(ms)]).then(([result]) => result);
14
- };
15
- const discussKitService = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
16
- (x) => x.did === "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"
17
- );
18
- const discussKitPrefix = discussKitService ? joinUrl(discussKitService.mountPoint, "/") : "";
19
- const discussKitApiPrefix = joinUrl(discussKitPrefix, "/api/");
20
- const isDiscussKitRunning = (discussKitService == null ? void 0 : discussKitService.status) === "running";
21
- const isInIframe = () => {
1
+ import s from "url-join";
2
+ const c = (n, t) => n.user ? t() : new Promise((i) => {
3
+ n.login(() => i(t()));
4
+ }), e = (n) => new Promise((t) => setTimeout(t, n)), d = (n, t) => Promise.all([n, e(t)]).then(([i]) => i), o = window.blocklet?.componentMountPoints?.find(
5
+ (n) => n.did === "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"
6
+ ), r = o ? s(o.mountPoint, "/") : "", m = s(r, "/api/"), p = o?.status === "running", w = () => {
22
7
  try {
23
8
  return window.self !== window.top;
24
- } catch (e) {
25
- return true;
9
+ } catch {
10
+ return !0;
26
11
  }
27
12
  };
28
13
  export {
29
- discussKitApiPrefix,
30
- discussKitPrefix,
31
- discussKitService,
32
- isDiscussKitRunning,
33
- isInIframe,
34
- minDelay,
35
- protectLogin,
36
- sleep
14
+ m as discussKitApiPrefix,
15
+ r as discussKitPrefix,
16
+ o as discussKitService,
17
+ p as isDiscussKitRunning,
18
+ w as isInIframe,
19
+ d as minDelay,
20
+ c as protectLogin,
21
+ e as sleep
37
22
  };
@@ -1,5 +1,5 @@
1
- import flat from "flat";
2
- const en = flat({
1
+ import e from "flat";
2
+ const s = e({
3
3
  comments: "Comments",
4
4
  comment: "Comment",
5
5
  poweredBy: "- powered by Discuss Kit",
@@ -49,5 +49,5 @@ const en = flat({
49
49
  }
50
50
  });
51
51
  export {
52
- en as default
52
+ s as default
53
53
  };
@@ -1,8 +1,8 @@
1
- import flat from "flat";
2
- import { translations as translations$1 } from "@blocklet/discuss-kit-ux";
3
- import en from "./en";
4
- import zh from "./zh";
5
- const translations = { zh: { ...zh, ...flat(translations$1.zh) }, en: { ...en, ...flat(translations$1.en) } };
1
+ import o from "flat";
2
+ import { translations as t } from "@blocklet/discuss-kit-ux";
3
+ import r from "./en.js";
4
+ import n from "./zh.js";
5
+ const f = { zh: { ...n, ...o(t.zh) }, en: { ...r, ...o(t.en) } };
6
6
  export {
7
- translations
7
+ f as translations
8
8
  };
@@ -1,5 +1,5 @@
1
- import flat from "flat";
2
- const zh = flat({
1
+ import e from "flat";
2
+ const s = e({
3
3
  comments: "条评论",
4
4
  comment: "评论",
5
5
  poweredBy: "- 由 Discuss Kit 提供支持",
@@ -51,5 +51,5 @@ const zh = flat({
51
51
  }
52
52
  });
53
53
  export {
54
- zh as default
54
+ s as default
55
55
  };
package/lib/es/session.js CHANGED
@@ -1,14 +1,13 @@
1
- import { useContext } from "react";
2
- import { createAuthServiceSessionContext } from "@arcblock/did-connect/lib/Session";
3
- const { SessionProvider, SessionContext, SessionConsumer, withSession } = createAuthServiceSessionContext();
4
- function useSessionContext() {
5
- const data = useContext(SessionContext);
6
- return data;
1
+ import { useContext as e } from "react";
2
+ import { createAuthServiceSessionContext as o } from "@arcblock/did-connect/lib/Session";
3
+ const { SessionProvider: r, SessionContext: t, SessionConsumer: S, withSession: u } = o();
4
+ function a() {
5
+ return e(t);
7
6
  }
8
7
  export {
9
- SessionConsumer,
10
- SessionContext,
11
- SessionProvider,
12
- useSessionContext,
13
- withSession
8
+ S as SessionConsumer,
9
+ t as SessionContext,
10
+ r as SessionProvider,
11
+ a as useSessionContext,
12
+ u as withSession
14
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit",
3
- "version": "2.3.106",
3
+ "version": "2.4.0",
4
4
  "description": "A react component for Discuss Kit blocklet.",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/es/index.js",
@@ -32,11 +32,11 @@
32
32
  "@dnd-kit/core": "^6.1.0",
33
33
  "@dnd-kit/sortable": "^8.0.0",
34
34
  "@dnd-kit/utilities": "^3.2.2",
35
- "@emotion/react": "^11.13.3",
36
- "@emotion/styled": "^11.13.0",
37
- "@mui/icons-material": "^5.16.7",
38
- "@mui/lab": "^5.0.0-alpha.173",
39
- "@mui/material": "^5.16.7",
35
+ "@emotion/react": "^11.14.0",
36
+ "@emotion/styled": "^11.14.1",
37
+ "@mui/icons-material": "^7.1.2",
38
+ "@mui/lab": "^7.0.0-beta.14",
39
+ "@mui/material": "^7.1.2",
40
40
  "@uiw/react-md-editor": "^3.25.6",
41
41
  "ahooks": "^3.8.1",
42
42
  "axios": "^0.27.2",
@@ -49,15 +49,15 @@
49
49
  "rehype-sanitize": "^5.0.1",
50
50
  "timeago.js": "^4.0.2",
51
51
  "url-join": "^4.0.1",
52
- "@blocklet/discuss-kit-ux": "^2.3.106",
53
- "@blocklet/editor": "^2.3.106"
52
+ "@blocklet/discuss-kit-ux": "^2.4.0",
53
+ "@blocklet/editor": "^2.4.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@arcblock/did-connect": "^2.10.36",
57
- "@arcblock/ux": "^2.10.46",
58
- "@blocklet/ui-react": "^2.10.5",
59
- "react": ">=18.0.0",
60
- "react-dom": ">=18.0.0"
56
+ "@arcblock/did-connect": "^3.0.1",
57
+ "@arcblock/ux": "^3.0.1",
58
+ "@blocklet/ui-react": "^3.0.1",
59
+ "react": "^19.1.0",
60
+ "react-dom": "^19.1.0"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public"
@@ -67,12 +67,13 @@
67
67
  "@babel/core": "^7.25.2",
68
68
  "@babel/preset-env": "^7.25.4",
69
69
  "@babel/preset-react": "^7.24.7",
70
- "@vitejs/plugin-react": "^4.3.2",
70
+ "@vitejs/plugin-react": "^4.6.0",
71
71
  "eslint-plugin-react-hooks": "^4.6.2",
72
+ "fast-glob": "^3.3.3",
72
73
  "jest": "^24.9.0",
73
- "vite": "^5.4.9",
74
- "vite-plugin-build": "^0.10.0",
75
- "vite-plugin-svgr": "^4.2.0"
74
+ "vite": "^7.0.0",
75
+ "vite-plugin-no-bundle": "^4.0.0",
76
+ "vite-plugin-svgr": "^4.3.0"
76
77
  },
77
78
  "scripts": {
78
79
  "lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",