@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/comment.d.ts CHANGED
@@ -1,40 +1,48 @@
1
+ //#region src/typings/options.d.ts
2
+ // oxlint-disable-next-line typescript/explicit-module-boundary-types, typescript/no-explicit-any
1
3
  type WalineAbort = (reason?: any) => void;
2
-
4
+ //#endregion
5
+ //#region src/comment.d.ts
3
6
  interface WalineCommentCountOptions {
4
- /**
5
- * Waline 服务端地址
6
- *
7
- * Waline server url
8
- */
9
- serverURL: string;
10
- /**
11
- * 评论数 CSS 选择器
12
- *
13
- * Comment count CSS selector
14
- *
15
- * @default '.waline-comment-count'
16
- */
17
- selector?: string;
18
- /**
19
- * 需要获取的默认路径
20
- *
21
- * Path to be fetched by default
22
- *
23
- * @default window.location.pathname
24
- */
25
- path?: string;
26
- /**
27
- * 错误提示消息所使用的语言
28
- *
29
- * Language of error message
30
- *
31
- * @default navigator.language
32
- */
33
- lang?: string;
7
+ /**
8
+ * Waline 服务端地址
9
+ *
10
+ * Waline server url
11
+ */
12
+ serverURL: string;
13
+ /**
14
+ * 评论数 CSS 选择器
15
+ *
16
+ * Comment count CSS selector
17
+ *
18
+ * @default '.waline-comment-count'
19
+ */
20
+ selector?: string;
21
+ /**
22
+ * 需要获取的默认路径
23
+ *
24
+ * Path to be fetched by default
25
+ *
26
+ * @default window.location.pathname
27
+ */
28
+ path?: string;
29
+ /**
30
+ * 错误提示消息所使用的语言
31
+ *
32
+ * Language of error message
33
+ *
34
+ * @default navigator.language
35
+ */
36
+ lang?: string;
34
37
  }
35
- declare const commentCount: ({ serverURL, path, selector, lang, }: WalineCommentCountOptions) => WalineAbort;
36
-
38
+ declare const commentCount: ({
39
+ serverURL,
40
+ path,
41
+ selector,
42
+ lang
43
+ }: WalineCommentCountOptions) => WalineAbort;
44
+ //#endregion
45
+ //#region src/version.d.ts
37
46
  declare const version: string;
38
-
39
- export { commentCount, version };
40
- export type { WalineAbort, WalineCommentCountOptions };
47
+ //#endregion
48
+ export { type WalineAbort, WalineCommentCountOptions, commentCount, version };
package/dist/comment.js CHANGED
@@ -1,2 +1 @@
1
- const h=e=>`${e.replace(/\/?$/,"/")}api/`,g=(e,t="")=>{if(typeof e=="object"&&e.errno)throw new TypeError(`${t} failed with ${e.errno}: ${e.errmsg}`);return e},i=({serverURL:e,lang:t,paths:r,signal:o})=>fetch(`${h(e)}comment?type=count&url=${encodeURIComponent(r.join(","))}&lang=${t}`,{signal:o}).then(n=>n.json()).then(n=>g(n,"Get comment count").data),u=e=>{try{return decodeURI(e)}catch{return e}},p=(e="")=>e.replace(/\/$/u,""),m=e=>/^(https?:)?\/\//.test(e),d=e=>{const t=p(e);return m(t)?t:`https://${t}`},$=e=>{e.name!=="AbortError"&&console.error(e.message)},f=e=>{const{path:t}=e.dataset;return t!=null&&t.length?t:null},v=({serverURL:e,path:t=window.location.pathname,selector:r=".waline-comment-count",lang:o=navigator.language})=>{const n=new AbortController,a=document.querySelectorAll(r);return a.length>0&&i({serverURL:d(e),paths:Array.from(a,c=>u(f(c)??t)),lang:o,signal:n.signal}).then(c=>{a.forEach((s,l)=>{s.textContent=c[l].toString()})}).catch($),n.abort.bind(n)},w="3.12.2";export{v as commentCount,w as version};
2
- //# sourceMappingURL=comment.js.map
1
+ import{fetchCommentCount as e}from"@waline/api";const t=e=>{try{return decodeURI(e)}catch{return e}},n=(e=``)=>e.replace(/\/$/u,``),r=e=>/^(https?:)?\/\//u.test(e),i=e=>{let t=n(e);return r(t)?t:`https://${t}`},a=e=>{e.name!==`AbortError`&&console.error(e.message)},o=e=>{let{path:t}=e.dataset;return t?.length?t:null},s=({serverURL:n,path:r=window.location.pathname,selector:s=`.waline-comment-count`,lang:c=navigator.language})=>{let l=new AbortController,u=document.querySelectorAll(s);return u.length>0&&e({serverURL:i(n),paths:Array.from(u,e=>t(o(e)??r)),lang:c,signal:l.signal}).then(e=>{u.forEach((t,n)=>{t.textContent=e[n].toString()})}).catch(a),l.abort.bind(l)},c=`3.14.0`;export{s as commentCount,c as version};
@@ -1,9 +1,8 @@
1
- import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
1
+ import { ComponentOptionsMixin, ComponentProvideOptions, DefineComponent, PublicProps } from "vue";
2
2
 
