gitalk-react 1.0.0 → 1.1.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/README-zh-CN.md +152 -53
- package/README.md +132 -34
- package/dist/gitalk-dark.css +1 -1
- package/dist/gitalk-light.css +1 -1
- package/dist/gitalk.browser.full.js +102 -0
- package/dist/gitalk.browser.js +94 -0
- package/dist/gitalk.cjs +94 -0
- package/dist/gitalk.d.cts +14 -0
- package/dist/gitalk.d.mts +174 -0
- package/dist/gitalk.js +2737 -10382
- package/package.json +61 -41
- package/proxy-server/.env.example +6 -0
- package/proxy-server/README.md +38 -0
- package/proxy-server/server.mjs +110 -0
- package/dist/gitalk.d.ts +0 -623
- package/dist/gitalk.umd.cjs +0 -126
- package/lib/assets/arrow-down.svg +0 -1
- package/lib/assets/edit.svg +0 -3
- package/lib/assets/github.svg +0 -3
- package/lib/assets/heart-filled.svg +0 -3
- package/lib/assets/heart.svg +0 -3
- package/lib/assets/reply.svg +0 -3
- package/lib/assets/tip.svg +0 -8
- package/lib/components/action.tsx +0 -21
- package/lib/components/avatar.tsx +0 -42
- package/lib/components/button.tsx +0 -35
- package/lib/components/comment-textarea.tsx +0 -166
- package/lib/components/comment.tsx +0 -204
- package/lib/components/comments-list.tsx +0 -112
- package/lib/components/meta.tsx +0 -133
- package/lib/components/svg.tsx +0 -29
- package/lib/constants/index.ts +0 -71
- package/lib/contexts/I18nContext.ts +0 -20
- package/lib/gitalk.tsx +0 -891
- package/lib/i18n/ar.json +0 -20
- package/lib/i18n/bn.json +0 -20
- package/lib/i18n/de.json +0 -20
- package/lib/i18n/en.json +0 -20
- package/lib/i18n/es.json +0 -20
- package/lib/i18n/fa.json +0 -20
- package/lib/i18n/fr.json +0 -20
- package/lib/i18n/hi.json +0 -20
- package/lib/i18n/index.ts +0 -53
- package/lib/i18n/ja.json +0 -20
- package/lib/i18n/ko.json +0 -20
- package/lib/i18n/pl.json +0 -21
- package/lib/i18n/pt.json +0 -20
- package/lib/i18n/ru.json +0 -20
- package/lib/i18n/ur.json +0 -20
- package/lib/i18n/zh-CN.json +0 -20
- package/lib/i18n/zh-TW.json +0 -20
- package/lib/interfaces/index.ts +0 -198
- package/lib/services/graphql/comment.ts +0 -84
- package/lib/services/request.ts +0 -24
- package/lib/services/user.ts +0 -40
- package/lib/themes/base.scss +0 -630
- package/lib/themes/gitalk-dark.scss +0 -28
- package/lib/themes/gitalk-light.scss +0 -28
- package/lib/utils/compatibility.ts +0 -35
- package/lib/utils/dom.ts +0 -15
- package/lib/utils/logger.ts +0 -66
- package/lib/utils/query.ts +0 -19
- package/lib/vite-env.d.ts +0 -1
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { Comment, GitalkProps } from "../../interfaces";
|
|
2
|
-
|
|
3
|
-
export interface IssueCommentsQLResponse {
|
|
4
|
-
repository: {
|
|
5
|
-
issue: {
|
|
6
|
-
comments: {
|
|
7
|
-
totalCount: number;
|
|
8
|
-
pageInfo: {
|
|
9
|
-
hasPreviousPage?: boolean;
|
|
10
|
-
hasNextPage?: boolean;
|
|
11
|
-
startCursor?: string;
|
|
12
|
-
endCursor?: string;
|
|
13
|
-
};
|
|
14
|
-
nodes: (Pick<Comment, "body"> & {
|
|
15
|
-
databaseId: Comment["id"];
|
|
16
|
-
author: {
|
|
17
|
-
avatarUrl: Comment["user"]["avatar_url"];
|
|
18
|
-
login: Comment["user"]["login"];
|
|
19
|
-
url: Comment["user"]["html_url"];
|
|
20
|
-
};
|
|
21
|
-
bodyHTML: Comment["body_html"];
|
|
22
|
-
createdAt: Comment["created_at"];
|
|
23
|
-
resourcePath: Comment["html_url"];
|
|
24
|
-
reactions: Comment["reactionsHeart"];
|
|
25
|
-
})[];
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const getIssueCommentsQL = ({
|
|
32
|
-
pagerDirection,
|
|
33
|
-
}: {
|
|
34
|
-
pagerDirection: GitalkProps["pagerDirection"];
|
|
35
|
-
}): string => {
|
|
36
|
-
const cursorDirection = pagerDirection === "last" ? "before" : "after";
|
|
37
|
-
|
|
38
|
-
return `
|
|
39
|
-
query getIssueAndComments(
|
|
40
|
-
$owner: String!,
|
|
41
|
-
$repo: String!,
|
|
42
|
-
$id: Int!,
|
|
43
|
-
$cursor: String,
|
|
44
|
-
$pageSize: Int!
|
|
45
|
-
) {
|
|
46
|
-
repository(owner: $owner, name: $repo) {
|
|
47
|
-
issue(number: $id) {
|
|
48
|
-
comments(${pagerDirection}: $pageSize, ${cursorDirection}: $cursor) {
|
|
49
|
-
totalCount
|
|
50
|
-
pageInfo {
|
|
51
|
-
${pagerDirection === "last" ? "hasPreviousPage" : "hasNextPage"}
|
|
52
|
-
${cursorDirection === "before" ? "startCursor" : "endCursor"}
|
|
53
|
-
}
|
|
54
|
-
nodes {
|
|
55
|
-
databaseId
|
|
56
|
-
author {
|
|
57
|
-
avatarUrl
|
|
58
|
-
login
|
|
59
|
-
url
|
|
60
|
-
}
|
|
61
|
-
body
|
|
62
|
-
bodyHTML
|
|
63
|
-
createdAt
|
|
64
|
-
resourcePath
|
|
65
|
-
reactions(first: 100, content: HEART) {
|
|
66
|
-
totalCount
|
|
67
|
-
viewerHasReacted
|
|
68
|
-
pageInfo {
|
|
69
|
-
hasNextPage
|
|
70
|
-
}
|
|
71
|
-
nodes {
|
|
72
|
-
databaseId
|
|
73
|
-
user {
|
|
74
|
-
login
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
`;
|
|
84
|
-
};
|
package/lib/services/request.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Octokit, type RequestError } from "octokit";
|
|
2
|
-
|
|
3
|
-
import { ACCESS_TOKEN_KEY } from "../constants";
|
|
4
|
-
import logger from "../utils/logger";
|
|
5
|
-
|
|
6
|
-
export const getOctokitInstance = (accessToken?: string) => {
|
|
7
|
-
const _octokit = new Octokit(
|
|
8
|
-
accessToken
|
|
9
|
-
? {
|
|
10
|
-
auth: accessToken,
|
|
11
|
-
}
|
|
12
|
-
: {},
|
|
13
|
-
);
|
|
14
|
-
_octokit.hook.error("request", (error) => {
|
|
15
|
-
if ((error as RequestError).status === 401) {
|
|
16
|
-
localStorage.removeItem(ACCESS_TOKEN_KEY);
|
|
17
|
-
logger.w(`Access token expired.`);
|
|
18
|
-
}
|
|
19
|
-
throw error;
|
|
20
|
-
});
|
|
21
|
-
return _octokit;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default getOctokitInstance;
|
package/lib/services/user.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { stringifySearchQuery } from "../utils/query";
|
|
2
|
-
|
|
3
|
-
export const getAuthorizeUrl = (clientID: string) => {
|
|
4
|
-
const query = {
|
|
5
|
-
client_id: clientID,
|
|
6
|
-
redirect_uri: window.location.href,
|
|
7
|
-
scope: "public_repo",
|
|
8
|
-
};
|
|
9
|
-
return `https://github.com/login/oauth/authorize?${stringifySearchQuery(query)}`;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const getAccessToken = async ({
|
|
13
|
-
url,
|
|
14
|
-
code,
|
|
15
|
-
clientID,
|
|
16
|
-
clientSecret,
|
|
17
|
-
}: {
|
|
18
|
-
url: string;
|
|
19
|
-
code: string;
|
|
20
|
-
clientID: string;
|
|
21
|
-
clientSecret: string;
|
|
22
|
-
}) => {
|
|
23
|
-
const res = await fetch(url, {
|
|
24
|
-
method: "POST",
|
|
25
|
-
headers: {
|
|
26
|
-
Accept: "application/json",
|
|
27
|
-
"Content-Type": "application/json",
|
|
28
|
-
},
|
|
29
|
-
body: JSON.stringify({
|
|
30
|
-
code,
|
|
31
|
-
client_id: clientID,
|
|
32
|
-
client_secret: clientSecret,
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const resData = await res.json();
|
|
37
|
-
const { access_token } = resData;
|
|
38
|
-
|
|
39
|
-
return access_token as string;
|
|
40
|
-
};
|