@waline/client 3.0.0-alpha.2 → 3.0.0-alpha.4

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/shim.d.mts DELETED
@@ -1,643 +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
- }
169
-
170
- interface WalineProps {
171
- /**
172
- * Waline 的服务端地址
173
- *
174
- * Waline server address url
175
- */
176
- serverURL: string;
177
- /**
178
- * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
179
- *
180
- * 你可以将其设置为 `window.location.pathname`
181
- *
182
- * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
183
- *
184
- * You can set it to `window.location.pathname`
185
- */
186
- path: string;
187
- /**
188
- * 评论者相关属性
189
- *
190
- * `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
191
- *
192
- * Reviewer attributes.
193
- *
194
- * Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
195
- *
196
- * @default ['nick', 'mail', 'link']
197
- */
198
- meta?: WalineMeta[];
199
- /**
200
- * 设置**必填项**,默认昵称为匿名
201
- *
202
- * Set required fields, default anonymous with nickname
203
- *
204
- * @default []
205
- */
206
- requiredMeta?: WalineMeta[];
207
- /**
208
- * 评论字数限制。填入单个数字时为最大字数限制
209
- *
210
- * @more 设置为 `0` 时无限制
211
- *
212
- * Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
213
- *
214
- * @more No limit when set to `0`.
215
- *
216
- * @default 0
217
- */
218
- wordLimit?: number | [number, number];
219
- /**
220
- * 评论列表分页,每页条数
221
- *
222
- * number of pages per page
223
- *
224
- * @default 10
225
- */
226
- pageSize?: number;
227
- /**
228
- * Waline 显示语言
229
- *
230
- * 可选值:
231
- *
232
- * - `'zh'`
233
- * - `'zh-cn'`
234
- * - `'zh-CN'`
235
- * - `'zh-tw'`
236
- * - `'zh-TW'`
237
- * - `'en'`
238
- * - `'en-US'`
239
- * - `'en-us'`
240
- * - `'jp'`
241
- * - `'jp-jp'`
242
- * - `'jp-JP'`
243
- * - `'pt-br'`
244
- * - `'pt-BR'`
245
- * - `'ru'`
246
- * - `'ru-ru'`
247
- * - `'ru-RU'`
248
- *
249
- * Display language for waline
250
- *
251
- * Optional value:
252
- *
253
- * - `'zh'`
254
- * - `'zh-cn'`
255
- * - `'zh-CN'`
256
- * - `'zh-tw'`
257
- * - `'zh-TW'`
258
- * - `'en'`
259
- * - `'en-US'`
260
- * - `'en-us'`
261
- * - `'jp'`
262
- * - `'jp-jp'`
263
- * - `'jp-JP'`
264
- * - `'pt-br'`
265
- * - `'pt-BR'`
266
- * - `'ru'`
267
- * - `'ru-ru'`
268
- * - `'ru-RU'`
269
- *
270
- * @default navigator.language
271
- */
272
- lang?: string;
273
- /**
274
- * 自定义 waline 语言显示
275
- *
276
- * @see [自定义语言](https://waline.js.org/client/i18n.html)
277
- *
278
- * Custom display language in waline
279
- *
280
- * @see [I18n](https://waline.js.org/en/client/i18n.html)
281
- */
282
- locale?: Partial<WalineLocale>;
283
- /**
284
- * 评论列表排序方式
285
- *
286
- * Sorting method for comment list
287
- *
288
- * @default 'latest'
289
- */
290
- commentSorting?: WalineCommentSorting;
291
- /**
292
- * 是否启用暗黑模式适配
293
- *
294
- * @more 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
295
- *
296
- * Whether to enable darkmode support
297
- *
298
- * @more Setting `'auto'` will display darkmode due to device settings. Filling in CSS selector will enable darkmode only when the selector match waline ancestor nodes.
299
- */
300
- dark?: string | boolean;
301
- /**
302
- * 设置表情包
303
- *
304
- * Set Emojis
305
- *
306
- * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
307
- */
308
- emoji?: (WalineEmojiInfo | WalineEmojiPresets)[] | boolean;
309
- /**
310
- * 设置搜索功能
311
- *
312
- * Customize Search feature
313
- *
314
- * @default true
315
- */
316
- search?: WalineSearchOptions | boolean;
317
- /**
318
- * 代码高亮
319
- *
320
- * Code highlighting
321
- *
322
- * @default true
323
- */
324
- highlighter?: WalineHighlighter | boolean;
325
- /**
326
- * 自定义图片上传方法,方便更好的存储图片
327
- *
328
- * 方法执行时会将图片对象传入。
329
- *
330
- * Custom image upload callback to manage picture by yourself.
331
- *
332
- * We will pass a picture file object when execute it.
333
- *
334
- * @default true
335
- */
336
- imageUploader?: WalineImageUploader | boolean;
337
- /**
338
- * 自定义数学公式处理方法,用于预览。
339
- *
340
- * Custom math formula parse callback for preview.
341
- *
342
- * @default true
343
- */
344
- texRenderer?: WalineTeXRenderer | boolean;
345
- /**
346
- *
347
- * 登录模式状态,可选值:
348
- *
349
- * - `'enable'`: 启用登录 (默认)
350
- * - `'disable'`: 禁用登录,用户只能填写信息评论
351
- * - `'force'`: 强制登录,用户必须注册并登录才可发布评论
352
- *
353
- * Login mode status, optional values:
354
- *
355
- * - `'enable'`: enable login (default)
356
- * - `'disable'`: Login is disabled, users should fill in information to comment
357
- * - `'force'`: Forced login, users must login to comment
358
- *
359
- * @default 'enable'
360
- */
361
- login?: WalineLoginStatus;
362
- /**
363
- * 是否在页脚展示版权信息
364
- *
365
- * 为了支持 Waline,我们强烈建议你开启它
366
- *
367
- * Whether show copyright in footer
368
- *
369
- * We strongly recommended you to keep it on to support waline
370
- *
371
- * @default true
372
- */
373
- copyright?: boolean;
374
- /**
375
- * recaptcha v3 client key
376
- */
377
- recaptchaV3Key?: string;
378
- /**
379
- * turnstile client key
380
- */
381
- turnstileKey?: string;
382
- /**
383
- * reaction
384
- */
385
- reaction?: string[] | boolean;
386
- }
387
-
388
- interface WalineInitOptions extends Omit<WalineProps, 'path'> {
389
- /**
390
- * Waline 的初始化挂载器。必须是一个**有效的** CSS 选择器 或 HTML 元素
391
- *
392
- * The DOM element to be mounted on initialization. It must be a **valid** CSS selector string or HTML Element.
393
- */
394
- el?: string | HTMLElement | null;
395
- /**
396
- * 评论数统计
397
- *
398
- * Comment number support
399
- *
400
- * @default false
401
- */
402
- comment?: string | boolean;
403
- /**
404
- * 页面访问量统计
405
- *
406
- * Pageview number support
407
- *
408
- * @default false
409
- */
410
- pageview?: string | boolean;
411
- /**
412
- * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
413
- *
414
- * 你可以将其设置为 `window.location.pathname`
415
- *
416
- * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
417
- *
418
- * You can set it to `window.location.pathname`
419
- *
420
- * @default window.location.pathname
421
- */
422
- path?: string;
423
- }
424
- type WalineAbort = (reason?: any) => void;
425
-
426
- type Locales = Record<string, WalineLocale>;
427
- declare const DEFAULT_LOCALES: Locales;
428
-
429
- interface WalineCommentCountOptions {
430
- /**
431
- * Waline 服务端地址
432
- *
433
- * Waline server url
434
- */
435
- serverURL: string;
436
- /**
437
- * 评论数 CSS 选择器
438
- *
439
- * Comment count CSS selector
440
- *
441
- * @default '.waline-comment-count'
442
- */
443
- selector?: string;
444
- /**
445
- * 需要获取的默认路径
446
- *
447
- * Path to be fetched by default
448
- *
449
- * @default window.location.pathname
450
- */
451
- path?: string;
452
- /**
453
- * 错误提示消息所使用的语言
454
- *
455
- * Language of error message
456
- *
457
- * @default navigator.language
458
- */
459
- lang?: string;
460
- }
461
-
462
- declare const commentCount: ({ serverURL, path, selector, lang, }: WalineCommentCountOptions) => WalineAbort;
463
-
464
- interface WalineInstance {
465
- /**
466
- * Waline 被挂载到的元素
467
- *
468
- * @description 当通过 `el: null` 初始化,值为 `null`
469
- *
470
- * Element where Waline is mounted
471
- *
472
- * @description when initialized with `el: null`, it will be `null`
473
- */
474
- el: HTMLElement | null;
475
- /**
476
- * 更新 Waline 实例
477
- *
478
- * @description 只要不设置`path` 选项,更新时它就会被重置为 `windows.location.pathname`
479
- *
480
- * Update Waline instance
481
- *
482
- * @description when not setting `path` option, it will be reset to `window.location.pathname`
483
- */
484
- update: (newOptions?: Partial<Omit<WalineInitOptions, 'el'>>) => void;
485
- /**
486
- * 取消挂载并摧毁 Waline 实例
487
- *
488
- * Unmount and destroy Waline instance
489
- */
490
- destroy: () => void;
491
- }
492
- declare const init: ({ el, path, comment, pageview, ...initProps }: WalineInitOptions) => WalineInstance | null;
493
-
494
- interface WalinePageviewCountOptions {
495
- /**
496
- * Waline 服务端地址
497
- *
498
- * Waline server url
499
- */
500
- serverURL: string;
501
- /**
502
- * 浏览量 CSS 选择器
503
- *
504
- * Pageview CSS selector
505
- *
506
- * @default '.waline-pageview-count'
507
- */
508
- selector?: string;
509
- /**
510
- * 需要更新和获取的路径
511
- *
512
- * Path to be fetched and updated
513
- *
514
- * @default window.location.pathname
515
- */
516
- path?: string;
517
- /**
518
- * 是否在查询时更新 path 的浏览量
519
- *
520
- * Whether update pageviews when fetching path result
521
- *
522
- * @default true
523
- */
524
- update?: boolean;
525
- /**
526
- * 错误提示消息所使用的语言
527
- *
528
- * Language of error message
529
- *
530
- * @default navigator.language
531
- */
532
- lang?: string;
533
- }
534
-
535
- declare const pageviewCount: ({ serverURL, path, selector, update, lang, }: WalinePageviewCountOptions) => WalineAbort;
536
-
537
- declare const version: string;
538
-
539
- interface WalineRecentCommentsOptions {
540
- /**
541
- * Waline 服务端地址
542
- *
543
- * Waline serverURL
544
- */
545
- serverURL: string;
546
- /**
547
- * 获取最新评论的数量
548
- *
549
- * fetch number of latest comments
550
- */
551
- count: number;
552
- /**
553
- * 需要挂载的元素
554
- *
555
- * Element to be mounted
556
- */
557
- el?: string | HTMLElement;
558
- /**
559
- * 错误提示消息所使用的语言
560
- *
561
- * Language of error message
562
- *
563
- * @default navigator.language
564
- */
565
- lang?: string;
566
- }
567
- interface WalineRecentCommentsResult {
568
- /**
569
- * 评论数据
570
- *
571
- * Comment Data
572
- */
573
- comments: RecentCommentData[];
574
- /**
575
- * 取消挂载挂件
576
- *
577
- * Umount widget
578
- */
579
- destroy: () => void;
580
- }
581
- declare const RecentComments: ({ el, serverURL, count, lang, }: WalineRecentCommentsOptions) => Promise<WalineRecentCommentsResult>;
582
-
583
- interface WalineUserListOptions {
584
- /**
585
- * Waline 服务端地址
586
- *
587
- * Waline serverURL
588
- */
589
- serverURL: string;
590
- /**
591
- * 获取用户列表的数量
592
- *
593
- * fetch number of user list
594
- */
595
- count: number;
596
- /**
597
- * 需要挂载的元素
598
- *
599
- * Element to be mounted
600
- */
601
- el?: string | HTMLElement;
602
- /**
603
- * 错误提示消息所使用的语言
604
- *
605
- * Language of error message
606
- *
607
- * @default navigator.language
608
- */
609
- lang?: string;
610
- /**
611
- * 自定义 waline 语言显示
612
- *
613
- * @see [自定义语言](https://waline.js.org/client/i18n.html)
614
- *
615
- * Custom display language in waline
616
- *
617
- * @see [I18n](https://waline.js.org/en/client/i18n.html)
618
- */
619
- locale?: WalineLocale;
620
- /**
621
- * 列表模式还是头像墙模式
622
- *
623
- * list mode or avatar wall mode
624
- */
625
- mode: 'list' | 'wall';
626
- }
627
- interface WalineUserListResult {
628
- /**
629
- * 用户数据
630
- *
631
- * User Data
632
- */
633
- users: WalineUser[];
634
- /**
635
- * 取消挂载挂件
636
- *
637
- * Umount widget
638
- */
639
- destroy: () => void;
640
- }
641
- declare const UserList: ({ el, serverURL, count, locale, lang, mode, }: WalineUserListOptions) => Promise<WalineUserListResult>;
642
-
643
- export { RecentComments, UserList, type WalineAbort, type WalineCommentCountOptions, type WalineCommentSorting, type WalineDateLocale, type WalineEmojiInfo, type WalineEmojiMaps, type WalineEmojiPresets, type WalineHighlighter, type WalineImageUploader, type WalineInitOptions, type WalineInstance, type WalineLevelLocale, type WalineLocale, type WalineLoginStatus, type WalineMeta, type WalinePageviewCountOptions, type WalineProps, type WalineReactionLocale, type WalineRecentCommentsOptions, type WalineRecentCommentsResult, type WalineSearchImageData, type WalineSearchOptions, type WalineSearchResult, type WalineTeXRenderer, type WalineUserListOptions, type WalineUserListResult, commentCount, DEFAULT_LOCALES as defaultLocales, init, pageviewCount, version };