3
+ //#region src/typings/base.d.ts
3
4
  type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
4
-
5
5
  type WalineEmojiPresets = `//${string}` | `http://${string}` | `https://${string}`;
6
-
7
6
  interface WalineEmojiInfo {
8
7
  /**
9
8
  * 选项卡上的 Emoji 名称
@@ -42,9 +41,7 @@ interface WalineEmojiInfo {
42
41
  */
43
42
  items: string[];
44
43
  }
45
-
46
44
  type WalineLoginStatus = 'enable' | 'disable' | 'force';
47
-
48
45
  interface WalineSearchImageData extends Record<string, unknown> {
49
46
  /**
50
47
  * 图片链接
@@ -52,34 +49,30 @@ interface WalineSearchImageData extends Record<string, unknown> {
52
49
  * Image link
53
50
  */
54
51
  src: string;
55
-
56
52
  /**
57
53
  * 图片标题
58
54
  *
59
- * @description 用于图片的 alt 属性
55
+ * 用于图片的 alt 属性
60
56
  *
61
57
  * Image title
62
58
  *
63
- * @description Used for alt attribute of image
59
+ * Used for alt attribute of image
64
60
  */
65
61
  title?: string;
66
-
67
62
  /**
68
63
  * 图片缩略图
69
64
  *
70
- * @description 为了更好的加载性能,我们会优先在列表中使用此缩略图
65
+ * 为了更好的加载性能,我们会优先在列表中使用此缩略图
71
66
  *
72
67
  * Image preview link
73
68
  *
74
- * @description For better loading performance, we will use this thumbnail first in the list
69
+ * For better loading performance, we will use this thumbnail first in the list
75
70
  *
76
71
  * @default src
77
72
  */
78
73
  preview?: string;
79
74
  }
80
-
81
75
  type WalineSearchResult = WalineSearchImageData[];
82
-
83
76
  interface WalineSearchOptions {
84
77
  /**
85
78
  * 搜索操作
@@ -87,7 +80,6 @@ interface WalineSearchOptions {
87
80
  * Search action
88
81
  */
89
82
  search: (word: string) => Promise<WalineSearchResult>;
90
-
91
83
  /**
92
84
  * 打开列表时展示的默认结果
93
85
  *
@@ -96,29 +88,26 @@ interface WalineSearchOptions {
96
88
  * @default () => search('')
97
89
  */
98
90
  default?: () => Promise<WalineSearchResult>;
99
-
100
91
  /**
101
92
  * 获取更多的操作
102
93
  *
103
- * @description 会在列表滚动到底部时触发,如果你的搜索服务支持分页功能,你应该设置此项实现无限滚动
94
+ * 会在列表滚动到底部时触发,如果你的搜索服务支持分页功能,你应该设置此项实现无限滚动
104
95
  *
105
96
  * Fetch more action
106
97
  *
107
- * @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
98
+ * It will be triggered when the list scrolls to the bottom. If your search service supports
99
+ * paging, you should set this to achieve infinite scrolling
108
100
  *
109
101
  * @default (word) => search(word)
110
102
  */
111
103
  more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
112
104
  }
113
-
114
105
  type WalineMeta = 'nick' | 'mail' | 'link';
115
-
116
106
  type WalineImageUploader = (image: File) => Promise<string>;
117
-
118
107
  type WalineHighlighter = (code: string, lang: string) => string;
119
-
120
108
  type WalineTeXRenderer = (blockMode: boolean, tex: string) => string;
