@blocklet/discuss-kit 1.5.182 → 1.5.183
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/comments.js +2 -3
- package/lib/es/comments.js +1 -2
- package/package.json +4 -4
- package/lib/cjs/ws.js +0 -43
- package/lib/es/ws.js +0 -43
package/lib/cjs/comments.js
CHANGED
|
@@ -16,7 +16,6 @@ const discussKitUx = require("@blocklet/discuss-kit-ux");
|
|
|
16
16
|
const ahooks = require("ahooks");
|
|
17
17
|
const ErrorFallback = require("./components/error-fallback");
|
|
18
18
|
const locales = require("./locales");
|
|
19
|
-
const getWsClient = require("./ws");
|
|
20
19
|
const api = require("./api");
|
|
21
20
|
const useAsyncRetry = (fn, deps = []) => {
|
|
22
21
|
const state = ahooks.useRequest(fn, { refreshDeps: deps });
|
|
@@ -131,7 +130,7 @@ function DiscussKitComments({
|
|
|
131
130
|
}));
|
|
132
131
|
}
|
|
133
132
|
};
|
|
134
|
-
|
|
133
|
+
discussKitUx.useSubscription(
|
|
135
134
|
object.id,
|
|
136
135
|
({ event, data }) => {
|
|
137
136
|
var _a;
|
|
@@ -259,7 +258,7 @@ function Wrapper({
|
|
|
259
258
|
if (!_prefix) {
|
|
260
259
|
throw new Error("prefix is required.");
|
|
261
260
|
}
|
|
262
|
-
const wsClient = getWsClient(_prefix);
|
|
261
|
+
const wsClient = discussKitUx.getWsClient(_prefix);
|
|
263
262
|
react.useEffect(() => {
|
|
264
263
|
wsClient.connect();
|
|
265
264
|
return () => {
|
package/lib/es/comments.js
CHANGED
|
@@ -11,11 +11,10 @@ import CircularProgress from "@mui/material/CircularProgress";
|
|
|
11
11
|
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
12
12
|
import { useLocaleContext, LocaleProvider } from "@arcblock/ux/lib/Locale/context";
|
|
13
13
|
import { ErrorBoundary } from "react-error-boundary";
|
|
14
|
-
import { UploaderProvider, InternalThemeProvider, ConfirmProvider, DefaultEditorConfigProvider, CommentsProvider, useDefaultApiErrorHandler, useCommentsContext, GithubReaction, CommentInput, CommentList } from "@blocklet/discuss-kit-ux";
|
|
14
|
+
import { getWsClient, UploaderProvider, InternalThemeProvider, ConfirmProvider, DefaultEditorConfigProvider, CommentsProvider, useDefaultApiErrorHandler, useCommentsContext, useSubscription, GithubReaction, CommentInput, CommentList } from "@blocklet/discuss-kit-ux";
|
|
15
15
|
import { useRequest } from "ahooks";
|
|
16
16
|
import ErrorFallback from "./components/error-fallback";
|
|
17
17
|
import { translations } from "./locales";
|
|
18
|
-
import getWsClient, { useSubscription } from "./ws";
|
|
19
18
|
import api, { fetchRatings } from "./api";
|
|
20
19
|
const useAsyncRetry = (fn, deps = []) => {
|
|
21
20
|
const state = useRequest(fn, { refreshDeps: deps });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.183",
|
|
4
4
|
"description": "A react component for Discuss Kit blocklet.",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/es/index.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@arcblock/did-connect": "^2.8.14",
|
|
38
38
|
"@arcblock/ux": "^2.8.14",
|
|
39
39
|
"@arcblock/ws": "^1.18.95",
|
|
40
|
-
"@blocklet/discuss-kit-ux": "1.5.
|
|
41
|
-
"@blocklet/editor": "1.5.
|
|
40
|
+
"@blocklet/discuss-kit-ux": "1.5.183",
|
|
41
|
+
"@blocklet/editor": "1.5.183",
|
|
42
42
|
"@emotion/react": "^11.10.5",
|
|
43
43
|
"@emotion/styled": "^11.10.5",
|
|
44
44
|
"@mui/icons-material": "^5.14.9",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"vite-plugin-build": "^0.10.0",
|
|
78
78
|
"vite-plugin-svgr": "^4.1.0"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "6d597a12b098da62ff187179e43222c45bf0f629"
|
|
81
81
|
}
|
package/lib/cjs/ws.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const Cookie = require("js-cookie");
|
|
5
|
-
const ws = require("@arcblock/ws");
|
|
6
|
-
let client;
|
|
7
|
-
function create(prefix) {
|
|
8
|
-
const pathPrefix = prefix;
|
|
9
|
-
const url = `//${window.location.host}${pathPrefix.replace(/\/$/, "")}`;
|
|
10
|
-
return new ws.WsClient(url, {
|
|
11
|
-
heartbeatIntervalMs: 10 * 1e3,
|
|
12
|
-
params: () => ({
|
|
13
|
-
token: Cookie.get("login_token")
|
|
14
|
-
}),
|
|
15
|
-
reconnectAfterMs: (tries) => {
|
|
16
|
-
if (Cookie.get("login_token")) {
|
|
17
|
-
return Math.floor(Math.random() * 2 ** tries * 1e3);
|
|
18
|
-
}
|
|
19
|
-
return 2 ** tries * 1e3;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function getWsClient(prefix) {
|
|
24
|
-
if (!client) {
|
|
25
|
-
client = create(prefix);
|
|
26
|
-
}
|
|
27
|
-
return client;
|
|
28
|
-
}
|
|
29
|
-
const useSubscription = (event, cb = () => {
|
|
30
|
-
}, deps = [], prefix = "") => {
|
|
31
|
-
if (!client) {
|
|
32
|
-
client = getWsClient(prefix);
|
|
33
|
-
}
|
|
34
|
-
react.useEffect(() => {
|
|
35
|
-
client.on(event, cb);
|
|
36
|
-
return () => {
|
|
37
|
-
client.off(event, cb);
|
|
38
|
-
};
|
|
39
|
-
}, deps);
|
|
40
|
-
};
|
|
41
|
-
exports.create = create;
|
|
42
|
-
exports.default = getWsClient;
|
|
43
|
-
exports.useSubscription = useSubscription;
|
package/lib/es/ws.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import Cookie from "js-cookie";
|
|
3
|
-
import { WsClient } from "@arcblock/ws";
|
|
4
|
-
let client;
|
|
5
|
-
function create(prefix) {
|
|
6
|
-
const pathPrefix = prefix;
|
|
7
|
-
const url = `//${window.location.host}${pathPrefix.replace(/\/$/, "")}`;
|
|
8
|
-
return new WsClient(url, {
|
|
9
|
-
heartbeatIntervalMs: 10 * 1e3,
|
|
10
|
-
params: () => ({
|
|
11
|
-
token: Cookie.get("login_token")
|
|
12
|
-
}),
|
|
13
|
-
reconnectAfterMs: (tries) => {
|
|
14
|
-
if (Cookie.get("login_token")) {
|
|
15
|
-
return Math.floor(Math.random() * 2 ** tries * 1e3);
|
|
16
|
-
}
|
|
17
|
-
return 2 ** tries * 1e3;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function getWsClient(prefix) {
|
|
22
|
-
if (!client) {
|
|
23
|
-
client = create(prefix);
|
|
24
|
-
}
|
|
25
|
-
return client;
|
|
26
|
-
}
|
|
27
|
-
const useSubscription = (event, cb = () => {
|
|
28
|
-
}, deps = [], prefix = "") => {
|
|
29
|
-
if (!client) {
|
|
30
|
-
client = getWsClient(prefix);
|
|
31
|
-
}
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
client.on(event, cb);
|
|
34
|
-
return () => {
|
|
35
|
-
client.off(event, cb);
|
|
36
|
-
};
|
|
37
|
-
}, deps);
|
|
38
|
-
};
|
|
39
|
-
export {
|
|
40
|
-
create,
|
|
41
|
-
getWsClient as default,
|
|
42
|
-
useSubscription
|
|
43
|
-
};
|