gitalk-react 1.0.0-beta.8 → 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 +159 -57
- package/README.md +142 -40
- 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 +7427 -12628
- package/package.json +67 -44
- 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 -455
- package/dist/gitalk.umd.cjs +0 -123
- 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 -164
- package/lib/components/comment.tsx +0 -185
- package/lib/components/comments-list.tsx +0 -106
- package/lib/components/meta.tsx +0 -129
- package/lib/components/svg.tsx +0 -29
- package/lib/constants/index.ts +0 -57
- package/lib/contexts/I18nContext.ts +0 -20
- package/lib/gitalk.tsx +0 -882
- package/lib/i18n/de.json +0 -20
- package/lib/i18n/en.json +0 -20
- package/lib/i18n/es-ES.json +0 -20
- package/lib/i18n/fa.json +0 -20
- package/lib/i18n/fr.json +0 -20
- package/lib/i18n/index.ts +0 -40
- package/lib/i18n/ja.json +0 -20
- package/lib/i18n/ko.json +0 -20
- package/lib/i18n/pl.json +0 -21
- package/lib/i18n/ru.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 -196
- 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 -628
- 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
package/lib/i18n/de.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalking ...",
|
|
3
|
-
"no-found-related": "Zugehöriger %{link} nicht gefunden",
|
|
4
|
-
"please-contact": "Bitte kontaktiere %{user} um den Kommentar zu initialisieren",
|
|
5
|
-
"init-issue": "Initialisiere Issue",
|
|
6
|
-
"leave-a-comment": "Hinterlasse einen Kommentar",
|
|
7
|
-
"preview": "Vorschau",
|
|
8
|
-
"edit": "Editieren",
|
|
9
|
-
"comment": "Kommentieren",
|
|
10
|
-
"support-markdown": "Markdown wird unterstützt",
|
|
11
|
-
"login-with-github": "Mit GitHub-Account anmelden",
|
|
12
|
-
"first-comment-person": "Sei die erste Person, welche einen Kommentar hinterlässt!",
|
|
13
|
-
"commented": "kommentierte",
|
|
14
|
-
"load-more": "Zeige mehr",
|
|
15
|
-
"counts": "%{counts} Kommentar |||| %{counts} Kommentare",
|
|
16
|
-
"sort-asc": "Älteste zuerst",
|
|
17
|
-
"sort-desc": "Neuste zuerst",
|
|
18
|
-
"logout": "Abmelden",
|
|
19
|
-
"anonymous": "Anonym"
|
|
20
|
-
}
|
package/lib/i18n/en.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalking ...",
|
|
3
|
-
"no-found-related": "Related %{link} not found",
|
|
4
|
-
"please-contact": "Please contact %{user} to initialize the comment",
|
|
5
|
-
"init-issue": "Init Issue",
|
|
6
|
-
"leave-a-comment": "Leave a comment",
|
|
7
|
-
"preview": "Preview",
|
|
8
|
-
"edit": "Edit",
|
|
9
|
-
"comment": "Comment",
|
|
10
|
-
"support-markdown": "Markdown is supported",
|
|
11
|
-
"login-with-github": "Login with GitHub",
|
|
12
|
-
"first-comment-person": "Be the first person to leave a comment!",
|
|
13
|
-
"commented": "commented",
|
|
14
|
-
"load-more": "Load more",
|
|
15
|
-
"counts": "%{counts} comment |||| %{counts} comments",
|
|
16
|
-
"sort-asc": "Sort by Oldest",
|
|
17
|
-
"sort-desc": "Sort by Latest",
|
|
18
|
-
"logout": "Logout",
|
|
19
|
-
"anonymous": "Anonymous"
|
|
20
|
-
}
|
package/lib/i18n/es-ES.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalking ...",
|
|
3
|
-
"no-found-related": "Link %{link} no encontrado",
|
|
4
|
-
"please-contact": "Por favor contacta con %{user} para inicializar el comentario",
|
|
5
|
-
"init-issue": "Iniciar Issue",
|
|
6
|
-
"leave-a-comment": "Deja un comentario",
|
|
7
|
-
"preview": "Avance",
|
|
8
|
-
"edit": "Editar",
|
|
9
|
-
"comment": "Comentario",
|
|
10
|
-
"support-markdown": "Markdown es soportado",
|
|
11
|
-
"login-with-github": "Entrar con GitHub",
|
|
12
|
-
"first-comment-person": "Sé el primero en dejar un comentario!",
|
|
13
|
-
"commented": "comentó",
|
|
14
|
-
"load-more": "Cargar más",
|
|
15
|
-
"counts": "%{counts} comentario |||| %{counts} comentarios",
|
|
16
|
-
"sort-asc": "Ordenar por Antiguos",
|
|
17
|
-
"sort-desc": "Ordenar por Recientes",
|
|
18
|
-
"logout": "Salir",
|
|
19
|
-
"anonymous": "Anónimo"
|
|
20
|
-
}
|
package/lib/i18n/fa.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "بارگزاری ...",
|
|
3
|
-
"no-found-related": "%{link} مرتبط پیدا نشد.",
|
|
4
|
-
"please-contact": "لطفاً با %{user} اطلاع دهید تا اضافه کند.",
|
|
5
|
-
"init-issue": "شروع نظرات",
|
|
6
|
-
"leave-a-comment": "نظرتان را بنویسید",
|
|
7
|
-
"preview": "پیشنمایش",
|
|
8
|
-
"edit": "ویرایش",
|
|
9
|
-
"comment": "ثبت",
|
|
10
|
-
"support-markdown": "پشتیبانی از مارکداون",
|
|
11
|
-
"login-with-github": "ورود با گیتهاب",
|
|
12
|
-
"first-comment-person": "اولین نظر را شما بنویسید!",
|
|
13
|
-
"commented": " - ",
|
|
14
|
-
"load-more": "نظرات بیشتر",
|
|
15
|
-
"counts": "%{counts} نظر |||| %{counts} نظر",
|
|
16
|
-
"sort-asc": "مرتبسازی از قدیمیترین",
|
|
17
|
-
"sort-desc": "مرتبسازی از جدیدترین",
|
|
18
|
-
"logout": "خروج",
|
|
19
|
-
"anonymous": "بینام"
|
|
20
|
-
}
|
package/lib/i18n/fr.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalking ...",
|
|
3
|
-
"no-found-related": "Lien %{link} non trouvé",
|
|
4
|
-
"please-contact": "Veuillez contacter %{user} pour initialiser les commentaires",
|
|
5
|
-
"init-issue": "Initialisation des issues",
|
|
6
|
-
"leave-a-comment": "Laisser un commentaire",
|
|
7
|
-
"preview": "Aperçu",
|
|
8
|
-
"edit": "Modifier",
|
|
9
|
-
"comment": "Commentaire",
|
|
10
|
-
"support-markdown": "Markdown est supporté",
|
|
11
|
-
"login-with-github": "Se connecter avec GitHub",
|
|
12
|
-
"first-comment-person": "Soyez le premier à laisser un commentaire !",
|
|
13
|
-
"commented": "a commenté",
|
|
14
|
-
"load-more": "Charger plus",
|
|
15
|
-
"counts": "%{counts} commentaire |||| %{counts} commentaires",
|
|
16
|
-
"sort-asc": "Trier du plus ancien au plus récent",
|
|
17
|
-
"sort-desc": "Trier du plus récent au plus ancien",
|
|
18
|
-
"logout": "Déconnexion",
|
|
19
|
-
"anonymous": "Anonyme"
|
|
20
|
-
}
|
package/lib/i18n/index.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import Polyglot from "node-polyglot";
|
|
2
|
-
|
|
3
|
-
import { DEFAULT_LANG } from "../constants";
|
|
4
|
-
import DE from "./de.json";
|
|
5
|
-
import EN from "./en.json";
|
|
6
|
-
import ES from "./es-ES.json";
|
|
7
|
-
import FA from "./fa.json";
|
|
8
|
-
import FR from "./fr.json";
|
|
9
|
-
import JA from "./ja.json";
|
|
10
|
-
import KO from "./ko.json";
|
|
11
|
-
import PL from "./pl.json";
|
|
12
|
-
import RU from "./ru.json";
|
|
13
|
-
import ZHCN from "./zh-CN.json";
|
|
14
|
-
import ZHTW from "./zh-TW.json";
|
|
15
|
-
|
|
16
|
-
export const i18nMap = {
|
|
17
|
-
zh: ZHCN,
|
|
18
|
-
"zh-CN": ZHCN,
|
|
19
|
-
"zh-TW": ZHTW,
|
|
20
|
-
en: EN,
|
|
21
|
-
"es-ES": ES,
|
|
22
|
-
fr: FR,
|
|
23
|
-
ru: RU,
|
|
24
|
-
de: DE,
|
|
25
|
-
pl: PL,
|
|
26
|
-
ko: KO,
|
|
27
|
-
fa: FA,
|
|
28
|
-
ja: JA,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type Lang = keyof typeof i18nMap;
|
|
32
|
-
|
|
33
|
-
const getPolyglotInstance = (lang: Lang = DEFAULT_LANG) => {
|
|
34
|
-
return new Polyglot({
|
|
35
|
-
phrases: i18nMap[lang] ?? i18nMap.en,
|
|
36
|
-
locale: lang,
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default getPolyglotInstance;
|
package/lib/i18n/ja.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalk を読み込んでいます...",
|
|
3
|
-
"no-found-related": "%{link} に関連するものが見当たりません",
|
|
4
|
-
"please-contact": "コメントを初期化するために %{user} に連絡してください",
|
|
5
|
-
"init-issue": "イシューを初期化する",
|
|
6
|
-
"leave-a-comment": "コメントを残す",
|
|
7
|
-
"preview": "プレビュー",
|
|
8
|
-
"edit": "編集する",
|
|
9
|
-
"comment": "コメント",
|
|
10
|
-
"support-markdown": "Markdown 記法をサポートしています",
|
|
11
|
-
"login-with-github": "GitHub にログインする",
|
|
12
|
-
"first-comment-person": "最初にコメントを残しましょう!",
|
|
13
|
-
"commented": "によるコメント",
|
|
14
|
-
"load-more": "もっと見る",
|
|
15
|
-
"counts": "%{counts} つのコメント",
|
|
16
|
-
"sort-asc": "投稿順に並び替え",
|
|
17
|
-
"sort-desc": "最新順で並び替え",
|
|
18
|
-
"logout": "ログアウト",
|
|
19
|
-
"anonymous": "匿名"
|
|
20
|
-
}
|
package/lib/i18n/ko.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "초기화 중 ...",
|
|
3
|
-
"no-found-related": "관련 링크를 찾을 수 없습니다: %{link} ",
|
|
4
|
-
"please-contact": "초기화를 위해 %{user} 에게 연락해 주세요",
|
|
5
|
-
"init-issue": "이슈 초기화",
|
|
6
|
-
"leave-a-comment": "댓글을 남겨보세요",
|
|
7
|
-
"preview": "미리보기",
|
|
8
|
-
"edit": "수정하기",
|
|
9
|
-
"comment": "댓글 달기",
|
|
10
|
-
"support-markdown": "마크다운(Markdown) 문법 지원",
|
|
11
|
-
"login-with-github": "GitHub로 로그인하기",
|
|
12
|
-
"first-comment-person": "첫 번째로 댓글을 남겨보세요!",
|
|
13
|
-
"commented": "님이 작성함",
|
|
14
|
-
"load-more": "더 보기",
|
|
15
|
-
"counts": "댓글 %{counts} 개",
|
|
16
|
-
"sort-asc": "오래된 댓글 먼저",
|
|
17
|
-
"sort-desc": "최신 댓글 먼저",
|
|
18
|
-
"logout": "로그아웃",
|
|
19
|
-
"anonymous": "익명"
|
|
20
|
-
}
|
package/lib/i18n/pl.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalking ...",
|
|
3
|
-
"no-found-related": "Nie znaleziono powiązanego zgłoszenia: %{link}",
|
|
4
|
-
"please-contact": "Skontaktuj się z %{user}, aby umożliwić komentowanie",
|
|
5
|
-
"init-issue": "Utwórz zgłoszenie (GitHub Issue)",
|
|
6
|
-
"leave-a-comment": "Skomentuj",
|
|
7
|
-
"preview": "Podgląd",
|
|
8
|
-
"edit": "Edytuj",
|
|
9
|
-
"comment": "Wyślij",
|
|
10
|
-
"support-markdown": "Możesz użyć składni Markdown",
|
|
11
|
-
"login-with-github": "Zaloguj się poprzez GitHub",
|
|
12
|
-
"first-comment-person": "Skomentuj jako pierwszy!",
|
|
13
|
-
"commented": "skomentowany",
|
|
14
|
-
"load-more": "Załaduj więcej",
|
|
15
|
-
"counts": "%{counts} komentarz |||| %{counts} komentarze |||| %{counts} komentarzy",
|
|
16
|
-
"sort-asc": "Sortuj od najstarszych",
|
|
17
|
-
"sort-desc": "Sortuj od najnowszych",
|
|
18
|
-
"logout": "Wyloguj",
|
|
19
|
-
"anonymous": "Anonimowy"
|
|
20
|
-
}
|
|
21
|
-
|
package/lib/i18n/ru.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalking ...",
|
|
3
|
-
"no-found-related": "Связанные %{link} не найдены",
|
|
4
|
-
"please-contact": "Пожалуйста, свяжитесь с %{user} чтобы инициализировать комментарий",
|
|
5
|
-
"init-issue": "Выпуск инициализации",
|
|
6
|
-
"leave-a-comment": "Оставить комментарий",
|
|
7
|
-
"preview": "Предварительный просмотр",
|
|
8
|
-
"edit": "Pедактировать",
|
|
9
|
-
"comment": "Комментарий",
|
|
10
|
-
"support-markdown": "Поддерживается Markdown",
|
|
11
|
-
"login-with-github": "Вход через GitHub",
|
|
12
|
-
"first-comment-person": "Будьте первым, кто оставил комментарий",
|
|
13
|
-
"commented": "прокомментированный",
|
|
14
|
-
"load-more": "Загрузить ещё",
|
|
15
|
-
"counts": "%{counts} комментарий |||| %{counts} комментариев",
|
|
16
|
-
"sort-asc": "Сортировать по старым",
|
|
17
|
-
"sort-desc": "Сортировать по последним",
|
|
18
|
-
"logout": "Выход",
|
|
19
|
-
"anonymous": "Анонимный"
|
|
20
|
-
}
|
package/lib/i18n/zh-CN.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalk 加载中 ...",
|
|
3
|
-
"no-found-related": "未找到相关的 %{link} 进行评论",
|
|
4
|
-
"please-contact": "请联系 %{user} 初始化创建",
|
|
5
|
-
"init-issue": "初始化 Issue",
|
|
6
|
-
"leave-a-comment": "说点什么",
|
|
7
|
-
"preview": "预览",
|
|
8
|
-
"edit": "编辑",
|
|
9
|
-
"comment": "评论",
|
|
10
|
-
"support-markdown": "支持 Markdown 语法",
|
|
11
|
-
"login-with-github": "使用 GitHub 登录",
|
|
12
|
-
"first-comment-person": "来做第一个留言的人吧!",
|
|
13
|
-
"commented": "发表于",
|
|
14
|
-
"load-more": "加载更多",
|
|
15
|
-
"counts": "%{counts} 条评论",
|
|
16
|
-
"sort-asc": "从旧到新排序",
|
|
17
|
-
"sort-desc": "从新到旧排序",
|
|
18
|
-
"logout": "注销",
|
|
19
|
-
"anonymous": "未登录用户"
|
|
20
|
-
}
|
package/lib/i18n/zh-TW.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"init": "Gitalk 載入中…",
|
|
3
|
-
"no-found-related": "未找到相關的 %{link}",
|
|
4
|
-
"please-contact": "請聯絡 %{user} 初始化評論",
|
|
5
|
-
"init-issue": "初始化 Issue",
|
|
6
|
-
"leave-a-comment": "寫點什麼",
|
|
7
|
-
"preview": "預覽",
|
|
8
|
-
"edit": "編輯",
|
|
9
|
-
"comment": "評論",
|
|
10
|
-
"support-markdown": "支援 Markdown 語法",
|
|
11
|
-
"login-with-github": "使用 GitHub 登入",
|
|
12
|
-
"first-comment-person": "成為首個留言的人吧!",
|
|
13
|
-
"commented": "評論於",
|
|
14
|
-
"load-more": "載入更多",
|
|
15
|
-
"counts": "%{counts} 筆評論",
|
|
16
|
-
"sort-asc": "從舊至新排序",
|
|
17
|
-
"sort-desc": "從新至舊排序",
|
|
18
|
-
"logout": "登出",
|
|
19
|
-
"anonymous": "訪客"
|
|
20
|
-
}
|
package/lib/interfaces/index.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import type { Endpoints } from "@octokit/types";
|
|
2
|
-
import type FlipMove from "react-flip-move";
|
|
3
|
-
|
|
4
|
-
import type { Lang } from "../i18n";
|
|
5
|
-
import type { IssueCommentsQLResponse } from "../services/graphql/comment";
|
|
6
|
-
|
|
7
|
-
export interface GitalkProps
|
|
8
|
-
extends Omit<
|
|
9
|
-
React.DetailedHTMLProps<
|
|
10
|
-
React.HTMLAttributes<HTMLDivElement>,
|
|
11
|
-
HTMLDivElement
|
|
12
|
-
>,
|
|
13
|
-
"id" | "title"
|
|
14
|
-
> {
|
|
15
|
-
/**
|
|
16
|
-
* GitHub Application Client ID.
|
|
17
|
-
*/
|
|
18
|
-
clientID: string;
|
|
19
|
-
/**
|
|
20
|
-
* GitHub Application Client Secret.
|
|
21
|
-
*/
|
|
22
|
-
clientSecret: string;
|
|
23
|
-
/**
|
|
24
|
-
* GitHub repository owner.
|
|
25
|
-
* Can be personal user or organization.
|
|
26
|
-
*/
|
|
27
|
-
owner: string;
|
|
28
|
-
/**
|
|
29
|
-
* Name of Github repository.
|
|
30
|
-
*/
|
|
31
|
-
repo: string;
|
|
32
|
-
/**
|
|
33
|
-
* GitHub repository owner and collaborators.
|
|
34
|
-
* (Users who having write access to this repository)
|
|
35
|
-
*/
|
|
36
|
-
admin: string[];
|
|
37
|
-
/**
|
|
38
|
-
* The unique id of the page.
|
|
39
|
-
* Length must less than 50.
|
|
40
|
-
*
|
|
41
|
-
* @default location.host + location.pathname
|
|
42
|
-
*/
|
|
43
|
-
id?: string;
|
|
44
|
-
/**
|
|
45
|
-
* The issue ID of the page.
|
|
46
|
-
* If the number attribute is not defined, issue will be located using id.
|
|
47
|
-
*/
|
|
48
|
-
number?: number;
|
|
49
|
-
/**
|
|
50
|
-
* GitHub issue labels.
|
|
51
|
-
*
|
|
52
|
-
* @default ['Gitalk']
|
|
53
|
-
*/
|
|
54
|
-
labels?: string[];
|
|
55
|
-
/**
|
|
56
|
-
* GitHub issue title.
|
|
57
|
-
*
|
|
58
|
-
* @default document.title
|
|
59
|
-
*/
|
|
60
|
-
title?: string;
|
|
61
|
-
/**
|
|
62
|
-
* GitHub issue body.
|
|
63
|
-
*
|
|
64
|
-
* @default location.href + header.meta[description]
|
|
65
|
-
*/
|
|
66
|
-
body?: string;
|
|
67
|
-
/**
|
|
68
|
-
* Localization language key.
|
|
69
|
-
*
|
|
70
|
-
* @default navigator.language
|
|
71
|
-
*/
|
|
72
|
-
language?: Lang;
|
|
73
|
-
/**
|
|
74
|
-
* Pagination size, with maximum 100.
|
|
75
|
-
*
|
|
76
|
-
* @default 10
|
|
77
|
-
*/
|
|
78
|
-
perPage?: number;
|
|
79
|
-
/**
|
|
80
|
-
* Comment sorting direction.
|
|
81
|
-
* Available values are `last` and `first`.
|
|
82
|
-
*
|
|
83
|
-
* @default "last"
|
|
84
|
-
*/
|
|
85
|
-
pagerDirection?: "last" | "first";
|
|
86
|
-
/**
|
|
87
|
-
* By default, Gitalk will create a corresponding github issue for your every single page automatically when the logined user is belong to the admin users.
|
|
88
|
-
* You can create it manually by setting this option to true.
|
|
89
|
-
*
|
|
90
|
-
* @default false
|
|
91
|
-
*/
|
|
92
|
-
createIssueManually?: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Enable hot key (cmd|ctrl + enter) submit comment.
|
|
95
|
-
*
|
|
96
|
-
* @default true
|
|
97
|
-
*/
|
|
98
|
-
enableHotKey?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Facebook-like distraction free mode.
|
|
101
|
-
*
|
|
102
|
-
* @default false
|
|
103
|
-
*/
|
|
104
|
-
distractionFreeMode?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Comment list animation.
|
|
107
|
-
*
|
|
108
|
-
* @default
|
|
109
|
-
* ```ts
|
|
110
|
-
* {
|
|
111
|
-
* staggerDelayBy: 150,
|
|
112
|
-
* appearAnimation: 'accordionVertical',
|
|
113
|
-
* enterAnimation: 'accordionVertical',
|
|
114
|
-
* leaveAnimation: 'accordionVertical',
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
* @link https://github.com/joshwcomeau/react-flip-move/blob/master/documentation/enter_leave_animations.md
|
|
118
|
-
*/
|
|
119
|
-
flipMoveOptions?: FlipMove.FlipMoveProps;
|
|
120
|
-
/**
|
|
121
|
-
* GitHub oauth request reverse proxy for CORS.
|
|
122
|
-
* [Why need this?](https://github.com/isaacs/github/issues/330)
|
|
123
|
-
*
|
|
124
|
-
* @default "https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token"
|
|
125
|
-
*/
|
|
126
|
-
proxy?: string;
|
|
127
|
-
/**
|
|
128
|
-
* Default user field if comments' author is not provided
|
|
129
|
-
*
|
|
130
|
-
* @default
|
|
131
|
-
* ```ts
|
|
132
|
-
* {
|
|
133
|
-
* avatar_url: "//avatars1.githubusercontent.com/u/29697133?s=50",
|
|
134
|
-
* login: "null",
|
|
135
|
-
* html_url: ""
|
|
136
|
-
* }
|
|
137
|
-
*/
|
|
138
|
-
defaultUser?: Comment["user"];
|
|
139
|
-
/**
|
|
140
|
-
* Default user field if comments' author is not provided
|
|
141
|
-
*
|
|
142
|
-
* @deprecated use `defaultUser`
|
|
143
|
-
*/
|
|
144
|
-
defaultAuthor?: IssueCommentsQLResponse["repository"]["issue"]["comments"]["nodes"][number]["author"];
|
|
145
|
-
/**
|
|
146
|
-
* Default collapse the comment if meets the height (px)
|
|
147
|
-
*/
|
|
148
|
-
collapsedHeight?: number;
|
|
149
|
-
/**
|
|
150
|
-
* Callback method invoked when updating the number of comments.
|
|
151
|
-
*
|
|
152
|
-
* @param count comments number
|
|
153
|
-
*/
|
|
154
|
-
updateCountCallback?: (count: number) => void;
|
|
155
|
-
/**
|
|
156
|
-
* Callback method invoked when a new issue is successfully created.
|
|
157
|
-
*
|
|
158
|
-
* @param issue created issue
|
|
159
|
-
*/
|
|
160
|
-
onCreateIssue?: (issue: Issue) => void;
|
|
161
|
-
/**
|
|
162
|
-
* Callback method invoked when a new comment is successfully created.
|
|
163
|
-
*
|
|
164
|
-
* @param comment created comment
|
|
165
|
-
*/
|
|
166
|
-
onCreateComment?: (comment: Comment) => void;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export type User = Endpoints["GET /user"]["response"]["data"];
|
|
170
|
-
|
|
171
|
-
export type Issue =
|
|
172
|
-
Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}"]["response"]["data"];
|
|
173
|
-
|
|
174
|
-
type CommentDefine =
|
|
175
|
-
Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}/comments"]["response"]["data"][number];
|
|
176
|
-
|
|
177
|
-
export type Comment = Pick<
|
|
178
|
-
CommentDefine,
|
|
179
|
-
"id" | "body" | "body_html" | "created_at" | "html_url"
|
|
180
|
-
> & {
|
|
181
|
-
user: Pick<
|
|
182
|
-
NonNullable<CommentDefine["user"]>,
|
|
183
|
-
"avatar_url" | "login" | "html_url"
|
|
184
|
-
>;
|
|
185
|
-
reactions: Pick<NonNullable<CommentDefine["reactions"]>, "heart">;
|
|
186
|
-
reactionsHeart: {
|
|
187
|
-
totalCount: number;
|
|
188
|
-
viewerHasReacted: boolean;
|
|
189
|
-
nodes: {
|
|
190
|
-
databaseId: number;
|
|
191
|
-
user: {
|
|
192
|
-
login: string;
|
|
193
|
-
};
|
|
194
|
-
}[];
|
|
195
|
-
};
|
|
196
|
-
};
|
|
@@ -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
|
-
};
|