@waline/client 3.12.2 → 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/waline.d.ts DELETED
@@ -1,741 +0,0 @@
1
- import { RecentCommentData, WalineUser } from '@waline/api';
2
- export * from '@waline/api';
3
-
4
- type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
5
- type WalineEmojiPresets = `//${string}` | `http://${string}` | `https://${string}`;
6
- interface WalineEmojiInfo {
7
- /**
8
- * 选项卡上的 Emoji 名称
9
- *
10
- * Emoji name show on tab
11
- */
12
- name: string;
13
- /**
14
- * 所在文件夹链接
15
- *
16
- * Current folder link
17
- */
18
- folder?: string;
19
- /**
20
- * Emoji 通用路径前缀
21
- *
22
- * Common prefix of Emoji icons
23
- */
24
- prefix?: string;
25
- /**
26
- * Emoji 图片的类型,会作为文件扩展名使用
27
- *
28
- * Type of Emoji icons, will be regarded as file extension
29
- */
30
- type?: string;
31
- /**
32
- * 选项卡显示的 Emoji 图标
33
- *
34
- * Emoji icon show on tab
35
- */
36
- icon: string;
37
- /**
38
- * Emoji 图片列表
39
- *
40
- * Emoji image list
41
- */
42
- items: string[];
43
- }
44
- type WalineEmojiMaps = Record<string, string>;
45
- type WalineLoginStatus = 'enable' | 'disable' | 'force';
46
- interface WalineSearchImageData extends Record<string, unknown> {
47
- /**
48
- * 图片链接
49
- *
50
- * Image link
51
- */
52
- src: string;
53
- /**
54
- * 图片标题
55
- *
56
- * @description 用于图片的 alt 属性
57
- *
58
- * Image title
59
- *
60
- * @description Used for alt attribute of image
61
- */
62
- title?: string;
63
- /**
64
- * 图片缩略图
65
- *
66
- * @description 为了更好的加载性能,我们会优先在列表中使用此缩略图
67
- *
68
- * Image preview link
69
- *
70
- * @description For better loading performance, we will use this thumbnail first in the list
71
- *
72
- * @default src
73
- */
74
- preview?: string;
75
- }
76
- type WalineSearchResult = WalineSearchImageData[];
77
- interface WalineSearchOptions {
78
- /**
79
- * 搜索操作
80
- *
81
- * Search action
82
- */
83
- search: (word: string) => Promise<WalineSearchResult>;
84
- /**
85
- * 打开列表时展示的默认结果
86
- *
87
- * Default result when opening list
88
- *
89
- * @default () => search('')
90
- */
91
- default?: () => Promise<WalineSearchResult>;
92
- /**
93
- * 获取更多的操作
94
- *
95
- * @description 会在列表滚动到底部时触发,如果你的搜索服务支持分页功能,你应该设置此项实现无限滚动
96
- *
97
- * Fetch more action
98
- *
99
- * @description It will be triggered when the list scrolls to the bottom. If your search service supports paging, you should set this to achieve infinite scrolling
100
- *
101
- * @default (word) => search(word)
102
- */
103
- more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
104
- }
105
- type WalineMeta = 'nick' | 'mail' | 'link';
106
- type WalineImageUploader = (image: File) => Promise<string>;
107
- type WalineHighlighter = (code: string, lang: string) => string;
108
- type WalineTeXRenderer = (blockMode: boolean, tex: string) => string;
109
-
110
- interface WalineDateLocale {
111
- seconds: string;
112
- minutes: string;
113
- hours: string;
114
- days: string;
115
- now: string;
116
- }
117
- type WalineLevelLocale = Record<`level${number}`, string>;
118
- interface WalineReactionLocale {
119
- reactionTitle: string;
120
- reaction0: string;
121
- reaction1: string;
122
- reaction2: string;
123
- reaction3: string;
124
- reaction4: string;
125
- reaction5: string;
126
- reaction6: string;
127
- reaction7: string;
128
- reaction8: string;
129
- }
130
- interface WalineLocale extends WalineDateLocale, WalineLevelLocale, WalineReactionLocale {
131
- nick: string;
132
- mail: string;
133
- link: string;
134
- optional: string;
135
- placeholder: string;
136
- sofa: string;
137
- submit: string;
138
- comment: string;
139
- refresh: string;
140
- more: string;
141
- uploading: string;
142
- login: string;
143
- admin: string;
144
- sticky: string;
145
- word: string;
146
- anonymous: string;
147
- gif: string;
148
- gifSearchPlaceholder: string;
149
- approved: string;
150
- waiting: string;
151
- spam: string;
152
- unsticky: string;
153
- oldest: string;
154
- latest: string;
155
- hottest: string;
156
- nickError: string;
157
- mailError: string;
158
- wordHint: string;
159
- like: string;
160
- cancelLike: string;
161
- reply: string;
162
- cancelReply: string;
163
- preview: string;
164
- emoji: string;
165
- uploadImage: string;
166
- profile: string;
167
- logout: string;
168
- commentUnderReview: string;
169
- subPostComment: string;
170
- subSiteComment: string;
171
- subscribeToReplies: string;
172
- }
173
-
174
- interface WalineProps {
175
- /**
176
- * Waline 的服务端地址
177
- *
178
- * Waline server address url
179
- */
180
- serverURL: string;
181
- /**
182
- * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
183
- *
184
- * 你可以将其设置为 `window.location.pathname`
185
- *
186
- * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
187
- *
188
- * You can set it to `window.location.pathname`
189
- */
190
- path: string;
191
- /**
192
- * 评论者相关属性
193
- *
194
- * `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
195
- *
196
- * Reviewer attributes.
197
- *
198
- * Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
199
- *
200
- * @default ['nick', 'mail', 'link']
201
- */
202
- meta?: WalineMeta[];
203
- /**
204
- * 设置**必填项**,默认昵称为匿名
205
- *
206
- * Set required fields, default anonymous with nickname
207
- *
208
- * @default []
209
- */
210
- requiredMeta?: WalineMeta[];
211
- /**
212
- * 评论字数限制。填入单个数字时为最大字数限制
213
- *
214
- * @description 设置为 `0` 时无限制
215
- *
216
- * Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
217
- *
218
- * @description No limit when set to `0`.
219
- *
220
- * @default 0
221
- */
222
- wordLimit?: number | [number, number];
223
- /**
224
- * 评论列表分页,每页条数
225
- *
226
- * number of pages per page
227
- *
228
- * @default 10
229
- */
230
- pageSize?: number;
231
- /**
232
- * Waline 显示语言
233
- *
234
- * 可选值:
235
- *
236
- * - `'zh'`
237
- * - `'zh-cn'`
238
- * - `'zh-CN'`
239
- * - `'zh-tw'`
240
- * - `'zh-TW'`
241
- * - `'en'`
242
- * - `'en-US'`
243
- * - `'en-us'`
244
- * - `'jp'`
245
- * - `'jp-jp'`
246
- * - `'jp-JP'`
247
- * - `'pt-br'`
248
- * - `'pt-BR'`
249
- * - `'ru'`
250
- * - `'ru-ru'`
251
- * - `'ru-RU'`
252
- * - `'fr-FR'`
253
- * - `'fr'`
254
- *
255
- * Display language for waline
256
- *
257
- * Optional value:
258
- *
259
- * - `'zh'`
260
- * - `'zh-cn'`
261
- * - `'zh-CN'`
262
- * - `'zh-tw'`
263
- * - `'zh-TW'`
264
- * - `'en'`
265
- * - `'en-US'`
266
- * - `'en-us'`
267
- * - `'jp'`
268
- * - `'jp-jp'`
269
- * - `'jp-JP'`
270
- * - `'pt-br'`
271
- * - `'pt-BR'`
272
- * - `'ru'`
273
- * - `'ru-ru'`
274
- * - `'ru-RU'`
275
- * - `'fr-FR'`
276
- * - `'fr'`
277
- *
278
- * @default navigator.language
279
- */
280
- lang?: string;
281
- /**
282
- * 自定义 waline 语言显示
283
- *
284
- * @see [自定义语言](https://waline.js.org/client/i18n.html)
285
- *
286
- * Custom display language in waline
287
- *
288
- * @see [I18n](https://waline.js.org/en/client/i18n.html)
289
- */
290
- locale?: Partial<WalineLocale>;
291
- /**
292
- * 评论列表排序方式
293
- *
294
- * Sorting method for comment list
295
- *
296
- * @default 'latest'
297
- */
298
- commentSorting?: WalineCommentSorting;
299
- /**
300
- * 是否启用暗黑模式适配
301
- *
302
- * @description 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
303
- *
304
- * Whether to enable darkmode support
305
- *
306
- * @description Setting `'auto'` will display darkmode due to device settings. Filling in CSS selector will enable darkmode only when the selector match waline ancestor nodes.
307
- */
308
- dark?: string | boolean;
309
- /**
310
- *
311
- * 登录模式状态,可选值:
312
- *
313
- * - `'enable'`: 启用登录 (默认)
314
- * - `'disable'`: 禁用登录,用户只能填写信息评论
315
- * - `'force'`: 强制登录,用户必须注册并登录才可发布评论
316
- *
317
- * Login mode status, optional values:
318
- *
319
- * - `'enable'`: enable login (default)
320
- * - `'disable'`: Login is disabled, users should fill in information to comment
321
- * - `'force'`: Forced login, users must login to comment
322
- *
323
- * @default 'enable'
324
- */
325
- login?: WalineLoginStatus;
326
- /**
327
- * 是否在页脚隐藏版权信息
328
- *
329
- * 为了支持 Waline,我们强烈建议你开启它
330
- *
331
- * Whether hide copyright in footer
332
- *
333
- * We strongly recommended you to keep it on to support waline
334
- *
335
- */
336
- noCopyright?: boolean;
337
- /**
338
- * 是否隐藏 RSS 订阅入口
339
- *
340
- * Whether to hide RSS subscription links
341
- *
342
- * @default false
343
- */
344
- noRss?: boolean;
345
- /**
346
- * recaptcha v3 客户端 key
347
- *
348
- * recaptcha v3 client key
349
- */
350
- recaptchaV3Key?: string;
351
- /**
352
- * turnstile 客户端 key
353
- *
354
- * turnstile client key
355
- */
356
- turnstileKey?: string;
357
- /**
358
- * 文章反应
359
- *
360
- * Article reaction
361
- *
362
- * @default false
363
- */
364
- reaction?: string[] | boolean;
365
- /**
366
- * 设置表情包
367
- *
368
- * Set Emojis
369
- *
370
- * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
371
- */
372
- emoji?: (WalineEmojiInfo | WalineEmojiPresets)[];
373
- /**
374
- * 设置搜索功能
375
- *
376
- * Customize Search feature
377
- */
378
- search?: WalineSearchOptions;
379
- /**
380
- * 代码块高亮器
381
- *
382
- * Code fence highlighter
383
- */
384
- highlighter?: WalineHighlighter;
385
- /**
386
- * 自定义图片上传方法,方便更好的存储图片
387
- *
388
- * 方法执行时会将图片对象传入。
389
- *
390
- * Custom image upload callback to manage picture by yourself.
391
- *
392
- * We will pass a picture file object when execute it.
393
- */
394
- imageUploader?: WalineImageUploader;
395
- /**
396
- * 自定义数学公式处理方法,用于预览。
397
- *
398
- * Custom math formula parse callback for preview.
399
- */
400
- texRenderer?: WalineTeXRenderer;
401
- }
402
-
403
- interface WalineInitOptions extends Omit<WalineProps, 'path' | 'emoji' | 'search' | 'highlighter' | 'imageUploader' | 'texRenderer'> {
404
- /**
405
- * Waline 的初始化挂载器。必须是一个**有效的** CSS 选择器 或 HTML 元素
406
- *
407
- * The DOM element to be mounted on initialization. It must be a **valid** CSS selector string or HTML Element.
408
- */
409
- el?: string | HTMLElement | null;
410
- /**
411
- * 评论数统计
412
- *
413
- * Comment number support
414
- *
415
- * @default true
416
- */
417
- comment?: string | boolean;
418
- /**
419
- * 页面访问量统计
420
- *
421
- * Pageview number support
422
- *
423
- * @default true
424
- */
425
- pageview?: string | boolean;
426
- /**
427
- * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
428
- *
429
- * 你可以将其设置为 `window.location.pathname`
430
- *
431
- * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
432
- *
433
- * You can set it to `window.location.pathname`
434
- *
435
- * @default window.location.pathname
436
- */
437
- path?: string;
438
- /**
439
- * 设置表情包
440
- *
441
- * Set Emojis
442
- *
443
- * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
444
- */
445
- emoji?: (WalineEmojiInfo | WalineEmojiPresets)[] | boolean;
446
- /**
447
- * 设置搜索功能
448
- *
449
- * Customize Search feature
450
- *
451
- * @default true
452
- */
453
- search?: WalineSearchOptions | boolean;
454
- /**
455
- * 代码高亮
456
- *
457
- * Code highlighting
458
- *
459
- * @default true
460
- */
461
- highlighter?: WalineHighlighter | boolean;
462
- /**
463
- * 自定义图片上传方法,方便更好的存储图片
464
- *
465
- * 方法执行时会将图片对象传入。
466
- *
467
- * Custom image upload callback to manage picture by yourself.
468
- *
469
- * We will pass a picture file object when execute it.
470
- *
471
- * @default true
472
- */
473
- imageUploader?: WalineImageUploader | boolean;
474
- /**
475
- * 自定义数学公式处理方法,用于预览。
476
- *
477
- * Custom math formula parse callback for preview.
478
- *
479
- * @default true
480
- */
481
- texRenderer?: WalineTeXRenderer | boolean;
482
- }
483
- type WalineAbort = (reason?: any) => void;
484
-
485
- type Locales = Record<string, WalineLocale>;
486
- declare const DEFAULT_LOCALES: Locales;
487
-
488
- interface WalineCommentCountOptions {
489
- /**
490
- * Waline 服务端地址
491
- *
492
- * Waline server url
493
- */
494
- serverURL: string;
495
- /**
496
- * 评论数 CSS 选择器
497
- *
498
- * Comment count CSS selector
499
- *
500
- * @default '.waline-comment-count'
501
- */
502
- selector?: string;
503
- /**
504
- * 需要获取的默认路径
505
- *
506
- * Path to be fetched by default
507
- *
508
- * @default window.location.pathname
509
- */
510
- path?: string;
511
- /**
512
- * 错误提示消息所使用的语言
513
- *
514
- * Language of error message
515
- *
516
- * @default navigator.language
517
- */
518
- lang?: string;
519
- }
520
- declare const commentCount: ({ serverURL, path, selector, lang, }: WalineCommentCountOptions) => WalineAbort;
521
-
522
- interface WalineInstance {
523
- /**
524
- * Waline 被挂载到的元素
525
- *
526
- * @description 当通过 `el: null` 初始化,值为 `null`
527
- *
528
- * Element where Waline is mounted
529
- *
530
- * @description when initialized with `el: null`, it will be `null`
531
- */
532
- el: HTMLElement | null;
533
- /**
534
- * 更新 Waline 实例
535
- *
536
- * @description 只要不设置`path` 选项,更新时它就会被重置为 `windows.location.pathname`
537
- *
538
- * Update Waline instance
539
- *
540
- * @description when not setting `path` option, it will be reset to `window.location.pathname`
541
- */
542
- update: (newOptions?: Partial<Omit<WalineInitOptions, 'el'>>) => void;
543
- /**
544
- * 取消挂载并摧毁 Waline 实例
545
- *
546
- * Unmount and destroy Waline instance
547
- */
548
- destroy: () => void;
549
- }
550
- declare const init: ({ el, path, comment, pageview, ...initProps }: WalineInitOptions) => WalineInstance | null;
551
-
552
- interface WalinePageviewCountOptions {
553
- /**
554
- * Waline 服务端地址
555
- *
556
- * Waline server url
557
- */
558
- serverURL: string;
559
- /**
560
- * 浏览量 CSS 选择器
561
- *
562
- * Pageview CSS selector
563
- *
564
- * @default '.waline-pageview-count'
565
- */
566
- selector?: string;
567
- /**
568
- * 需要更新和获取的路径
569
- *
570
- * Path to be fetched and updated
571
- *
572
- * @default window.location.pathname
573
- */
574
- path?: string;
575
- /**
576
- * 是否在查询时更新 path 的浏览量
577
- *
578
- * Whether update pageviews when fetching path result
579
- *
580
- * @default true
581
- */
582
- update?: boolean;
583
- /**
584
- * 错误提示消息所使用的语言
585
- *
586
- * Language of error message
587
- *
588
- * @default navigator.language
589
- */
590
- lang?: string;
591
- }
592
- declare const pageviewCount: ({ serverURL, path, selector, update, lang, }: WalinePageviewCountOptions) => WalineAbort;
593
-
594
- declare const version: string;
595
-
596
- interface WalineRecentCommentsOptions {
597
- /**
598
- * Waline 服务端地址
599
- *
600
- * Waline serverURL
601
- */
602
- serverURL: string;
603
- /**
604
- * 获取最新评论的数量
605
- *
606
- * fetch number of latest comments
607
- */
608
- count: number;
609
- /**
610
- * 需要挂载的元素
611
- *
612
- * Element to be mounted
613
- */
614
- el?: string | HTMLElement;
615
- /**
616
- * 错误提示消息所使用的语言
617
- *
618
- * Language of error message
619
- *
620
- * @default navigator.language
621
- */
622
- lang?: string;
623
- }
624
- interface WalineRecentCommentsResult {
625
- /**
626
- * 评论数据
627
- *
628
- * Comment Data
629
- */
630
- comments: RecentCommentData[];
631
- /**
632
- * 取消挂载挂件
633
- *
634
- * Umount widget
635
- */
636
- destroy: () => void;
637
- }
638
- declare const RecentComments: ({ el, serverURL, count, lang, }: WalineRecentCommentsOptions) => Promise<WalineRecentCommentsResult>;
639
-
640
- interface WalineUserListOptions {
641
- /**
642
- * Waline 服务端地址
643
- *
644
- * Waline serverURL
645
- */
646
- serverURL: string;
647
- /**
648
- * 获取用户列表的数量
649
- *
650
- * fetch number of user list
651
- */
652
- count: number;
653
- /**
654
- * 需要挂载的元素
655
- *
656
- * Element to be mounted
657
- */
658
- el?: string | HTMLElement;
659
- /**
660
- * 错误提示消息所使用的语言
661
- *
662
- * Language of error message
663
- *
664
- * @default navigator.language
665
- */
666
- lang?: string;
667
- /**
668
- * 自定义 waline 语言显示
669
- *
670
- * @see [自定义语言](https://waline.js.org/client/i18n.html)
671
- *
672
- * Custom display language in waline
673
- *
674
- * @see [I18n](https://waline.js.org/en/client/i18n.html)
675
- */
676
- locale?: WalineLocale;
677
- /**
678
- * 列表模式还是头像墙模式
679
- *
680
- * list mode or avatar wall mode
681
- *
682
- * @default 'list'
683
- */
684
- mode?: 'list' | 'wall';
685
- }
686
- interface WalineUserListResult {
687
- /**
688
- * 用户数据
689
- *
690
- * User Data
691
- */
692
- users: WalineUser[];
693
- /**
694
- * 取消挂载挂件
695
- *
696
- * Umount widget
697
- */
698
- destroy: () => void;
699
- }
700
- declare const UserList: ({ el, serverURL, count, locale, lang, mode, }: WalineUserListOptions) => Promise<WalineUserListResult>;
701
-
702
- /**
703
- * Options for the star rating widget.
704
- */
705
- interface WalineStarOptions {
706
- /**
707
- * Element or CSS selector on which to mount the widget.
708
- */
709
- el?: string | HTMLElement;
710
- /**
711
- * Path identifying the current page or article.
712
- */
713
- path: string;
714
- /**
715
- * Language code used by the widget, such as `en` or `zh-CN`.
716
- */
717
- lang?: string;
718
- /**
719
- * Waline server URL.
720
- */
721
- serverURL: string;
722
- /**
723
- * Callback invoked after the user submits a rating.
724
- *
725
- * @param score The score selected by the user.
726
- */
727
- onRate?: (score: number) => void;
728
- }
729
- /**
730
- * Star widget result.
731
- */
732
- interface WalineStarResult {
733
- /**
734
- * Destroy star widget instance.
735
- */
736
- destroy: () => void;
737
- }
738
- declare const Star: ({ el, path, lang, serverURL, onRate, }: WalineStarOptions) => WalineStarResult;
739
-
740
- export { RecentComments, Star, UserList, commentCount, DEFAULT_LOCALES as defaultLocales, init, pageviewCount, version };
741
- export type { WalineAbort, WalineCommentCountOptions, WalineCommentSorting, WalineDateLocale, WalineEmojiInfo, WalineEmojiMaps, WalineEmojiPresets, WalineHighlighter, WalineImageUploader, WalineInitOptions, WalineInstance, WalineLevelLocale, WalineLocale, WalineLoginStatus, WalineMeta, WalinePageviewCountOptions, WalineProps, WalineReactionLocale, WalineRecentCommentsOptions, WalineRecentCommentsResult, WalineSearchImageData, WalineSearchOptions, WalineSearchResult, WalineStarOptions, WalineStarResult, WalineTeXRenderer, WalineUserListOptions, WalineUserListResult };