@blocklet/discuss-kit 2.3.105 → 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.
package/lib/cjs/index.js CHANGED
@@ -1,25 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const discussKitUx = require("@blocklet/discuss-kit-ux");
4
- const commentsInstaller = require("./comments-installer");
5
- const commentsWithSession = require("./comments-with-session");
6
- const commentListener = require("./hooks/comment-listener");
7
- const commentsDialog = require("./comments-dialog");
8
- Object.defineProperty(exports, "AutoTranslateHeaderAddon", {
9
- enumerable: true,
10
- get: () => discussKitUx.AutoTranslateHeaderAddon
11
- });
12
- Object.defineProperty(exports, "Translate", {
13
- enumerable: true,
14
- get: () => discussKitUx.Translate
15
- });
16
- exports.Comments = commentsInstaller;
17
- exports.CommentsWithSession = commentsWithSession;
18
- Object.defineProperty(exports, "useCommentsListener", {
19
- enumerable: true,
20
- get: () => commentListener.useCommentsListener
21
- });
22
- Object.defineProperty(exports, "CommentsDialog", {
23
- enumerable: true,
24
- get: () => commentsDialog.CommentsDialog
25
- });
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@blocklet/discuss-kit-ux"),t=require("./comments-installer.js"),n=require("./comments-with-session.js"),s=require("./hooks/comment-listener.js"),r=require("./comments-dialog.js");Object.defineProperty(exports,"AutoTranslateHeaderAddon",{enumerable:!0,get:()=>e.AutoTranslateHeaderAddon});Object.defineProperty(exports,"Translate",{enumerable:!0,get:()=>e.Translate});exports.Comments=t;exports.CommentsWithSession=n;exports.useCommentsListener=s.useCommentsListener;exports.CommentsDialog=r.CommentsDialog;
@@ -1,37 +1 @@
1
- "use strict";
2
- var _a, _b;
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const joinUrl = require("url-join");
5
- const protectLogin = (session, action) => {
6
- if (session.user) {
7
- return action();
8
- }
9
- return new Promise((resolve) => {
10
- session.login(() => resolve(action()));
11
- });
12
- };
13
- const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
14
- const minDelay = (promise, ms) => {
15
- return Promise.all([promise, sleep(ms)]).then(([result]) => result);
16
- };
17
- const discussKitService = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
18
- (x) => x.did === "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"
19
- );
20
- const discussKitPrefix = discussKitService ? joinUrl(discussKitService.mountPoint, "/") : "";
21
- const discussKitApiPrefix = joinUrl(discussKitPrefix, "/api/");
22
- const isDiscussKitRunning = (discussKitService == null ? void 0 : discussKitService.status) === "running";
23
- const isInIframe = () => {
24
- try {
25
- return window.self !== window.top;
26
- } catch (e) {
27
- return true;
28
- }
29
- };
30
- exports.discussKitApiPrefix = discussKitApiPrefix;
31
- exports.discussKitPrefix = discussKitPrefix;
32
- exports.discussKitService = discussKitService;
33
- exports.isDiscussKitRunning = isDiscussKitRunning;
34
- exports.isInIframe = isInIframe;
35
- exports.minDelay = minDelay;
36
- exports.protectLogin = protectLogin;
37
- exports.sleep = sleep;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("url-join"),u=(i,s)=>i.user?s():new Promise(e=>{i.login(()=>e(s()))}),r=i=>new Promise(s=>setTimeout(s,i)),c=(i,s)=>Promise.all([i,r(s)]).then(([e])=>e),t=window.blocklet?.componentMountPoints?.find(i=>i.did==="z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu"),o=t?n(t.mountPoint,"/"):"",d=n(o,"/api/"),l=t?.status==="running",p=()=>{try{return window.self!==window.top}catch{return!0}};exports.discussKitApiPrefix=d;exports.discussKitPrefix=o;exports.discussKitService=t;exports.isDiscussKitRunning=l;exports.isInIframe=p;exports.minDelay=c;exports.protectLogin=u;exports.sleep=r;
@@ -1,52 +1 @@
1
- "use strict";
2
- const flat = require("flat");
3
- const en = flat({
4
- comments: "Comments",
5
- comment: "Comment",
6
- poweredBy: "- powered by Discuss Kit",
7
- connect: "Connect",
8
- inputPlaceHolder: "Write a comment",
9
- oldest: "Oldest",
10
- newest: "Newest",
11
- loadMore: "Click To Load More",
12
- connectDIDWallet: "Please connect DID Wallet.",
13
- installDIDWallet: "Click to get your own DID Wallet→",
14
- empty: "Be the first to leave a comment.",
15
- delete: "Delete",
16
- edit: "Edit",
17
- confirm: "Confirm",
18
- cancel: "Cancel",
19
- tip: "Tip",
20
- deleteCommentDesc: "Confirm delete this comment?",
21
- readMore: "Read More",
22
- showMoreReplies: "Show more replies",
23
- deleted: "This comment has been deleted",
24
- emptyContent: "No comment yet",
25
- userActionLog: {
26
- and: "and",
27
- added: "added the",
28
- removed: "removed the",
29
- label: "label",
30
- labels: "labels",
31
- assigned: "assigned",
32
- unassigned: "unassigned",
33
- selfAssigned: "self-assigned this",
34
- selfUnassigned: "self-unassigned this",
35
- published: "published this",
36
- unpublished: "unpublished this",
37
- changeTitle: "changed the title",
38
- changeBoard: "changed the board",
39
- mention: "mentioned this",
40
- pin: "pinned this",
41
- unpin: "unpinned this",
42
- markAsFeatured: "marked this as featured",
43
- unmarkAsFeatured: "unmarked this as featured",
44
- passport: "passport",
45
- passports: "passports"
46
- },
47
- apiUnavailable: {
48
- title: "Comment service is not available",
49
- desc: "Unable to access the comment service, please verify if Discuss Kit Blocklet is running and check for any access restrictions."
50
- }
51
- });
52
- module.exports = en;
1
+ "use strict";const e=require("flat"),t=e({comments:"Comments",comment:"Comment",poweredBy:"- powered by Discuss Kit",connect:"Connect",inputPlaceHolder:"Write a comment",oldest:"Oldest",newest:"Newest",loadMore:"Click To Load More",connectDIDWallet:"Please connect DID Wallet.",installDIDWallet:"Click to get your own DID Wallet→",empty:"Be the first to leave a comment.",delete:"Delete",edit:"Edit",confirm:"Confirm",cancel:"Cancel",tip:"Tip",deleteCommentDesc:"Confirm delete this comment?",readMore:"Read More",showMoreReplies:"Show more replies",deleted:"This comment has been deleted",emptyContent:"No comment yet",userActionLog:{and:"and",added:"added the",removed:"removed the",label:"label",labels:"labels",assigned:"assigned",unassigned:"unassigned",selfAssigned:"self-assigned this",selfUnassigned:"self-unassigned this",published:"published this",unpublished:"unpublished this",changeTitle:"changed the title",changeBoard:"changed the board",mention:"mentioned this",pin:"pinned this",unpin:"unpinned this",markAsFeatured:"marked this as featured",unmarkAsFeatured:"unmarked this as featured",passport:"passport",passports:"passports"},apiUnavailable:{title:"Comment service is not available",desc:"Unable to access the comment service, please verify if Discuss Kit Blocklet is running and check for any access restrictions."}});module.exports=t;
@@ -1,8 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const flat = require("flat");
4
- const discussKitUx = require("@blocklet/discuss-kit-ux");
5
- const en = require("./en");
6
- const zh = require("./zh");
7
- const translations = { zh: { ...zh, ...flat(discussKitUx.translations.zh) }, en: { ...en, ...flat(discussKitUx.translations.en) } };
8
- exports.translations = translations;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("flat"),e=require("@blocklet/discuss-kit-ux"),n=require("./en.js"),s=require("./zh.js"),r={zh:{...s,...t(e.translations.zh)},en:{...n,...t(e.translations.en)}};exports.translations=r;
@@ -1,54 +1 @@
1
- "use strict";
2
- const flat = require("flat");
3
- const zh = flat({
4
- comments: "条评论",
5
- comment: "评论",
6
- poweredBy: "- 由 Discuss Kit 提供支持",
7
- connect: "连接",
8
- inputPlaceHolder: "写评论",
9
- oldest: "最旧",
10
- newest: "最新",
11
- loadMore: "点击加载更多",
12
- connectDIDWallet: "请先连接 DID Wallet.",
13
- installDIDWallet: "点击拥有你的 DID Wallet→",
14
- empty: "成为第一个留下评论的人.",
15
- delete: "删除",
16
- edit: "编辑",
17
- confirm: "确认",
18
- cancel: "取消",
19
- tip: "提示",
20
- deleteCommentDesc: "确认删除这条评论?",
21
- readMore: "更多内容",
22
- showMoreReplies: "显示更多回复",
23
- deleted: "该评论已被删除",
24
- emptyContent: "暂无评论内容",
25
- userActionLog: {
26
- and: "和",
27
- added: "添加",
28
- removed: "移除",
29
- label: "标签",
30
- labels: "标签",
31
- assigned: "分配",
32
- unassigned: "取消分配",
33
- selfAssigned: "分配自己",
34
- selfUnassigned: "取消分配自己",
35
- published: "发布",
36
- unpublished: "取消发布",
37
- changeTitle: "修改标题",
38
- edited: "编辑",
39
- created: "创建",
40
- changeBoard: "修改板块",
41
- mention: "提到",
42
- pin: "置顶",
43
- unpin: "取消置顶",
44
- markAsFeatured: "标记为精品",
45
- unmarkAsFeatured: "取消精品",
46
- passport: "通行证",
47
- passports: "通行证"
48
- },
49
- apiUnavailable: {
50
- title: "评论服务不可用",
51
- desc: "无法访问评论服务,请检查 Discuss Kit Blocklet 是否运行正常 (服务是否运行中、服务是否设置了访问限制)"
52
- }
53
- });
54
- module.exports = zh;
1
+ "use strict";const e=require("flat"),t=e({comments:"条评论",comment:"评论",poweredBy:"- 由 Discuss Kit 提供支持",connect:"连接",inputPlaceHolder:"写评论",oldest:"最旧",newest:"最新",loadMore:"点击加载更多",connectDIDWallet:"请先连接 DID Wallet.",installDIDWallet:"点击拥有你的 DID Wallet→",empty:"成为第一个留下评论的人.",delete:"删除",edit:"编辑",confirm:"确认",cancel:"取消",tip:"提示",deleteCommentDesc:"确认删除这条评论?",readMore:"更多内容",showMoreReplies:"显示更多回复",deleted:"该评论已被删除",emptyContent:"暂无评论内容",userActionLog:{and:"和",added:"添加",removed:"移除",label:"标签",labels:"标签",assigned:"分配",unassigned:"取消分配",selfAssigned:"分配自己",selfUnassigned:"取消分配自己",published:"发布",unpublished:"取消发布",changeTitle:"修改标题",edited:"编辑",created:"创建",changeBoard:"修改板块",mention:"提到",pin:"置顶",unpin:"取消置顶",markAsFeatured:"标记为精品",unmarkAsFeatured:"取消精品",passport:"通行证",passports:"通行证"},apiUnavailable:{title:"评论服务不可用",desc:"无法访问评论服务,请检查 Discuss Kit Blocklet 是否运行正常 (服务是否运行中、服务是否设置了访问限制)"}});module.exports=t;
@@ -1,14 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
4
- const Session = require("@arcblock/did-connect/lib/Session");
5
- const { SessionProvider, SessionContext, SessionConsumer, withSession } = Session.createAuthServiceSessionContext();
6
- function useSessionContext() {
7
- const data = react.useContext(SessionContext);
8
- return data;
9
- }
10
- exports.SessionConsumer = SessionConsumer;
11
- exports.SessionContext = SessionContext;
12
- exports.SessionProvider = SessionProvider;
13
- exports.useSessionContext = useSessionContext;
14
- exports.withSession = withSession;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),o=require("@arcblock/did-connect/lib/Session"),{SessionProvider:t,SessionContext:e,SessionConsumer:n,withSession:i}=o.createAuthServiceSessionContext();function r(){return s.useContext(e)}exports.SessionConsumer=n;exports.SessionContext=e;exports.SessionProvider=t;exports.useSessionContext=r;exports.withSession=i;
package/lib/es/api.js CHANGED
@@ -1,51 +1,44 @@
1
- import { createAxios } from "@blocklet/js-sdk";
2
- import { utils } from "@blocklet/discuss-kit-ux";
3
- import { discussKitApiPrefix } from "./lib/utils";
4
- const request = createAxios({
5
- baseURL: discussKitApiPrefix,
1
+ import { createAxios as a } from "@blocklet/js-sdk";
2
+ import { utils as c } from "@blocklet/discuss-kit-ux";
3
+ import { discussKitApiPrefix as n } from "./lib/utils.js";
4
+ const s = a({
5
+ baseURL: n,
6
6
  timeout: 2e4,
7
7
  headers: {
8
- "x-discuss-kit-client-id": utils.getDiscussKitClientId()
8
+ "x-discuss-kit-client-id": c.getDiscussKitClientId()
9
9
  }
10
10
  });
11
- request.interceptors.request.use(
12
- (config) => {
13
- return config;
14
- },
15
- (error) => Promise.reject(error)
11
+ s.interceptors.request.use(
12
+ (t) => t,
13
+ (t) => Promise.reject(t)
16
14
  );
17
- const fetchRatings = async (id) => {
18
- const { data } = await request.get(`/ratings/${id}`);
19
- return data;
20
- };
21
- const fetchComments = async (params) => {
15
+ const p = async (t) => {
16
+ const { data: e } = await s.get(`/ratings/${t}`);
17
+ return e;
18
+ }, d = async (t) => {
22
19
  try {
23
- const { data } = await request.get("/comments", { params });
24
- return data;
20
+ const { data: e } = await s.get("/comments", { params: t });
21
+ return e;
25
22
  } catch (e) {
26
- console.error(e);
27
- throw e;
23
+ throw console.error(e), e;
28
24
  }
29
- };
30
- const reply = async ({ parentId, content }) => {
31
- const { data } = await request.post("/comments/replies", { content, parentId });
32
- return data;
33
- };
34
- const fetchMoreReplies = async ({ commentId, cursor, limit = 10 }) => {
25
+ }, l = async ({ parentId: t, content: e }) => {
26
+ const { data: o } = await s.post("/comments/replies", { content: e, parentId: t });
27
+ return o;
28
+ }, f = async ({ commentId: t, cursor: e, limit: o = 10 }) => {
35
29
  try {
36
- const { data } = await request.get(`/comments/${commentId}/replies`, {
37
- params: { cursor, limit, embed: "rating" }
30
+ const { data: r } = await s.get(`/comments/${t}/replies`, {
31
+ params: { cursor: e, limit: o, embed: "rating" }
38
32
  });
39
- return data;
40
- } catch (e) {
41
- console.error(e);
42
- throw e;
33
+ return r;
34
+ } catch (r) {
35
+ throw console.error(r), r;
43
36
  }
44
37
  };
45
38
  export {
46
- request as default,
47
- fetchComments,
48
- fetchMoreReplies,
49
- fetchRatings,
50
- reply
39
+ s as default,
40
+ d as fetchComments,
41
+ f as fetchMoreReplies,
42
+ p as fetchRatings,
43
+ l as reply
51
44
  };
@@ -1,24 +1,24 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useMediaQuery, Dialog, DialogTitle, IconButton, DialogContent } from "@mui/material";
3
- import CloseIcon from "@mui/icons-material/Close";
4
- import Comments from "./comments";
5
- function CommentsDialog({ title, open, onClose, ...rest }) {
6
- const fullScreen = useMediaQuery((theme) => theme.breakpoints.down("md"));
7
- return /* @__PURE__ */ jsxs(Dialog, { fullScreen, onClose, maxWidth: false, ...rest, open, children: [
8
- /* @__PURE__ */ jsxs(DialogTitle, { variant: "h4", sx: { position: "relative" }, children: [
9
- title,
10
- /* @__PURE__ */ jsx(
11
- IconButton,
1
+ import { jsxs as r, jsx as o } from "react/jsx-runtime";
2
+ import { useMediaQuery as l, Dialog as m, DialogTitle as p, IconButton as c, DialogContent as d } from "@mui/material";
3
+ import f from "@mui/icons-material/Close";
4
+ import h from "./comments.js";
5
+ function C({ title: n, open: e, onClose: i, ...t }) {
6
+ const s = l((a) => a.breakpoints.down("md"));
7
+ return /* @__PURE__ */ r(m, { fullScreen: s, onClose: i, maxWidth: !1, ...t, open: e, children: [
8
+ /* @__PURE__ */ r(p, { variant: "h4", sx: { position: "relative" }, children: [
9
+ n,
10
+ /* @__PURE__ */ o(
11
+ c,
12
12
  {
13
- onClick: onClose,
13
+ onClick: i,
14
14
  sx: { position: "absolute", right: 8, top: "50%", transform: "translateY(-50%)" },
15
- children: /* @__PURE__ */ jsx(CloseIcon, {})
15
+ children: /* @__PURE__ */ o(f, {})
16
16
  }
17
17
  )
18
18
  ] }),
19
- /* @__PURE__ */ jsx(DialogContent, { sx: { width: { xs: 1, sm: 800 } }, children: /* @__PURE__ */ jsx(Comments, { ...rest }) })
19
+ /* @__PURE__ */ o(d, { sx: { width: { xs: 1, sm: 800 } }, children: /* @__PURE__ */ o(h, { ...t }) })
20
20
  ] });
21
21
  }
22
22
  export {
23
- CommentsDialog
23
+ C as CommentsDialog
24
24
  };
@@ -1,19 +1,40 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { ComponentInstaller } from "@blocklet/ui-react";
3
- import PropTypes from "prop-types";
4
- import Comments from "./comments";
5
- import { DiscussKitDid } from "./constants";
6
- function CommentsInstaller({ installerProps, ...rest }) {
7
- return /* @__PURE__ */ jsx(ComponentInstaller, { did: DiscussKitDid, ...installerProps, children: /* @__PURE__ */ jsx(Comments, { ...rest }) });
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import t from "@blocklet/ui-react/lib/ComponentInstaller";
3
+ import s from "prop-types";
4
+ import r from "./comments.js";
5
+ import { DiscussKitDid as a } from "./constants.js";
6
+ function i({ installerProps: o = {}, ...n }) {
7
+ const l = Object.assign(
8
+ {},
9
+ {
10
+ displayReaction: !0,
11
+ onChange: () => {
12
+ },
13
+ flatView: !1,
14
+ autoCollapse: !1,
15
+ autoLoadComments: !0,
16
+ allowCopyLink: !1,
17
+ disabledSend: void 0,
18
+ showProfileCard: !1,
19
+ order: void 0,
20
+ interactive: !0,
21
+ renderComments: null,
22
+ renderDonation: null,
23
+ renderActions: null,
24
+ renderEditorPlugins: null,
25
+ enableAutoTranslate: !1,
26
+ renderInnerFooter: null,
27
+ sendComment: null,
28
+ reactionAppend: null
29
+ },
30
+ o
31
+ );
32
+ return /* @__PURE__ */ e(t, { did: a, ...l, children: /* @__PURE__ */ e(r, { ...n }) });
8
33
  }
9
- CommentsInstaller.propTypes = {
10
- ...Comments.propTypes,
11
- installerProps: PropTypes.object
12
- };
13
- CommentsInstaller.defaultProps = {
14
- ...Comments.defaultProps,
15
- installerProps: {}
34
+ i.propTypes = {
35
+ ...r.propTypes,
36
+ installerProps: s.object
16
37
  };
17
38
  export {
18
- CommentsInstaller as default
39
+ i as default
19
40
  };
@@ -1,16 +1,13 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { getWebWalletUrl } from "@arcblock/did-connect/lib/utils";
3
- import Comments from "./comments";
4
- import { SessionProvider } from "./session";
5
- const CommentsHOC = (WrappedComponent) => {
6
- const webWalletUrl = getWebWalletUrl();
7
- return function(props) {
8
- return /* @__PURE__ */ jsx(SessionProvider, { serviceHost: "/", webWalletUrl, children: (session) => {
9
- return /* @__PURE__ */ jsx(WrappedComponent, { ...props, session: session.session, showConnectBtn: true });
10
- } });
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { getWebWalletUrl as n } from "@arcblock/did-connect/lib/utils";
3
+ import i from "./comments.js";
4
+ import { SessionProvider as m } from "./session.js";
5
+ const c = (e) => {
6
+ const o = n();
7
+ return function(t) {
8
+ return /* @__PURE__ */ r(m, { serviceHost: "/", webWalletUrl: o, children: (s) => /* @__PURE__ */ r(e, { ...t, session: s.session, showConnectBtn: !0 }) });
11
9
  };
12
- };
13
- const commentsWithSession = CommentsHOC(Comments);
10
+ }, a = c(i);
14
11
  export {
15
- commentsWithSession as default
12
+ a as default
16
13
  };