121
-
109
+ //#endregion
110
+ //#region src/typings/locale.d.ts
122
111
  interface WalineDateLocale {
123
112
  seconds: string;
124
113
  minutes: string;
@@ -126,9 +115,7 @@ interface WalineDateLocale {
126
115
  days: string;
127
116
  now: string;
128
117
  }
129
-
130
118
  type WalineLevelLocale = Record<`level${number}`, string>;
131
-
132
119
  interface WalineReactionLocale {
133
120
  reactionTitle: string;
134
121
  reaction0: string;
@@ -141,7 +128,6 @@ interface WalineReactionLocale {
141
128
  reaction7: string;
142
129
  reaction8: string;
143
130
  }
144
-
145
131
  interface WalineLocale extends WalineDateLocale, WalineLevelLocale, WalineReactionLocale {
146
132
  nick: string;
147
133
  mail: string;
@@ -160,25 +146,17 @@ interface WalineLocale extends WalineDateLocale, WalineLevelLocale, WalineReacti
160
146
  word: string;
161
147
  anonymous: string;
162
148
  gif: string;
163
- gifSearchPlaceholder: string;
164
-
165
- // manage
149
+ gifSearchPlaceholder: string; // manage
166
150
  approved: string;
167
151
  waiting: string;
168
152
  spam: string;
169
- unsticky: string;
170
-
171
- // sorting
153
+ unsticky: string; // sorting
172
154
  oldest: string;
173
155
  latest: string;
174
- hottest: string;
175
-
176
- // hint
156
+ hottest: string; // hint
177
157
  nickError: string;
178
158
  mailError: string;
179
- wordHint: string;
180
-
181
- // i18n
159
+ wordHint: string; // i18n
182
160
  like: string;
183
161
  cancelLike: string;
184
162
  reply: string;
@@ -189,12 +167,12 @@ interface WalineLocale extends WalineDateLocale, WalineLevelLocale, WalineReacti
189
167
  profile: string;
190
168
  logout: string;
191
169
  commentUnderReview: string;
192
-
193
170
  subPostComment: string;
194
171
  subSiteComment: string;
195
172
  subscribeToReplies: string;
196
173
  }
197
-
174
+ //#endregion
175
+ //#region src/typings/waline.d.ts
198
176
  interface WalineProps {
199
177
  /**
200
178
  * Waline 的服务端地址
@@ -202,18 +180,17 @@ interface WalineProps {
202
180
  * Waline server address url
203
181
  */
204
182
  serverURL: string;
205
-
206
183
  /**
207
184
  * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
208
185
  *
209
186
  * 你可以将其设置为 `window.location.pathname`
210
187
  *
211
- * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
188
+ * Article path id. Used to distinguish different _article pages_ to ensure loading the correct
189
+ * comment list under the _article page_.
212
190
  *
213
191
  * You can set it to `window.location.pathname`
214
192
  */
215
193
  path: string;
216
-
217
194
  /**
218
195
  * 评论者相关属性
219
196
  *
@@ -226,38 +203,35 @@ interface WalineProps {
226
203
  * @default ['nick', 'mail', 'link']
227
204
  */
228
205
  meta?: WalineMeta[];
229
-
230
206
  /**
231
207
  * 设置**必填项**,默认昵称为匿名
232
208
  *
233
209
  * Set required fields, default anonymous with nickname
234
210
  *
235
- * @default []
211
+ * @default [ ]
236
212
  */
237
213
  requiredMeta?: WalineMeta[];
238
-
239
214
  /**
240
215
  * 评论字数限制。填入单个数字时为最大字数限制
241
216
  *
242
- * @description 设置为 `0` 时无限制
217
+ * 设置为 `0` 时无限制
243
218
  *
244
- * Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
219
+ * Comment word s limit. When a single number is filled in, it 's the maximum number of comment
220
+ * words.
245
221
  *
246
- * @description No limit when set to `0`.
222
+ * No limit when set to `0`.
247
223
  *
248
224
  * @default 0
249
225
  */
250
226
  wordLimit?: number | [number, number];
251
-
252
227
  /**
253
228
  * 评论列表分页,每页条数
254
229
  *
255
- * number of pages per page
230
+ * Number of pages per page
256
231
  *
257
232
  * @default 10
258
233
  */
259
234
  pageSize?: number;
260
-
261
235
  /**
262
236
  * Waline 显示语言
263
237
  *
@@ -308,18 +282,15 @@ interface WalineProps {
308
282
  * @default navigator.language
309
283
  */
310
284
  lang?: string;
311
-
312
285
  /**
313
286
  * 自定义 waline 语言显示
314
287
  *
315
288
  * @see [自定义语言](https://waline.js.org/client/i18n.html)
316
289
  *
317
290
  * Custom display language in waline
318
- *
319
291
  * @see [I18n](https://waline.js.org/en/client/i18n.html)
320
292
  */
321
293
  locale?: Partial<WalineLocale>;
322
-
323
294
  /**
324
295
  * 评论列表排序方式
325
296
  *
@@ -328,20 +299,18 @@ interface WalineProps {
328
299
  * @default 'latest'
329
300
  */
330
301
  commentSorting?: WalineCommentSorting;
331
-
332
302
  /**
333
303
  * 是否启用暗黑模式适配
334
304
  *
335
- * @description 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
305
+ * 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
336
306
  *
337
307
  * Whether to enable darkmode support
338
308
  *
339
- * @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.
309
+ * Setting `'auto'` will display darkmode due to device settings. Filling in CSS selector will
310
+ * enable darkmode only when the selector match waline ancestor nodes.
340
311
  */
341
312
  dark?: string | boolean;
342
-
343
313
  /**
344
- *
345
314
  * 登录模式状态,可选值:
346
315
  *
347
316
  * - `'enable'`: 启用登录 (默认)
@@ -357,7 +326,6 @@ interface WalineProps {
357
326
  * @default 'enable'
358
327
  */
359
328
  login?: WalineLoginStatus;
360
-
361
329
  /**
362
330
  * 是否在页脚隐藏版权信息
363
331
  *
@@ -366,10 +334,8 @@ interface WalineProps {
366
334
  * Whether hide copyright in footer
367
335
  *
368
336
  * We strongly recommended you to keep it on to support waline
369
- *
370
337
  */
371
338
  noCopyright?: boolean;
372
-
373
339
  /**
374
340
  * 是否隐藏 RSS 订阅入口
375
341
  *
@@ -378,21 +344,18 @@ interface WalineProps {
378
344
  * @default false
379
345
  */
380
346
  noRss?: boolean;
381
-
382
347
  /**
383
- * recaptcha v3 客户端 key
348
+ * Recaptcha v3 客户端 key
384
349
  *
385
- * recaptcha v3 client key
350
+ * Recaptcha v3 client key
386
351
  */
387
352
  recaptchaV3Key?: string;
388
-
389
353
  /**
390
- * turnstile 客户端 key
354
+ * Turnstile 客户端 key
391
355
  *
392
- * turnstile client key
356
+ * Turnstile client key
393
357
  */
394
358
  turnstileKey?: string;
395
-
396
359
  /**
397
360
  * 文章反应
398
361
  *
@@ -401,7 +364,6 @@ interface WalineProps {
401
364
  * @default false
402
365
  */
403
366
  reaction?: string[] | boolean;
404
-
405
367
  /**
406
368
  * 设置表情包
407
369
  *
@@ -410,22 +372,18 @@ interface WalineProps {
410
372
  * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
411
373
  */
412
374
  emoji?: (WalineEmojiInfo | WalineEmojiPresets)[];
413
-
414
375
  /**
415
376
  * 设置搜索功能
416
377
  *
417
378
  * Customize Search feature
418
379
  */
419
- search?: WalineSearchOptions;
420
-
380
+ search?: WalineSearchOptions | boolean;
421
381
  /**
422
382
  * 代码块高亮器
423
383
  *
424
384
  * Code fence highlighter
425
385
  */
426
-
427
386
  highlighter?: WalineHighlighter;
428
-
429
387
  /**
430
388
  * 自定义图片上传方法,方便更好的存储图片
431
389
  *
@@ -435,9 +393,7 @@ interface WalineProps {
435
393
  *
436
394
  * We will pass a picture file object when execute it.
437
395
  */
438
-
439
396
  imageUploader?: WalineImageUploader;
440
-
441
397
  /**
442
398
  * 自定义数学公式处理方法,用于预览。
443
399
  *
@@ -445,33 +401,9 @@ interface WalineProps {
445
401
  */
446
402
  texRenderer?: WalineTeXRenderer;
447
403
  }
448
-
449
- // oxlint-disable typescript/ban-types
450
- /* eslint-disable typescript/no-empty-object-type */
451
-
452
-
453
- declare const Waline: DefineComponent<
454
- WalineProps,
455
- {},
456
- {},
457
- {},
458
- {},
459
- ComponentOptionsMixin,
460
- ComponentOptionsMixin,
461
- {},
462
- string,
463
- PublicProps,
464
- Readonly<WalineProps> & Readonly<{}>,
465
- {},
466
- {},
467
- {},
468
- {},
469
- string,
470
- ComponentProvideOptions,
471
- false,
472
- {},
473
- HTMLDivElement
474
- >;
404
+ //#endregion
405
+ //#region src/entries/component-type.d.ts
406
+ declare const Waline: DefineComponent<WalineProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<WalineProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
475
407
  declare const version: string;
476
-
477
- export { Waline, version };
408
+ //#endregion
409
+ export { Waline, version };