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.
Files changed (63) hide show
  1. package/README-zh-CN.md +152 -53
  2. package/README.md +132 -34
  3. package/dist/gitalk-dark.css +1 -1
  4. package/dist/gitalk-light.css +1 -1
  5. package/dist/gitalk.browser.full.js +102 -0
  6. package/dist/gitalk.browser.js +94 -0
  7. package/dist/gitalk.cjs +94 -0
  8. package/dist/gitalk.d.cts +14 -0
  9. package/dist/gitalk.d.mts +174 -0
  10. package/dist/gitalk.js +2737 -10382
  11. package/package.json +61 -41
  12. package/proxy-server/.env.example +6 -0
  13. package/proxy-server/README.md +38 -0
  14. package/proxy-server/server.mjs +110 -0
  15. package/dist/gitalk.d.ts +0 -623
  16. package/dist/gitalk.umd.cjs +0 -126
  17. package/lib/assets/arrow-down.svg +0 -1
  18. package/lib/assets/edit.svg +0 -3
  19. package/lib/assets/github.svg +0 -3
  20. package/lib/assets/heart-filled.svg +0 -3
  21. package/lib/assets/heart.svg +0 -3
  22. package/lib/assets/reply.svg +0 -3
  23. package/lib/assets/tip.svg +0 -8
  24. package/lib/components/action.tsx +0 -21
  25. package/lib/components/avatar.tsx +0 -42
  26. package/lib/components/button.tsx +0 -35
  27. package/lib/components/comment-textarea.tsx +0 -166
  28. package/lib/components/comment.tsx +0 -204
  29. package/lib/components/comments-list.tsx +0 -112
  30. package/lib/components/meta.tsx +0 -133
  31. package/lib/components/svg.tsx +0 -29
  32. package/lib/constants/index.ts +0 -71
  33. package/lib/contexts/I18nContext.ts +0 -20
  34. package/lib/gitalk.tsx +0 -891
  35. package/lib/i18n/ar.json +0 -20
  36. package/lib/i18n/bn.json +0 -20
  37. package/lib/i18n/de.json +0 -20
  38. package/lib/i18n/en.json +0 -20
  39. package/lib/i18n/es.json +0 -20
  40. package/lib/i18n/fa.json +0 -20
  41. package/lib/i18n/fr.json +0 -20
  42. package/lib/i18n/hi.json +0 -20
  43. package/lib/i18n/index.ts +0 -53
  44. package/lib/i18n/ja.json +0 -20
  45. package/lib/i18n/ko.json +0 -20
  46. package/lib/i18n/pl.json +0 -21
  47. package/lib/i18n/pt.json +0 -20
  48. package/lib/i18n/ru.json +0 -20
  49. package/lib/i18n/ur.json +0 -20
  50. package/lib/i18n/zh-CN.json +0 -20
  51. package/lib/i18n/zh-TW.json +0 -20
  52. package/lib/interfaces/index.ts +0 -198
  53. package/lib/services/graphql/comment.ts +0 -84
  54. package/lib/services/request.ts +0 -24
  55. package/lib/services/user.ts +0 -40
  56. package/lib/themes/base.scss +0 -630
  57. package/lib/themes/gitalk-dark.scss +0 -28
  58. package/lib/themes/gitalk-light.scss +0 -28
  59. package/lib/utils/compatibility.ts +0 -35
  60. package/lib/utils/dom.ts +0 -15
  61. package/lib/utils/logger.ts +0 -66
  62. package/lib/utils/query.ts +0 -19
  63. package/lib/vite-env.d.ts +0 -1
