@waline/client 3.13.0 → 3.14.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/dist/full.d.ts ADDED
@@ -0,0 +1,1382 @@
1
+ //#region ../api/dist/index.d.ts
2
+ //#region src/utils.d.ts
3
+ interface BaseAPIOptions {
4
+ /**
5
+ * Waline 服务端地址
6
+ *
7
+ * Waline serverURL
8
+ */
9
+ serverURL: string;
10
+ /**
11
+ * 错误信息所使用的语言
12
+ *
13
+ * Language used in error text
14
+ */
15
+ lang: string;
16
+ }
17
+ interface ErrorStatusResponse {
18
+ /**
19
+ * 错误代码
20
+ *
21
+ * Error number
22
+ */
23
+ errno: number;
24
+ /**
25
+ * 错误消息
26
+ *
27
+ * Error msg
28
+ */
29
+ errmsg: string;
30
+ } //#endregion
31
+ //#region src/articleCounter.d.ts
32
+ interface GetArticleCounterOptions extends BaseAPIOptions {
33
+ /**
34
+ * 待获取计数器的 path
35
+ *
36
+ * Path of counters
37
+ */
38
+ paths: string[];
39
+ /**
40
+ * 待获取计数器的类型
41
+ *
42
+ * Counter type to be fetched
43
+ */
44
+ type: string[];
45
+ /**
46
+ * 取消请求的信号
47
+ *
48
+ * AbortSignal to cancel request
49
+ */
50
+ signal?: AbortSignal;
51
+ }
52
+ interface CounterFields {
53
+ time?: number;
54
+ reaction0?: number;
55
+ reaction1?: number;
56
+ reaction2?: number;
57
+ reaction3?: number;
58
+ reaction4?: number;
59
+ reaction5?: number;
60
+ reaction6?: number;
61
+ reaction7?: number;
62
+ reaction8?: number;
63
+ }
64
+ type GetArticleCounterResponseItem = Record<string, number> & CounterFields;
65
+ type GetArticleCounterResponse = GetArticleCounterResponseItem[];
66
+ declare const getArticleCounter: ({
67
+ serverURL,
68
+ lang,
69
+ paths,
70
+ type,
71
+ signal
72
+ }: GetArticleCounterOptions) => Promise<GetArticleCounterResponse>;
73
+ interface UpdateArticleCounterOptions extends BaseAPIOptions {
74
+ /**
75
+ * 待更新计数器的 path
76
+ *
77
+ * Path of counter to be updated
78
+ */
79
+ path: string;
80
+ /**
81
+ * 待更新计数器的类型
82
+ *
83
+ * Counter type to be updated
84
+ */
85
+ type: string;
86
+ /**
87
+ * 更新操作
88
+ *
89
+ * Update operation
90
+ *
91
+ * @default 'inc'
92
+ */
93
+ action?: 'inc' | 'desc';
94
+ }
95
+ declare const updateArticleCounter: ({
96
+ serverURL,
97
+ lang,
98
+ path,
99
+ type,
100
+ action
101
+ }: UpdateArticleCounterOptions) => Promise<GetArticleCounterResponse>; //#endregion
102
+ //#region src/typings.d.ts
103
+ type WalineCommentStatus = 'approved' | 'waiting' | 'spam';
104
+ type WalineUserType = 'administrator' | 'guest';
105
+ interface WalineCommentData {
106
+ /** User Nickname */
107
+ nick: string;
108
+ /** User email */
109
+ mail?: string;
110
+ /** User link */
111
+ link?: string;
112
+ /** Content of comment */
113
+ comment: string;
114
+ /** User Agent */
115
+ ua: string;
116
+ /** Comment page path */
117
+ url: string;
118
+ /**
119
+ * Parent comment id
120
+ *
121
+ * Only available when replying comment
122
+ */
123
+ pid?: number;
124
+ /**
125
+ * Root comment id
126
+ *
127
+ * Only available when replying comment
128
+ */
129
+ rid?: number;
130
+ /**
131
+ * User id being at
132
+ *
133
+ * Only available when replying comment
134
+ */
135
+ at?: string;
136
+ /** Recaptcha Token */
137
+ recaptchaV3?: string;
138
+ /** Turnstile Token */
139
+ turnstile?: string;
140
+ }
141
+ interface BaseWalineResponseComment {
142
+ /** Comment object ID */
143
+ objectId: number;
144
+ /** Timestamp of the comment */
145
+ time: number;
146
+ /** Content of comment */
147
+ comment: string;
148
+ /**
149
+ * Original comment content
150
+ *
151
+ * 原始评论内容
152
+ */
153
+ orig: string;
154
+ /**
155
+ * Comment like number
156
+ *
157
+ * 评论喜欢数
158
+ */
159
+ like: number;
160
+ /** User Nickname */
161
+ nick: string;
162
+ /** User link */
163
+ link: string;
164
+ /** User avatar */
165
+ avatar: string;
166
+ /**
167
+ * User type
168
+ *
169
+ * Only available with logged in user 用户类型
170
+ *
171
+ * 仅在登录用户时可用
172
+ */
173
+ type?: WalineUserType;
174
+ /**
175
+ * User ID
176
+ *
177
+ * Only available with logged in user 用户 ID
178
+ *
179
+ * 仅在登录用户时可用
180
+ */
181
+ user_id?: number;
182
+ /**
183
+ * User location
184
+ *
185
+ * Not available with `DISABLE_REGION=true` 用户位置
186
+ *
187
+ * `DISABLE_REGION=true` 时不可用
188
+ */
189
+ addr?: string;
190
+ /**
191
+ * User browser
192
+ *
193
+ * Not available with `DISABLE_USERAGENT=true` 用户浏览器
194
+ *
195
+ * `DISABLE_USERAGENT=true` 时不可用
196
+ */
197
+ browser?: string;
198
+ /**
199
+ * User location
200
+ *
201
+ * Not available with `DISABLE_USERAGENT=true` 用户位置
202
+ *
203
+ * `DISABLE_USERAGENT=true` 时不可用
204
+ */
205
+ os?: string;
206
+ /**
207
+ * User level
208
+ *
209
+ * Only available when `LEVELS` is set 用户等级
210
+ *
211
+ * 仅在 `LEVELS` 设置时可用
212
+ */
213
+ level?: number;
214
+ /**
215
+ * User label
216
+ *
217
+ * 用户标签
218
+ */
219
+ label?: string;
220
+ /**
221
+ * Comment status
222
+ *
223
+ * For administrators, `approved` `spam` `waiting` can be get, for others, the only value is
224
+ * `approved` 评论状态
225
+ *
226
+ * 管理员可获得 `approved`、`spam` 和 `waiting`,其他用户只能获得 `approved`
227
+ */
228
+ status?: WalineCommentStatus;
229
+ }
230
+ interface WalineChildComment extends BaseWalineResponseComment {
231
+ /** Parent comment id */
232
+ pid: number;
233
+ /** Root comment id */
234
+ rid: number;
235
+ /** User id being at */
236
+ at?: string;
237
+ /** Reply user information */
238
+ reply_user?: {
239
+ nick: string;
240
+ link: string;
241
+ avatar: string;
242
+ };
243
+ }
244
+ interface WalineRootComment extends BaseWalineResponseComment {
245
+ /**
246
+ * Whether the comment is sticky
247
+ *
248
+ * 是否置顶
249
+ */
250
+ sticky: boolean;
251
+ /**
252
+ * Child comments
253
+ *
254
+ * 子评论
255
+ */
256
+ children: WalineChildComment[];
257
+ }
258
+ type WalineComment = WalineRootComment | WalineChildComment; //#endregion
259
+ //#region src/comment.d.ts
260
+ interface GetCommentOptions extends BaseAPIOptions {
261
+ /**
262
+ * 待获取评论列表的 path
263
+ *
264
+ * Path of comment list
265
+ */
266
+ path: string;
267
+ /**
268
+ * 评论分页数
269
+ *
270
+ * Comment pagination number
271
+ */
272
+ page: number;
273
+ /**
274
+ * 每页评论个数
275
+ *
276
+ * Comment number per page
277
+ */
278
+ pageSize: number;
279
+ /**
280
+ * 排序方式
281
+ *
282
+ * Sort method
283
+ */
284
+ sortBy: string;
285
+ /**
286
+ * 用户令牌
287
+ *
288
+ * User token
289
+ */
290
+ token?: string;
291
+ /**
292
+ * 取消请求的信号
293
+ *
294
+ * AbortSignal to cancel request
295
+ */
296
+ signal?: AbortSignal;
297
+ }
298
+ interface GetCommentResponse {
299
+ /**
300
+ * 评论数量
301
+ *
302
+ * Comment number
303
+ */
304
+ count: number;
305
+ /**
306
+ * 评论分页数
307
+ *
308
+ * Comment pagination number
309
+ */
310
+ page: number;
311
+ /**
312
+ * 每页评论个数
313
+ *
314
+ * Comment number per page
315
+ */
316
+ pageSize: number;
317
+ /**
318
+ * 评论数据
319
+ *
320
+ * Comment Data
321
+ */
322
+ data: WalineRootComment[];
323
+ /**
324
+ * 页面总数
325
+ *
326
+ * Page number
327
+ */
328
+ totalPages: number;
329
+ }
330
+ declare const getComment: ({
331
+ serverURL,
332
+ lang,
333
+ path,
334
+ page,
335
+ pageSize,
336
+ sortBy,
337
+ signal,
338
+ token
339
+ }: GetCommentOptions) => Promise<GetCommentResponse>;
340
+ interface AddCommentOptions extends BaseAPIOptions {
341
+ /**
342
+ * 用户令牌
343
+ *
344
+ * User token
345
+ */
346
+ token?: string;
347
+ /**
348
+ * 用户待提交的评论数据
349
+ *
350
+ * Comment data being submitted by user
351
+ */
352
+ comment: WalineCommentData;
353
+ }
354
+ interface AddCommentResponse extends ErrorStatusResponse {
355
+ /**
356
+ * 渲染好的评论数据
357
+ *
358
+ * Comment data rendered
359
+ */
360
+ data?: WalineComment;
361
+ }
362
+ declare const addComment: ({
363
+ serverURL,
364
+ lang,
365
+ token,
366
+ comment
367
+ }: AddCommentOptions) => Promise<AddCommentResponse>;
368
+ interface DeleteCommentOptions extends BaseAPIOptions {
369
+ /**
370
+ * Auth token
371
+ *
372
+ * 认证令牌
373
+ */
374
+ token: string;
375
+ /**
376
+ * Comment objectId to be deleted
377
+ *
378
+ * 待删除的评论对象 ID
379
+ */
380
+ objectId: number;
381
+ }
382
+ interface DeleteCommentResponse extends ErrorStatusResponse {
383
+ data: '';
384
+ }
385
+ declare const deleteComment: ({
386
+ serverURL,
387
+ lang,
388
+ token,
389
+ objectId
390
+ }: DeleteCommentOptions) => Promise<DeleteCommentResponse>;
391
+ interface UpdateWalineCommentData extends Partial<WalineCommentData> {
392
+ /**
393
+ * 点赞还是取消点赞
394
+ *
395
+ * Like or dislike
396
+ */
397
+ like?: boolean;
398
+ /**
399
+ * 评论的状态
400
+ *
401
+ * Comment status
402
+ */
403
+ status?: 'approved' | 'waiting' | 'spam';
404
+ /**
405
+ * 评论指定状态
406
+ *
407
+ * Comment sticky status
408
+ *
409
+ * 0 means not sticky and 1 means sticky
410
+ */
411
+ sticky?: 0 | 1;
412
+ }
413
+ interface UpdateCommentOptions extends BaseAPIOptions {
414
+ /**
415
+ * 用户令牌
416
+ *
417
+ * User token
418
+ */
419
+ token: string;
420
+ /**
421
+ * 评论的 ID
422
+ *
423
+ * Comment ID
424
+ */
425
+ objectId: number;
426
+ /**
427
+ * 评论数据
428
+ *
429
+ * Comment data
430
+ */
431
+ comment?: UpdateWalineCommentData;
432
+ }
433
+ interface UpdateCommentResponse extends ErrorStatusResponse {
434
+ /**
435
+ * 更新后的评论数据
436
+ *
437
+ * Comment data rendered
438
+ */
439
+ data: WalineComment;
440
+ }
441
+ declare const updateComment: ({
442
+ serverURL,
443
+ lang,
444
+ token,
445
+ objectId,
446
+ comment
447
+ }: UpdateCommentOptions) => Promise<UpdateCommentResponse>; //#endregion
448
+ //#region src/commentCount.d.ts
449
+ interface GetCommentCountOptions extends BaseAPIOptions {
450
+ /**
451
+ * 待获取评论数的 path
452
+ *
453
+ * Path of pages to be fetched
454
+ */
455
+ paths: string[];
456
+ /**
457
+ * 取消请求的信号
458
+ *
459
+ * AbortSignal to cancel request
460
+ */
461
+ signal?: AbortSignal;
462
+ }
463
+ declare const fetchCommentCount: ({
464
+ serverURL,
465
+ lang,
466
+ paths,
467
+ signal
468
+ }: GetCommentCountOptions) => Promise<number[]>; //#endregion
469
+ //#region src/login.d.ts
470
+ interface UserInfo {
471
+ /**
472
+ * 显示姓名
473
+ *
474
+ * User name displayed
475
+ */
476
+ display_name: string;
477
+ /**
478
+ * 用户电子邮件地址
479
+ *
480
+ * User email
481
+ */
482
+ email: string;
483
+ /**
484
+ * 用户网站地址
485
+ *
486
+ * User website
487
+ */
488
+ url: string;
489
+ /**
490
+ * 用户令牌
491
+ *
492
+ * User token
493
+ */
494
+ token: string;
495
+ /**
496
+ * 用户头像
497
+ *
498
+ * User avatar
499
+ */
500
+ avatar: string;
501
+ /**
502
+ * 用户对象 ID
503
+ *
504
+ * User object ID
505
+ */
506
+ objectId: number;
507
+ /**
508
+ * 用户身份
509
+ *
510
+ * User role
511
+ */
512
+ type: 'administrator' | 'guest';
513
+ }
514
+ declare const login: ({
515
+ lang,
516
+ serverURL
517
+ }: BaseAPIOptions) => Promise<UserInfo & {
518
+ remember: boolean;
519
+ }>; //#endregion
520
+ //#region src/pageview.d.ts
521
+ interface GetPageviewOptions extends BaseAPIOptions {
522
+ /**
523
+ * 待获取页面的 path
524
+ *
525
+ * Path of pages
526
+ */
527
+ paths: string[];
528
+ /**
529
+ * 取消请求的信号
530
+ *
531
+ * AbortSignal to cancel request
532
+ */
533
+ signal?: AbortSignal;
534
+ }
535
+ declare const getPageview: ({
536
+ serverURL,
537
+ lang,
538
+ paths,
539
+ signal
540
+ }: GetPageviewOptions) => Promise<GetArticleCounterResponse>;
541
+ interface UpdatePageviewOptions extends BaseAPIOptions {
542
+ /**
543
+ * 待更新页面的 path
544
+ *
545
+ * Path of pages
546
+ */
547
+ path: string;
548
+ }
549
+ declare const updatePageview: (options: UpdatePageviewOptions) => Promise<GetArticleCounterResponse>; //#endregion
550
+ //#region src/recentComment.d.ts
551
+ interface GetRecentCommentOptions extends BaseAPIOptions {
552
+ /**
553
+ * 获取评论的数量
554
+ *
555
+ * Comment number to be fetched
556
+ */
557
+ count: number;
558
+ /**
559
+ * 取消请求的信号
560
+ *
561
+ * AbortSignal to cancel request
562
+ */
563
+ signal?: AbortSignal;
564
+ /**
565
+ * 用户令牌
566
+ *
567
+ * User token
568
+ */
569
+ token?: string;
570
+ }
571
+ interface RecentCommentData extends BaseWalineResponseComment {
572
+ /**
573
+ * Page url where comment locales
574
+ *
575
+ * 评论所在页面地址
576
+ */
577
+ url: string;
578
+ }
579
+ declare const getRecentComment: ({
580
+ serverURL,
581
+ lang,
582
+ count,
583
+ signal,
584
+ token
585
+ }: GetRecentCommentOptions) => Promise<RecentCommentData[]>; //#endregion
586
+ //#region src/user.d.ts
587
+ interface GetUserListOptions extends BaseAPIOptions {
588
+ /**
589
+ * 每页个数
590
+ *
591
+ * Number per page
592
+ */
593
+ pageSize: number;
594
+ /**
595
+ * 取消请求的信号
596
+ *
597
+ * AbortSignal to cancel request
598
+ */
599
+ signal?: AbortSignal;
600
+ }
601
+ interface WalineUser extends Pick<WalineComment, 'nick' | 'link' | 'avatar' | 'label' | 'level'> {
602
+ count: number;
603
+ }
604
+ interface GetUserListResponse extends ErrorStatusResponse {
605
+ data: WalineUser[];
606
+ }
607
+ declare const getUserList: ({
608
+ serverURL,
609
+ signal,
610
+ pageSize,
611
+ lang
612
+ }: GetUserListOptions) => Promise<WalineUser[]>; //#endregion
613
+ //#endregion
614
+ //#region src/typings/base.d.ts
615
+ type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
616
+ type WalineEmojiPresets = `//${string}` | `http://${string}` | `https://${string}`;
617
+ interface WalineEmojiInfo {
618
+ /**
619
+ * 选项卡上的 Emoji 名称
620
+ *
621
+ * Emoji name show on tab
622
+ */
623
+ name: string;
624
+ /**
625
+ * 所在文件夹链接
626
+ *
627
+ * Current folder link
628
+ */
629
+ folder?: string;
630
+ /**
631
+ * Emoji 通用路径前缀
632
+ *
633
+ * Common prefix of Emoji icons
634
+ */
635
+ prefix?: string;
636
+ /**
637
+ * Emoji 图片的类型,会作为文件扩展名使用
638
+ *
639
+ * Type of Emoji icons, will be regarded as file extension
640
+ */
641
+ type?: string;
642
+ /**
643
+ * 选项卡显示的 Emoji 图标
644
+ *
645
+ * Emoji icon show on tab
646
+ */
647
+ icon: string;
648
+ /**
649
+ * Emoji 图片列表
650
+ *
651
+ * Emoji image list
652
+ */
653
+ items: string[];
654
+ }
655
+ type WalineEmojiMaps = Record<string, string>;
656
+ type WalineLoginStatus = 'enable' | 'disable' | 'force';
657
+ interface WalineSearchImageData extends Record<string, unknown> {
658
+ /**
659
+ * 图片链接
660
+ *
661
+ * Image link
662
+ */
663
+ src: string;
664
+ /**
665
+ * 图片标题
666
+ *
667
+ * 用于图片的 alt 属性
668
+ *
669
+ * Image title
670
+ *
671
+ * Used for alt attribute of image
672
+ */
673
+ title?: string;
674
+ /**
675
+ * 图片缩略图
676
+ *
677
+ * 为了更好的加载性能,我们会优先在列表中使用此缩略图
678
+ *
679
+ * Image preview link
680
+ *
681
+ * For better loading performance, we will use this thumbnail first in the list
682
+ *
683
+ * @default src
684
+ */
685
+ preview?: string;
686
+ }
687
+ type WalineSearchResult = WalineSearchImageData[];
688
+ interface WalineSearchOptions {
689
+ /**
690
+ * 搜索操作
691
+ *
692
+ * Search action
693
+ */
694
+ search: (word: string) => Promise<WalineSearchResult>;
695
+ /**
696
+ * 打开列表时展示的默认结果
697
+ *
698
+ * Default result when opening list
699
+ *
700
+ * @default () => search('')
701
+ */
702
+ default?: () => Promise<WalineSearchResult>;
703
+ /**
704
+ * 获取更多的操作
705
+ *
706
+ * 会在列表滚动到底部时触发,如果你的搜索服务支持分页功能,你应该设置此项实现无限滚动
707
+ *
708
+ * Fetch more action
709
+ *
710
+ * It will be triggered when the list scrolls to the bottom. If your search service supports
711
+ * paging, you should set this to achieve infinite scrolling
712
+ *
713
+ * @default (word) => search(word)
714
+ */
715
+ more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
716
+ }
717
+ type WalineMeta = 'nick' | 'mail' | 'link';
718
+ type WalineImageUploader = (image: File) => Promise<string>;
719
+ type WalineHighlighter = (code: string, lang: string) => string;
720
+ type WalineTeXRenderer = (blockMode: boolean, tex: string) => string;
721
+ //#endregion
722
+ //#region src/typings/locale.d.ts
723
+ interface WalineDateLocale {
724
+ seconds: string;
725
+ minutes: string;
726
+ hours: string;
727
+ days: string;
728
+ now: string;
729
+ }
730
+ type WalineLevelLocale = Record<`level${number}`, string>;
731
+ interface WalineReactionLocale {
732
+ reactionTitle: string;
733
+ reaction0: string;
734
+ reaction1: string;
735
+ reaction2: string;
736
+ reaction3: string;
737
+ reaction4: string;
738
+ reaction5: string;
739
+ reaction6: string;
740
+ reaction7: string;
741
+ reaction8: string;
742
+ }
743
+ interface WalineLocale extends WalineDateLocale, WalineLevelLocale, WalineReactionLocale {
744
+ nick: string;
745
+ mail: string;
746
+ link: string;
747
+ optional: string;
748
+ placeholder: string;
749
+ sofa: string;
750
+ submit: string;
751
+ comment: string;
752
+ refresh: string;
753
+ more: string;
754
+ uploading: string;
755
+ login: string;
756
+ admin: string;
757
+ sticky: string;
758
+ word: string;
759
+ anonymous: string;
760
+ gif: string;
761
+ gifSearchPlaceholder: string; // manage
762
+ approved: string;
763
+ waiting: string;
764
+ spam: string;
765
+ unsticky: string; // sorting
766
+ oldest: string;
767
+ latest: string;
768
+ hottest: string; // hint
769
+ nickError: string;
770
+ mailError: string;
771
+ wordHint: string; // i18n
772
+ like: string;
773
+ cancelLike: string;
774
+ reply: string;
775
+ cancelReply: string;
776
+ preview: string;
777
+ emoji: string;
778
+ uploadImage: string;
779
+ profile: string;
780
+ logout: string;
781
+ commentUnderReview: string;
782
+ subPostComment: string;
783
+ subSiteComment: string;
784
+ subscribeToReplies: string;
785
+ }
786
+ //#endregion
787
+ //#region src/typings/waline.d.ts
788
+ interface WalineProps {
789
+ /**
790
+ * Waline 的服务端地址
791
+ *
792
+ * Waline server address url
793
+ */
794
+ serverURL: string;
795
+ /**
796
+ * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
797
+ *
798
+ * 你可以将其设置为 `window.location.pathname`
799
+ *
800
+ * Article path id. Used to distinguish different _article pages_ to ensure loading the correct
801
+ * comment list under the _article page_.
802
+ *
803
+ * You can set it to `window.location.pathname`
804
+ */
805
+ path: string;
806
+ /**
807
+ * 评论者相关属性
808
+ *
809
+ * `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
810
+ *
811
+ * Reviewer attributes.
812
+ *
813
+ * Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
814
+ *
815
+ * @default ['nick', 'mail', 'link']
816
+ */
817
+ meta?: WalineMeta[];
818
+ /**
819
+ * 设置**必填项**,默认昵称为匿名
820
+ *
821
+ * Set required fields, default anonymous with nickname
822
+ *
823
+ * @default [ ]
824
+ */
825
+ requiredMeta?: WalineMeta[];
826
+ /**
827
+ * 评论字数限制。填入单个数字时为最大字数限制
828
+ *
829
+ * 设置为 `0` 时无限制
830
+ *
831
+ * Comment word s limit. When a single number is filled in, it 's the maximum number of comment
832
+ * words.
833
+ *
834
+ * No limit when set to `0`.
835
+ *
836
+ * @default 0
837
+ */
838
+ wordLimit?: number | [number, number];
839
+ /**
840
+ * 评论列表分页,每页条数
841
+ *
842
+ * Number of pages per page
843
+ *
844
+ * @default 10
845
+ */
846
+ pageSize?: number;
847
+ /**
848
+ * Waline 显示语言
849
+ *
850
+ * 可选值:
851
+ *
852
+ * - `'zh'`
853
+ * - `'zh-cn'`
854
+ * - `'zh-CN'`
855
+ * - `'zh-tw'`
856
+ * - `'zh-TW'`
857
+ * - `'en'`
858
+ * - `'en-US'`
859
+ * - `'en-us'`
860
+ * - `'jp'`
861
+ * - `'jp-jp'`
862
+ * - `'jp-JP'`
863
+ * - `'pt-br'`
864
+ * - `'pt-BR'`
865
+ * - `'ru'`
866
+ * - `'ru-ru'`
867
+ * - `'ru-RU'`
868
+ * - `'fr-FR'`
869
+ * - `'fr'`
870
+ *
871
+ * Display language for waline
872
+ *
873
+ * Optional value:
874
+ *
875
+ * - `'zh'`
876
+ * - `'zh-cn'`
877
+ * - `'zh-CN'`
878
+ * - `'zh-tw'`
879
+ * - `'zh-TW'`
880
+ * - `'en'`
881
+ * - `'en-US'`
882
+ * - `'en-us'`
883
+ * - `'jp'`
884
+ * - `'jp-jp'`
885
+ * - `'jp-JP'`
886
+ * - `'pt-br'`
887
+ * - `'pt-BR'`
888
+ * - `'ru'`
889
+ * - `'ru-ru'`
890
+ * - `'ru-RU'`
891
+ * - `'fr-FR'`
892
+ * - `'fr'`
893
+ *
894
+ * @default navigator.language
895
+ */
896
+ lang?: string;
897
+ /**
898
+ * 自定义 waline 语言显示
899
+ *
900
+ * @see [自定义语言](https://waline.js.org/client/i18n.html)
901
+ *
902
+ * Custom display language in waline
903
+ * @see [I18n](https://waline.js.org/en/client/i18n.html)
904
+ */
905
+ locale?: Partial<WalineLocale>;
906
+ /**
907
+ * 评论列表排序方式
908
+ *
909
+ * Sorting method for comment list
910
+ *
911
+ * @default 'latest'
912
+ */
913
+ commentSorting?: WalineCommentSorting;
914
+ /**
915
+ * 是否启用暗黑模式适配
916
+ *
917
+ * 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
918
+ *
919
+ * Whether to enable darkmode support
920
+ *
921
+ * Setting `'auto'` will display darkmode due to device settings. Filling in CSS selector will
922
+ * enable darkmode only when the selector match waline ancestor nodes.
923
+ */
924
+ dark?: string | boolean;
925
+ /**
926
+ * 登录模式状态,可选值:
927
+ *
928
+ * - `'enable'`: 启用登录 (默认)
929
+ * - `'disable'`: 禁用登录,用户只能填写信息评论
930
+ * - `'force'`: 强制登录,用户必须注册并登录才可发布评论
931
+ *
932
+ * Login mode status, optional values:
933
+ *
934
+ * - `'enable'`: enable login (default)
935
+ * - `'disable'`: Login is disabled, users should fill in information to comment
936
+ * - `'force'`: Forced login, users must login to comment
937
+ *
938
+ * @default 'enable'
939
+ */
940
+ login?: WalineLoginStatus;
941
+ /**
942
+ * 是否在页脚隐藏版权信息
943
+ *
944
+ * 为了支持 Waline,我们强烈建议你开启它
945
+ *
946
+ * Whether hide copyright in footer
947
+ *
948
+ * We strongly recommended you to keep it on to support waline
949
+ */
950
+ noCopyright?: boolean;
951
+ /**
952
+ * 是否隐藏 RSS 订阅入口
953
+ *
954
+ * Whether to hide RSS subscription links
955
+ *
956
+ * @default false
957
+ */
958
+ noRss?: boolean;
959
+ /**
960
+ * Recaptcha v3 客户端 key
961
+ *
962
+ * Recaptcha v3 client key
963
+ */
964
+ recaptchaV3Key?: string;
965
+ /**
966
+ * Turnstile 客户端 key
967
+ *
968
+ * Turnstile client key
969
+ */
970
+ turnstileKey?: string;
971
+ /**
972
+ * 文章反应
973
+ *
974
+ * Article reaction
975
+ *
976
+ * @default false
977
+ */
978
+ reaction?: string[] | boolean;
979
+ /**
980
+ * 设置表情包
981
+ *
982
+ * Set Emojis
983
+ *
984
+ * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
985
+ */
986
+ emoji?: (WalineEmojiInfo | WalineEmojiPresets)[];
987
+ /**
988
+ * 设置搜索功能
989
+ *
990
+ * Customize Search feature
991
+ */
992
+ search?: WalineSearchOptions | boolean;
993
+ /**
994
+ * 代码块高亮器
995
+ *
996
+ * Code fence highlighter
997
+ */
998
+ highlighter?: WalineHighlighter;
999
+ /**
1000
+ * 自定义图片上传方法,方便更好的存储图片
1001
+ *
1002
+ * 方法执行时会将图片对象传入。
1003
+ *
1004
+ * Custom image upload callback to manage picture by yourself.
1005
+ *
1006
+ * We will pass a picture file object when execute it.
1007
+ */
1008
+ imageUploader?: WalineImageUploader;
1009
+ /**
1010
+ * 自定义数学公式处理方法,用于预览。
1011
+ *
1012
+ * Custom math formula parse callback for preview.
1013
+ */
1014
+ texRenderer?: WalineTeXRenderer;
1015
+ }
1016
+ //#endregion
1017
+ //#region src/typings/options.d.ts
1018
+ interface WalineInitOptions extends Omit<WalineProps, 'path' | 'emoji' | 'search' | 'highlighter' | 'imageUploader' | 'texRenderer'> {
1019
+ /**
1020
+ * Waline 的初始化挂载器。必须是一个**有效的** CSS 选择器 或 HTML 元素
1021
+ *
1022
+ * The DOM element to be mounted on initialization. It must be a **valid** CSS selector string or
1023
+ * HTML Element.
1024
+ */
1025
+ el?: string | HTMLElement | null;
1026
+ /**
1027
+ * 评论数统计
1028
+ *
1029
+ * Comment number support
1030
+ *
1031
+ * @default true
1032
+ */
1033
+ comment?: string | boolean;
1034
+ /**
1035
+ * 页面访问量统计
1036
+ *
1037
+ * Pageview number support
1038
+ *
1039
+ * @default true
1040
+ */
1041
+ pageview?: string | boolean;
1042
+ /**
1043
+ * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
1044
+ *
1045
+ * 你可以将其设置为 `window.location.pathname`
1046
+ *
1047
+ * Article path id. Used to distinguish different _article pages_ to ensure loading the correct
1048
+ * comment list under the _article page_.
1049
+ *
1050
+ * You can set it to `window.location.pathname`
1051
+ *
1052
+ * @default window.location.pathname
1053
+ */
1054
+ path?: string;
1055
+ /**
1056
+ * 设置表情包
1057
+ *
1058
+ * Set Emojis
1059
+ *
1060
+ * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
1061
+ */
1062
+ emoji?: (WalineEmojiInfo | WalineEmojiPresets)[] | boolean;
1063
+ /**
1064
+ * 设置搜索功能
1065
+ *
1066
+ * Customize Search feature
1067
+ *
1068
+ * @default true
1069
+ */
1070
+ search?: WalineSearchOptions | boolean;
1071
+ /**
1072
+ * 代码高亮
1073
+ *
1074
+ * Code highlighting
1075
+ *
1076
+ * @default true
1077
+ */
1078
+ highlighter?: WalineHighlighter | boolean;
1079
+ /**
1080
+ * 自定义图片上传方法,方便更好的存储图片
1081
+ *
1082
+ * 方法执行时会将图片对象传入。
1083
+ *
1084
+ * Custom image upload callback to manage picture by yourself.
1085
+ *
1086
+ * We will pass a picture file object when execute it.
1087
+ *
1088
+ * @default true
1089
+ */
1090
+ imageUploader?: WalineImageUploader | boolean;
1091
+ /**
1092
+ * 自定义数学公式处理方法,用于预览。
1093
+ *
1094
+ * Custom math formula parse callback for preview.
1095
+ *
1096
+ * @default true
1097
+ */
1098
+ texRenderer?: WalineTeXRenderer | boolean;
1099
+ }
1100
+ // oxlint-disable-next-line typescript/explicit-module-boundary-types, typescript/no-explicit-any
1101
+ type WalineAbort = (reason?: any) => void;
1102
+ //#endregion
1103
+ //#region src/config/i18n/index.d.ts
1104
+ type Locales = Record<string, WalineLocale>;
1105
+ declare const DEFAULT_LOCALES: Locales;
1106
+ //#endregion
1107
+ //#region src/comment.d.ts
1108
+ interface WalineCommentCountOptions {
1109
+ /**
1110
+ * Waline 服务端地址
1111
+ *
1112
+ * Waline server url
1113
+ */
1114
+ serverURL: string;
1115
+ /**
1116
+ * 评论数 CSS 选择器
1117
+ *
1118
+ * Comment count CSS selector
1119
+ *
1120
+ * @default '.waline-comment-count'
1121
+ */
1122
+ selector?: string;
1123
+ /**
1124
+ * 需要获取的默认路径
1125
+ *
1126
+ * Path to be fetched by default
1127
+ *
1128
+ * @default window.location.pathname
1129
+ */
1130
+ path?: string;
1131
+ /**
1132
+ * 错误提示消息所使用的语言
1133
+ *
1134
+ * Language of error message
1135
+ *
1136
+ * @default navigator.language
1137
+ */
1138
+ lang?: string;
1139
+ }
1140
+ declare const commentCount: ({
1141
+ serverURL,
1142
+ path,
1143
+ selector,
1144
+ lang
1145
+ }: WalineCommentCountOptions) => WalineAbort;
1146
+ //#endregion
1147
+ //#region src/init.d.ts
1148
+ interface WalineInstance {
1149
+ /**
1150
+ * Waline 被挂载到的元素
1151
+ *
1152
+ * 当通过 `el: null` 初始化,值为 `null` Element where Waline is mounted
1153
+ *
1154
+ * When initialized with `el: null`, it will be `null`
1155
+ */
1156
+ el: HTMLElement | null;
1157
+ /**
1158
+ * 更新 Waline 实例
1159
+ *
1160
+ * 只要不设置`path` 选项,更新时它就会被重置为 `windows.location.pathname` Update Waline instance
1161
+ *
1162
+ * When not setting `path` option, it will be reset to `window.location.pathname`
1163
+ */
1164
+ update: (newOptions?: Partial<Omit<WalineInitOptions, 'el'>>) => void;
1165
+ /**
1166
+ * 取消挂载并摧毁 Waline 实例
1167
+ *
1168
+ * Unmount and destroy Waline instance
1169
+ */
1170
+ destroy: () => void;
1171
+ }
1172
+ declare const init: ({
1173
+ el,
1174
+ path,
1175
+ comment,
1176
+ pageview,
1177
+ ...initProps
1178
+ }: WalineInitOptions) => WalineInstance | null;
1179
+ //#endregion
1180
+ //#region src/pageview.d.ts
1181
+ interface WalinePageviewCountOptions {
1182
+ /**
1183
+ * Waline 服务端地址
1184
+ *
1185
+ * Waline server url
1186
+ */
1187
+ serverURL: string;
1188
+ /**
1189
+ * 浏览量 CSS 选择器
1190
+ *
1191
+ * Pageview CSS selector
1192
+ *
1193
+ * @default '.waline-pageview-count'
1194
+ */
1195
+ selector?: string;
1196
+ /**
1197
+ * 需要更新和获取的路径
1198
+ *
1199
+ * Path to be fetched and updated
1200
+ *
1201
+ * @default window.location.pathname
1202
+ */
1203
+ path?: string;
1204
+ /**
1205
+ * 是否在查询时更新 path 的浏览量
1206
+ *
1207
+ * Whether update pageviews when fetching path result
1208
+ *
1209
+ * @default true
1210
+ */
1211
+ update?: boolean;
1212
+ /**
1213
+ * 错误提示消息所使用的语言
1214
+ *
1215
+ * Language of error message
1216
+ *
1217
+ * @default navigator.language
1218
+ */
1219
+ lang?: string;
1220
+ }
1221
+ declare const pageviewCount: ({
1222
+ serverURL,
1223
+ path,
1224
+ selector,
1225
+ update,
1226
+ lang
1227
+ }: WalinePageviewCountOptions) => WalineAbort;
1228
+ //#endregion
1229
+ //#region src/version.d.ts
1230
+ declare const version: string;
1231
+ //#endregion
1232
+ //#region src/widgets/recentComments.d.ts
1233
+ interface WalineRecentCommentsOptions {
1234
+ /**
1235
+ * Waline 服务端地址
1236
+ *
1237
+ * Waline serverURL
1238
+ */
1239
+ serverURL: string;
1240
+ /**
1241
+ * 获取最新评论的数量
1242
+ *
1243
+ * Fetch number of latest comments
1244
+ */
1245
+ count: number;
1246
+ /**
1247
+ * 需要挂载的元素
1248
+ *
1249
+ * Element to be mounted
1250
+ */
1251
+ el?: string | HTMLElement;
1252
+ /**
1253
+ * 错误提示消息所使用的语言
1254
+ *
1255
+ * Language of error message
1256
+ *
1257
+ * @default navigator.language
1258
+ */
1259
+ lang?: string;
1260
+ }
1261
+ interface WalineRecentCommentsResult {
1262
+ /**
1263
+ * 评论数据
1264
+ *
1265
+ * Comment Data
1266
+ */
1267
+ comments: RecentCommentData[];
1268
+ /**
1269
+ * 取消挂载挂件
1270
+ *
1271
+ * Umount widget
1272
+ */
1273
+ destroy: () => void;
1274
+ }
1275
+ declare const RecentComments: ({
1276
+ el,
1277
+ serverURL,
1278
+ count,
1279
+ lang
1280
+ }: WalineRecentCommentsOptions) => Promise<WalineRecentCommentsResult>;
1281
+ //#endregion
1282
+ //#region src/widgets/userList.d.ts
1283
+ interface WalineUserListOptions {
1284
+ /**
1285
+ * Waline 服务端地址
1286
+ *
1287
+ * Waline serverURL
1288
+ */
1289
+ serverURL: string;
1290
+ /**
1291
+ * 获取用户列表的数量
1292
+ *
1293
+ * Fetch number of user list
1294
+ */
1295
+ count: number;
1296
+ /**
1297
+ * 需要挂载的元素
1298
+ *
1299
+ * Element to be mounted
1300
+ */
1301
+ el?: string | HTMLElement;
1302
+ /**
1303
+ * 错误提示消息所使用的语言
1304
+ *
1305
+ * Language of error message
1306
+ *
1307
+ * @default navigator.language
1308
+ */
1309
+ lang?: string;
1310
+ /**
1311
+ * 自定义 waline 语言显示
1312
+ *
1313
+ * @see [自定义语言](https://waline.js.org/client/i18n.html)
1314
+ *
1315
+ * Custom display language in waline
1316
+ * @see [I18n](https://waline.js.org/en/client/i18n.html)
1317
+ */
1318
+ locale?: WalineLocale;
1319
+ /**
1320
+ * 列表模式还是头像墙模式
1321
+ *
1322
+ * List mode or avatar wall mode
1323
+ *
1324
+ * @default 'list'
1325
+ */
1326
+ mode?: 'list' | 'wall';
1327
+ }
1328
+ interface WalineUserListResult {
1329
+ /**
1330
+ * 用户数据
1331
+ *
1332
+ * User Data
1333
+ */
1334
+ users: WalineUser[];
1335
+ /**
1336
+ * 取消挂载挂件
1337
+ *
1338
+ * Umount widget
1339
+ */
1340
+ destroy: () => void;
1341
+ }
1342
+ declare const UserList: ({
1343
+ el,
1344
+ serverURL,
1345
+ count,
1346
+ locale,
1347
+ lang,
1348
+ mode
1349
+ }: WalineUserListOptions) => Promise<WalineUserListResult>;
1350
+ //#endregion
1351
+ //#region src/widgets/star/index.d.ts
1352
+ /** Options for the star rating widget. */
1353
+ interface WalineStarOptions {
1354
+ /** Element or CSS selector on which to mount the widget. */
1355
+ el?: string | HTMLElement;
1356
+ /** Path identifying the current page or article. */
1357
+ path: string;
1358
+ /** Language code used by the widget, such as `en` or `zh-CN`. */
1359
+ lang?: string;
1360
+ /** Waline server URL. */
1361
+ serverURL: string;
1362
+ /**
1363
+ * Callback invoked after the user submits a rating.
1364
+ *
1365
+ * @param score The score selected by the user.
1366
+ */
1367
+ onRate?: (score: number) => void;
1368
+ }
1369
+ /** Star widget result. */
1370
+ interface WalineStarResult {
1371
+ /** Destroy star widget instance. */
1372
+ destroy: () => void;
1373
+ }
1374
+ declare const Star: ({
1375
+ el,
1376
+ path,
1377
+ lang,
1378
+ serverURL,
1379
+ onRate
1380
+ }: WalineStarOptions) => WalineStarResult;
1381
+ //#endregion
1382
+ export { AddCommentOptions, AddCommentResponse, BaseWalineResponseComment, CounterFields, DeleteCommentOptions, DeleteCommentResponse, GetArticleCounterOptions, GetArticleCounterResponse, GetArticleCounterResponseItem, GetCommentCountOptions, GetCommentOptions, GetCommentResponse, GetRecentCommentOptions, GetUserListOptions, GetUserListResponse, RecentCommentData, RecentComments, Star, UpdateArticleCounterOptions, UpdateCommentOptions, UpdateCommentResponse, UpdatePageviewOptions, UserInfo, UserList, WalineAbort, WalineChildComment, WalineComment, WalineCommentCountOptions, WalineCommentData, WalineCommentSorting, WalineCommentStatus, WalineDateLocale, WalineEmojiInfo, WalineEmojiMaps, WalineEmojiPresets, WalineHighlighter, WalineImageUploader, WalineInitOptions, WalineInstance, WalineLevelLocale, WalineLocale, WalineLoginStatus, WalineMeta, WalinePageviewCountOptions, WalineProps, WalineReactionLocale, WalineRecentCommentsOptions, WalineRecentCommentsResult, WalineRootComment, WalineSearchImageData, WalineSearchOptions, WalineSearchResult, WalineStarOptions, WalineStarResult, WalineTeXRenderer, WalineUser, WalineUserListOptions, WalineUserListResult, WalineUserType, addComment, commentCount, DEFAULT_LOCALES as defaultLocales, deleteComment, fetchCommentCount, getArticleCounter, getComment, getPageview, getRecentComment, getUserList, init, login, pageviewCount, updateArticleCounter, updateComment, updatePageview, version };