package/dist/gitalk.d.ts DELETED
@@ -1,623 +0,0 @@
1
- import { default as default_2 } from 'react';
2
- import { default as default_3 } from 'react-flip-move';
3
- import { Endpoints } from '@octokit/types';
4
-
5
- declare type Comment_2 = Pick<CommentDefine, "id" | "body" | "body_html" | "created_at" | "html_url"> & {
6
- user: Pick<NonNullable<CommentDefine["user"]>, "avatar_url" | "login" | "html_url">;
7
- reactions: Pick<NonNullable<CommentDefine["reactions"]>, "heart">;
8
- reactionsHeart: {
9
- totalCount: number;
10
- viewerHasReacted: boolean;
11
- nodes: {
12
- databaseId: number;
13
- user: {
14
- login: string;
15
- };
16
- }[];
17
- };
18
- };
19
-
20
- declare type CommentDefine = Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}/comments"]["response"]["data"][number];
21
-
22
- export declare const DEFAULT_FLIP_MOVE_OPTIONS: NonNullable<GitalkProps["flipMoveOptions"]>;
23
-
24
- declare const Gitalk: default_2.FC<GitalkProps>;
25
- export default Gitalk;
26
-
27
- export declare interface GitalkProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id" | "title"> {
28
- /**
29
- * GitHub Application Client ID.
30
- */
31
- clientID: string;
32
- /**
33
- * GitHub Application Client Secret.
34
- */
35
- clientSecret: string;
36
- /**
37
- * GitHub repository owner.
38
- * Can be personal user or organization.
39
- */
40
- owner: string;
41
- /**
42
- * Name of Github repository.
43
- */
44
- repo: string;
45
- /**
46
- * GitHub repository owner and collaborators.
47
- * (Users who having write access to this repository)
48
- */
49
- admin: string[];
50
- /**
51
- * The unique id of the page.
52
- * Length must less than 50.
53
- *
54
- * @default location.host + location.pathname
55
- */
56
- id?: string;
57
- /**
58
- * The issue ID of the page.
59
- * If the number attribute is not defined, issue will be located using id.
60
- */
61
- number?: number;
62
- /**
63
- * GitHub issue labels.
64
- *
65
- * @default ['Gitalk']
66
- */
67
- labels?: string[];
68
- /**
69
- * GitHub issue title.
70
- *
71
- * @default document.title
72
- */
73
- title?: string;
74
- /**
75
- * GitHub issue body.
76
- *
77
- * @default location.href + header.meta[description]
78
- */
79
- body?: string;
80
- /**
81
- * Localization language key.
82
- *
83
- * @default navigator.language
84
- */
85
- language?: Lang;
86
- /**
87
- * Pagination size, with maximum 100.
88
- *
89
- * @default 10
90
- */
91
- perPage?: number;
92
- /**
93
- * Comment sorting direction.
94
- * Available values are `last` and `first`.
95
- *
96
- * @default "last"
97
- */
98
- pagerDirection?: "last" | "first";
99
- /**
100
- * 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.
101
- * You can create it manually by setting this option to true.
102
- *
103
- * @default false
104
- */
105
- createIssueManually?: boolean;
106
- /**
107
- * Enable hot key (cmd|ctrl + enter) submit comment.
108
- *
109
- * @default true
110
- */
111
- enableHotKey?: boolean;
112
- /**
113
- * Facebook-like distraction free mode.
114
- *
115
- * @default false
116
- */
117
- distractionFreeMode?: boolean;
118
- /**
119
- * Comment list animation.
120
- *
121
- * @default
122
- * ```ts
123
- * {
124
- * staggerDelayBy: 150,
125
- * appearAnimation: 'accordionVertical',
126
- * enterAnimation: 'accordionVertical',
127
- * leaveAnimation: 'accordionVertical',
128
- * }
129
- * ```
130
- * @link https://github.com/joshwcomeau/react-flip-move/blob/master/documentation/enter_leave_animations.md
131
- */
132
- flipMoveOptions?: default_3.FlipMoveProps;
133
- /**
134
- * GitHub oauth request reverse proxy for CORS.
135
- * [Why need this?](https://github.com/isaacs/github/issues/330)
136
- *
137
- * @default "https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token"
138
- */
139
- proxy?: string;
140
- /**
141
- * Default user field if comments' author is not provided
142
- *
143
- * @default
144
- * ```ts
145
- * {
146
- * avatar_url: "//avatars1.githubusercontent.com/u/29697133?s=50",
147
- * login: "null",
148
- * html_url: ""
149
- * }
150
- */
151
- defaultUser?: Comment_2["user"];
152
- /**
153
- * Default user field if comments' author is not provided
154
- *
155
- * @deprecated use `defaultUser`
156
- */
157
- defaultAuthor?: IssueCommentsQLResponse["repository"]["issue"]["comments"]["nodes"][number]["author"];
158
- /**
159
- * Default collapse the comment if meets the height (px)
160
- */
161
- collapsedHeight?: number;
162
- /**
163
- * Whether to highlight the comment created by admin users.
164
- *
165
- * @default true
166
- */
167
- highlightAdminComment?: boolean;
168
- /**
169
- * Callback method invoked when updating the number of comments.
170
- *
171
- * @param count comments number
172
- */
173
- updateCountCallback?: (count: number) => void;
174
- /**
175
- * Callback method invoked when a new issue is successfully created.
176
- *
177
- * @param issue created issue
178
- */
179
- onCreateIssue?: (issue: Issue) => void;
180
- /**
181
- * Callback method invoked when a new comment is successfully created.
182
- *
183
- * @param comment created comment
184
- */
185
- onCreateComment?: (comment: Comment_2) => void;
186
- }
187
-
188
- declare const i18nMap: {
189
- en: {
190
- init: string;
191
- "no-found-related": string;
192
- "please-contact": string;
193
- "init-issue": string;
194
- "leave-a-comment": string;
195
- preview: string;
196
- edit: string;
197
- comment: string;
198
- "support-markdown": string;
199
- "login-with-github": string;
200
- "first-comment-person": string;
201
- commented: string;
202
- "load-more": string;
203
- counts: string;
204
- "sort-asc": string;
205
- "sort-desc": string;
206
- logout: string;
207
- anonymous: string;
208
- };
209
- zh: {
210
- init: string;
211
- "no-found-related": string;
212
- "please-contact": string;
213
- "init-issue": string;
214
- "leave-a-comment": string;
215
- preview: string;
216
- edit: string;
217
- comment: string;
218
- "support-markdown": string;
219
- "login-with-github": string;
220
- "first-comment-person": string;
221
- commented: string;
222
- "load-more": string;
223
- counts: string;
224
- "sort-asc": string;
225
- "sort-desc": string;
226
- logout: string;
227
- anonymous: string;
228
- };
229
- "zh-CN": {
230
- init: string;
231
- "no-found-related": string;
232
- "please-contact": string;
233
- "init-issue": string;
234
- "leave-a-comment": string;
235
- preview: string;
236
- edit: string;
237
- comment: string;
238
- "support-markdown": string;
239
- "login-with-github": string;
240
- "first-comment-person": string;
241
- commented: string;
242
- "load-more": string;
243
- counts: string;
244
- "sort-asc": string;
245
- "sort-desc": string;
246
- logout: string;
247
- anonymous: string;
248
- };
249
- "zh-SG": {
250
- init: string;
251
- "no-found-related": string;
252
- "please-contact": string;
253
- "init-issue": string;
254
- "leave-a-comment": string;
255
- preview: string;
256
- edit: string;
257
- comment: string;
258
- "support-markdown": string;
259
- "login-with-github": string;
260
- "first-comment-person": string;
261
- commented: string;
262
- "load-more": string;
263
- counts: string;
264
- "sort-asc": string;
265
- "sort-desc": string;
266
- logout: string;
267
- anonymous: string;
268
- };
269
- "zh-TW": {
270
- init: string;
271
- "no-found-related": string;
272
- "please-contact": string;
273
- "init-issue": string;
274
- "leave-a-comment": string;
275
- preview: string;
276
- edit: string;
277
- comment: string;
278
- "support-markdown": string;
279
- "login-with-github": string;
280
- "first-comment-person": string;
281
- commented: string;
282
- "load-more": string;
283
- counts: string;
284
- "sort-asc": string;
285
- "sort-desc": string;
286
- logout: string;
287
- anonymous: string;
288
- };
289
- "zh-HK": {
290
- init: string;
291
- "no-found-related": string;
292
- "please-contact": string;
293
- "init-issue": string;
294
- "leave-a-comment": string;
295
- preview: string;
296
- edit: string;
297
- comment: string;
298
- "support-markdown": string;
299
- "login-with-github": string;
300
- "first-comment-person": string;
301
- commented: string;
302
- "load-more": string;
303
- counts: string;
304
- "sort-asc": string;
305
- "sort-desc": string;
306
- logout: string;
307
- anonymous: string;
308
- };
309
- "zh-MO": {
310
- init: string;
311
- "no-found-related": string;
312
- "please-contact": string;
313
- "init-issue": string;
314
- "leave-a-comment": string;
315
- preview: string;
316
- edit: string;
317
- comment: string;
318
- "support-markdown": string;
319
- "login-with-github": string;
320
- "first-comment-person": string;
321
- commented: string;
322
- "load-more": string;
323
- counts: string;
324
- "sort-asc": string;
325
- "sort-desc": string;
326
- logout: string;
327
- anonymous: string;
328
- };
329
- hi: {
330
- init: string;
331
- "no-found-related": string;
332
- "please-contact": string;
333
- "init-issue": string;
334
- "leave-a-comment": string;
335
- preview: string;
336
- edit: string;
337
- comment: string;
338
- "support-markdown": string;
339
- "login-with-github": string;
340
- "first-comment-person": string;
341
- commented: string;
342
- "load-more": string;
343
- counts: string;
344
- "sort-asc": string;
345
- "sort-desc": string;
346
- logout: string;
347
- anonymous: string;
348
- };
349
- es: {
350
- init: string;
351
- "no-found-related": string;
352
- "please-contact": string;
353
- "init-issue": string;
354
- "leave-a-comment": string;
355
- preview: string;
356
- edit: string;
357
- comment: string;
358
- "support-markdown": string;
359
- "login-with-github": string;
360
- "first-comment-person": string;
361
- commented: string;
362
- "load-more": string;
363
- counts: string;
364
- "sort-asc": string;
365
- "sort-desc": string;
366
- logout: string;
367
- anonymous: string;
368
- };
369
- fr: {
370
- init: string;
371
- "no-found-related": string;
372
- "please-contact": string;
373
- "init-issue": string;
374
- "leave-a-comment": string;
375
- preview: string;
376
- edit: string;
377
- comment: string;
378
- "support-markdown": string;
379
- "login-with-github": string;
380
- "first-comment-person": string;
381
- commented: string;
382
- "load-more": string;
383
- counts: string;
384
- "sort-asc": string;
385
- "sort-desc": string;
386
- logout: string;
387
- anonymous: string;
388
- };
389
- ar: {
390
- init: string;
391
- "no-found-related": string;
392
- "please-contact": string;
393
- "init-issue": string;
394
- "leave-a-comment": string;
395
- preview: string;
396
- edit: string;
397
- comment: string;
398
- "support-markdown": string;
399
- "login-with-github": string;
400
- "first-comment-person": string;
401
- commented: string;
402
- "load-more": string;
403
- counts: string;
404
- "sort-asc": string;
405
- "sort-desc": string;
406
- logout: string;
407
- anonymous: string;
408
- };
409
- bn: {
410
- init: string;
411
- "no-found-related": string;
412
- "please-contact": string;
413
- "init-issue": string;
414
- "leave-a-comment": string;
415
- preview: string;
416
- edit: string;
417
- comment: string;
418
- "support-markdown": string;
419
- "login-with-github": string;
420
- "first-comment-person": string;
421
- commented: string;
422
- "load-more": string;
423
- counts: string;
424
- "sort-asc": string;
425
- "sort-desc": string;
426
- logout: string;
427
- anonymous: string;
428
- };
429
- ru: {
430
- init: string;
431
- "no-found-related": string;
432
- "please-contact": string;
433
- "init-issue": string;
434
- "leave-a-comment": string;
435
- preview: string;
436
- edit: string;
437
- comment: string;
438
- "support-markdown": string;
439
- "login-with-github": string;
440
- "first-comment-person": string;
441
- commented: string;
442
- "load-more": string;
443
- counts: string;
444
- "sort-asc": string;
445
- "sort-desc": string;
446
- logout: string;
447
- anonymous: string;
448
- };
449
- pt: {
450
- init: string;
451
- "no-found-related": string;
452
- "please-contact": string;
453
- "init-issue": string;
454
- "leave-a-comment": string;
455
- preview: string;
456
- edit: string;
457
- comment: string;
458
- "support-markdown": string;
459
- "login-with-github": string;
460
- "first-comment-person": string;
461
- commented: string;
462
- "load-more": string;
463
- counts: string;
464
- "sort-asc": string;
465
- "sort-desc": string;
466
- logout: string;
467
- anonymous: string;
468
- };
469
- ur: {
470
- init: string;
471
- "no-found-related": string;
472
- "please-contact": string;
473
- "init-issue": string;
474
- "leave-a-comment": string;
475
- preview: string;
476
- edit: string;
477
- comment: string;
478
- "support-markdown": string;
479
- "login-with-github": string;
480
- "first-comment-person": string;
481
- commented: string;
482
- "load-more": string;
483
- counts: string;
484
- "sort-asc": string;
485
- "sort-desc": string;
486
- logout: string;
487
- anonymous: string;
488
- };
489
- ko: {
490
- init: string;
491
- "no-found-related": string;
492
- "please-contact": string;
493
- "init-issue": string;
494
- "leave-a-comment": string;
495
- preview: string;
496
- edit: string;
497
- comment: string;
498
- "support-markdown": string;
499
- "login-with-github": string;
500
- "first-comment-person": string;
501
- commented: string;
502
- "load-more": string;
503
- counts: string;
504
- "sort-asc": string;
505
- "sort-desc": string;
506
- logout: string;
507
- anonymous: string;
508
- };
509
- ja: {
510
- init: string;
511
- "no-found-related": string;
512
- "please-contact": string;
513
- "init-issue": string;
514
- "leave-a-comment": string;
515
- preview: string;
516
- edit: string;
517
- comment: string;
518
- "support-markdown": string;
519
- "login-with-github": string;
520
- "first-comment-person": string;
521
- commented: string;
522
- "load-more": string;
523
- counts: string;
524
- "sort-asc": string;
525
- "sort-desc": string;
526
- logout: string;
527
- anonymous: string;
528
- };
529
- de: {
530
- init: string;
531
- "no-found-related": string;
532
- "please-contact": string;
533
- "init-issue": string;
534
- "leave-a-comment": string;
535
- preview: string;
536
- edit: string;
537
- comment: string;
538
- "support-markdown": string;
539
- "login-with-github": string;
540
- "first-comment-person": string;
541
- commented: string;
542
- "load-more": string;
543
- counts: string;
544
- "sort-asc": string;
545
- "sort-desc": string;
546
- logout: string;
547
- anonymous: string;
548
- };
549
- pl: {
550
- init: string;
551
- "no-found-related": string;
552
- "please-contact": string;
553
- "init-issue": string;
554
- "leave-a-comment": string;
555
- preview: string;
556
- edit: string;
557
- comment: string;
558
- "support-markdown": string;
559
- "login-with-github": string;
560
- "first-comment-person": string;
561
- commented: string;
562
- "load-more": string;
563
- counts: string;
564
- "sort-asc": string;
565
- "sort-desc": string;
566
- logout: string;
567
- anonymous: string;
568
- };
569
- fa: {
570
- init: string;
571
- "no-found-related": string;
572
- "please-contact": string;
573
- "init-issue": string;
574
- "leave-a-comment": string;
575
- preview: string;
576
- edit: string;
577
- comment: string;
578
- "support-markdown": string;
579
- "login-with-github": string;
580
- "first-comment-person": string;
581
- commented: string;
582
- "load-more": string;
583
- counts: string;
584
- "sort-asc": string;
585
- "sort-desc": string;
586
- logout: string;
587
- anonymous: string;
588
- };
589
- };
590
-
591
- declare type Issue = Endpoints["GET /repos/{owner}/{repo}/issues/{issue_number}"]["response"]["data"];
592
-
593
- declare interface IssueCommentsQLResponse {
594
- repository: {
595
- issue: {
596
- comments: {
597
- totalCount: number;
598
- pageInfo: {
599
- hasPreviousPage?: boolean;
600
- hasNextPage?: boolean;
601
- startCursor?: string;
602
- endCursor?: string;
603
- };
604
- nodes: (Pick<Comment_2, "body"> & {
605
- databaseId: Comment_2["id"];
606
- author: {
607
- avatarUrl: Comment_2["user"]["avatar_url"];
608
- login: Comment_2["user"]["login"];
609
- url: Comment_2["user"]["html_url"];
610
- };
611
- bodyHTML: Comment_2["body_html"];
612
- createdAt: Comment_2["created_at"];
613
- resourcePath: Comment_2["html_url"];
614
- reactions: Comment_2["reactionsHeart"];
615
- })[];
616
- };
617
- };
618
- };
619
- }
620
-
621
- declare type Lang = keyof typeof i18nMap;
622
-
623
- export { }