@waline/client 2.0.0-alpha.2 → 2.0.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 (47) hide show
  1. package/dist/component.js +1 -1
  2. package/dist/component.js.map +1 -1
  3. package/dist/legacy.d.ts +505 -0
  4. package/dist/legacy.js +2 -0
  5. package/dist/legacy.js.map +1 -0
  6. package/dist/pageview.cjs.js +1 -1
  7. package/dist/pageview.cjs.js.map +1 -1
  8. package/dist/pageview.d.ts +18 -12
  9. package/dist/pageview.esm.js +1 -1
  10. package/dist/pageview.esm.js.map +1 -1
  11. package/dist/pageview.js +1 -1
  12. package/dist/pageview.js.map +1 -1
  13. package/dist/shim.d.ts +63 -16
  14. package/dist/shim.esm.d.ts +63 -16
  15. package/dist/shim.esm.js +1 -1
  16. package/dist/shim.esm.js.map +1 -1
  17. package/dist/shim.js +1 -1
  18. package/dist/shim.js.map +1 -1
  19. package/dist/waline.cjs.d.ts +63 -16
  20. package/dist/waline.cjs.js +1 -1
  21. package/dist/waline.cjs.js.map +1 -1
  22. package/dist/waline.css +1 -1
  23. package/dist/waline.css.map +1 -1
  24. package/dist/waline.d.ts +63 -16
  25. package/dist/waline.esm.d.ts +63 -16
  26. package/dist/waline.esm.js +1 -1
  27. package/dist/waline.esm.js.map +1 -1
  28. package/dist/waline.js +1 -1
  29. package/dist/waline.js.map +1 -1
  30. package/package.json +2 -2
  31. package/src/comment.ts +25 -2
  32. package/src/compact/convert.ts +80 -0
  33. package/src/compact/dropped.ts +35 -0
  34. package/src/compact/index.ts +4 -0
  35. package/src/compact/logger.ts +5 -0
  36. package/src/compact/v1.ts +103 -0
  37. package/src/compact/valine.ts +132 -0
  38. package/src/components/Icons.ts +1 -1
  39. package/src/components/Waline.vue +18 -18
  40. package/src/entrys/legacy.ts +29 -0
  41. package/src/init.ts +27 -2
  42. package/src/pageview.ts +26 -20
  43. package/src/styles/emoji.scss +1 -1
  44. package/src/styles/nomalize.scss +2 -0
  45. package/src/typings/base.ts +1 -1
  46. package/src/typings/options.ts +3 -0
  47. package/src/utils/emoji.ts +2 -6
@@ -0,0 +1,505 @@
1
+ interface WalineEmojiInfo {
2
+ /**
3
+ * 选项卡上的 Emoji 名称
4
+ *
5
+ * Emoji name show on tab
6
+ */
7
+ name: string;
8
+ /**
9
+ * 所在文件夹链接
10
+ *
11
+ * Current folder link
12
+ */
13
+ folder?: string;
14
+ /**
15
+ * Emoji 通用路径前缀
16
+ *
17
+ * Common prefix of Emoji icons
18
+ */
19
+ prefix?: string;
20
+ /**
21
+ * Emoji 图片的类型,会作为文件扩展名使用
22
+ *
23
+ * Type of Emoji icons, will be regarded as file extension
24
+ */
25
+ type?: string;
26
+ /**
27
+ * 选项卡显示的 Emoji 图标
28
+ *
29
+ * Emoji icon show on tab
30
+ */
31
+ icon: string;
32
+ /**
33
+ * Emoji 图片列表
34
+ *
35
+ * Emoji image list
36
+ */
37
+ items: string[];
38
+ }
39
+ declare type WalineMeta = 'nick' | 'mail' | 'link';
40
+ declare type WalineImageUploader = (image: File) => Promise<string>;
41
+ declare type WalineHighlighter = ((code: string, lang: string) => string) | ((code: string, lang: string, callback?: (error: unknown | undefined, code?: string) => void) => void);
42
+ declare type WalineTexRenderer = (blockMode: boolean, tex: string) => string;
43
+
44
+ interface WalineLocale {
45
+ nick: string;
46
+ nickError: string;
47
+ mail: string;
48
+ mailError: string;
49
+ link: string;
50
+ optional: string;
51
+ placeholder: string;
52
+ sofa: string;
53
+ submit: string;
54
+ reply: string;
55
+ cancelReply: string;
56
+ comment: string;
57
+ refresh: string;
58
+ more: string;
59
+ preview: string;
60
+ emoji: string;
61
+ uploadImage: string;
62
+ seconds: string;
63
+ minutes: string;
64
+ hours: string;
65
+ days: string;
66
+ now: string;
67
+ uploading: string;
68
+ login: string;
69
+ logout: string;
70
+ admin: string;
71
+ sticky: string;
72
+ word: string;
73
+ wordHint: string;
74
+ anonymous: string;
75
+ }
76
+
77
+ interface WalineProps {
78
+ /**
79
+ * Waline 的服务端地址
80
+ *
81
+ * Waline server address url
82
+ */
83
+ serverURL: string;
84
+ /**
85
+ * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
86
+ *
87
+ * 你可以将其设置为 `window.location.pathname`
88
+ *
89
+ * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
90
+ *
91
+ * You can set it to `window.location.pathname`
92
+ */
93
+ path: string;
94
+ /**
95
+ * 评论者相关属性
96
+ *
97
+ * `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
98
+ *
99
+ * Reviewer attributes.
100
+ *
101
+ * Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
102
+ *
103
+ * @default ['nick', 'mail', 'link']
104
+ */
105
+ meta?: WalineMeta[];
106
+ /**
107
+ * 设置**必填项**,默认昵称为匿名
108
+ *
109
+ * Set required fields, default anonymous with nickname
110
+ *
111
+ * @default []
112
+ */
113
+ requiredMeta?: WalineMeta[];
114
+ /**
115
+ * 评论字数限制。填入单个数字时为最大字数限制
116
+ *
117
+ * @more 设置为 `0` 时无限制
118
+ *
119
+ * Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
120
+ *
121
+ * @more No limit when set to `0`.
122
+ *
123
+ * @default 0
124
+ */
125
+ wordLimit?: number | [number, number];
126
+ /**
127
+ * 评论列表分页,每页条数
128
+ *
129
+ * number of pages per page
130
+ *
131
+ * @default 10
132
+ */
133
+ pageSize?: number;
134
+ /**
135
+ * Waline 显示语言
136
+ *
137
+ * 可选值:
138
+ *
139
+ * - `'zh'`
140
+ * - `'zh-cn'`
141
+ * - `'zh-CN'`
142
+ * - `'zh-tw'`
143
+ * - `'zh-TW'`
144
+ * - `'en'`
145
+ * - `'en-US'`
146
+ * - `'en-us'`
147
+ * - `'jp'`
148
+ * - `'jp-jp'`
149
+ * - `'jp-JP'`
150
+ * - `'pt-br'`
151
+ * - `'pt-BR'`
152
+ * - `'ru'`
153
+ * - `'ru-ru'`
154
+ * - `'ru-RU'`
155
+ *
156
+ * Display language for waline
157
+ *
158
+ * Optional value:
159
+ *
160
+ * - `'zh'`
161
+ * - `'zh-cn'`
162
+ * - `'zh-CN'`
163
+ * - `'zh-tw'`
164
+ * - `'zh-TW'`
165
+ * - `'en'`
166
+ * - `'en-US'`
167
+ * - `'en-us'`
168
+ * - `'jp'`
169
+ * - `'jp-jp'`
170
+ * - `'jp-JP'`
171
+ * - `'pt-br'`
172
+ * - `'pt-BR'`
173
+ * - `'ru'`
174
+ * - `'ru-ru'`
175
+ * - `'ru-RU'`
176
+ *
177
+ * @default 'zh-CN'
178
+ */
179
+ lang?: string;
180
+ /**
181
+ * 自定义 waline 语言显示
182
+ *
183
+ * @see [自定义语言](https://waline.js.org/client/i18n.html)
184
+ *
185
+ * Custom display language in waline
186
+ *
187
+ * @see [I18n](https://waline.js.org/en/client/i18n.html)
188
+ */
189
+ locale?: Partial<WalineLocale>;
190
+ /**
191
+ * 是否启用暗黑模式适配
192
+ *
193
+ * @more 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
194
+ *
195
+ * Whether to enable darkmode support
196
+ *
197
+ * @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.
198
+ */
199
+ dark?: string | boolean;
200
+ /**
201
+ * 设置表情包
202
+ *
203
+ * Set Emojis
204
+ *
205
+ * @default ['https://cdn.jsdelivr.net/gh/walinejs/emojis/weibo']
206
+ */
207
+ emoji?: (string | WalineEmojiInfo)[];
208
+ /**
209
+ * 代码高亮
210
+ *
211
+ * Code highlighting
212
+ */
213
+ highlighter?: WalineHighlighter | false;
214
+ /**
215
+ * 自定义图片上传方法,方便更好的存储图片
216
+ *
217
+ * 方法执行时会将图片对象传入。
218
+ *
219
+ * Custom image upload callback to manage picture by yourself.
220
+ *
221
+ * We will pass a picture file object when execute it.
222
+ */
223
+ imageUploader?: WalineImageUploader | false;
224
+ /**
225
+ * 自定义数学公式处理方法,用于预览。
226
+ *
227
+ * Custom math formula parse callback for preview.
228
+ */
229
+ texRenderer?: WalineTexRenderer | false;
230
+ /**
231
+ *
232
+ * 登录模式状态,可选值:
233
+ *
234
+ * - `'enable'`: 启用登录 (默认)
235
+ * - `'disable'`: 禁用登录,用户只能填写信息评论
236
+ * - `'force'`: 强制登录,用户必须注册并登录才可发布评论
237
+ *
238
+ * Login mode status, optional values:
239
+ *
240
+ * - `'enable'`: enable login (default)
241
+ * - `'disable'`: Login is disabled, users should fill in infomation to comment
242
+ * - `'force'`: Forced login, users must login to comment
243
+ *
244
+ * @default 'enable'
245
+ */
246
+ login?: 'enable' | 'disable' | 'force';
247
+ /**
248
+ * 是否在页脚展示版权信息
249
+ *
250
+ * 为了支持 Waline,我们强烈建议你开启它
251
+ *
252
+ * Whether show copyright in footer
253
+ *
254
+ * We strongly recommended you to keep it on to support waline
255
+ *
256
+ * @default true
257
+ */
258
+ copyright?: boolean;
259
+ }
260
+
261
+ interface WalineInitOptions extends Omit<WalineProps, 'path'> {
262
+ /**
263
+ * Waline 的初始化挂载器。必须是一个**有效的** CSS 选择器 或 HTML 元素
264
+ *
265
+ * The DOM element to be mounted on initialization. It must be a **valid** CSS selector string or HTML Element.
266
+ */
267
+ el?: string | HTMLElement | null;
268
+ /**
269
+ * 评论数统计
270
+ *
271
+ * Comment number support
272
+ *
273
+ * @default false
274
+ */
275
+ comment?: string | boolean;
276
+ /**
277
+ * 页面访问量统计
278
+ *
279
+ * Pageview number support
280
+ *
281
+ * @default false
282
+ */
283
+ pageview?: string | boolean;
284
+ /**
285
+ * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
286
+ *
287
+ * 你可以将其设置为 `window.location.pathname`
288
+ *
289
+ * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
290
+ *
291
+ * You can set it to `window.location.pathname`
292
+ *
293
+ * @default window.location.pathname
294
+ */
295
+ path?: string;
296
+ }
297
+
298
+ interface WalineInstance {
299
+ /**
300
+ * Waline 被挂载到的元素
301
+ *
302
+ * @description 当通过 `el: null` 初始化,值为 `null`
303
+ *
304
+ * Element where Waline is mounted
305
+ *
306
+ * @description when initialized with `el: null`, it will be `null`
307
+ */
308
+ el: HTMLElement | null;
309
+ /**
310
+ * 更新 Waline 实例
311
+ *
312
+ * @description 只要不设置`path` 选项,更新时它就会被重置为 `windows.location.pathname`
313
+ *
314
+ * Update Waline instance
315
+ *
316
+ * @description when not setting `path` option, it will be reset to `window.location.pathname`
317
+ */
318
+ update: (newOptions: Partial<Omit<WalineInitOptions, 'el'>>) => void;
319
+ /**
320
+ * 取消挂载并摧毁 Waline 实例
321
+ *
322
+ * Unmount and destroy Waline instance
323
+ */
324
+ destroy: () => void;
325
+ }
326
+
327
+ declare type DeprecatedAvatar = '' | 'mp' | 'identicon' | 'monsterid' | 'wavatar' | 'retro' | 'robohash' | 'hide';
328
+ declare type DeprecatedEmojiMaps = Record<string, string>;
329
+ interface DeprecatedValineOptions {
330
+ /**
331
+ * @deprecated Use `locale.placeholder` instead, dropped in V2
332
+ */
333
+ placeholder?: string;
334
+ /**
335
+ * @deprecated Use `locale` instead, dropped in V2
336
+ */
337
+ langMode?: Partial<WalineLocale>;
338
+ /**
339
+ * @deprecated Use `requiredMeta` instead, dropped in V2
340
+ */
341
+ requiredFields?: WalineMeta[];
342
+ /**
343
+ * @deprecated Please use `AVATAR_PROXY` in server, dropped in V2
344
+ *
345
+ * [Gravatar](http://cn.gravatar.com/) 头像展示方式
346
+ *
347
+ * 可选值:
348
+ *
349
+ * - `''`
350
+ * - `'mp'`
351
+ * - `'identicon'`
352
+ * - `'monsterid'`
353
+ * - `'wavatar'`
354
+ * - `'retro'`
355
+ * - `'robohash'`
356
+ * - `'hide'`
357
+ *
358
+ * [Gravatar](http://gravatar.com/) type
359
+ *
360
+ * Optional value:
361
+ *
362
+ * - `''`
363
+ * - `'mp'`
364
+ * - `'identicon'`
365
+ * - `'monsterid'`
366
+ * - `'wavatar'`
367
+ * - `'retro'`
368
+ * - `'robohash'`
369
+ * - `'hide'`
370
+ *
371
+ * @default 'mp'
372
+ */
373
+ avatar?: DeprecatedAvatar;
374
+ /**
375
+ * @deprecated no longer needed, dropped in V2
376
+ *
377
+ * 每次访问是否**强制**拉取最新的*评论列表头像*
378
+ *
379
+ * Whether **force** pulling the latest avatar each time
380
+ *
381
+ * @default false
382
+ */
383
+ avatarForce?: boolean;
384
+ /**
385
+ * @deprecated Use `emojis` instead, dropped in V2
386
+ *
387
+ * 设置**表情包 CDN**
388
+ *
389
+ * @see [自定义表情包](https://waline.js.org/client/emoji.html)
390
+ *
391
+ * Set **Emoji Pack CDN**
392
+ *
393
+ * @see [Custom Emoji](https://waline.js.org/en/client/emoji.html)
394
+ *
395
+ * @default 'https://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/'
396
+ */
397
+ emojiCDN?: string;
398
+ /**
399
+ * @deprecated Use `emojis` instead, dropped in V2
400
+ *
401
+ * 设置**表情包映射**
402
+ *
403
+ * @see [自定义表情](https://waline.js.org/client/emoji.html)
404
+ *
405
+ * Set **emoji maps**
406
+ *
407
+ * @see [Custom Emoji](https://waline.js.org/en/client/emoji.html)
408
+ *
409
+ * @default 微博表情包
410
+ */
411
+ emojiMaps?: DeprecatedEmojiMaps;
412
+ }
413
+
414
+ interface DeprecatedWalineOptions {
415
+ /**
416
+ * @deprecated Please use mathjax in server, dropped in V2
417
+ *
418
+ * 是否注入额外的样式添加对 `<math>` 块的兼容
419
+ *
420
+ * Whether injecting additional styles to support math block
421
+ *
422
+ * @default false
423
+ */
424
+ mathTagSupport?: boolean;
425
+ /**
426
+ * @deprecated use `pageview` instead, dropped in V2
427
+ *
428
+ * 文章访问量统计
429
+ *
430
+ * Article reading statistics
431
+ *
432
+ * @default false
433
+ */
434
+ visitor?: boolean;
435
+ /**
436
+ * @deprecated use `highlighter` instead, dropped in V2
437
+ *
438
+ * 代码高亮
439
+ *
440
+ * Code highlighting
441
+ */
442
+ highlight?: WalineHighlighter | false;
443
+ /**
444
+ * @deprecated use `imageUploader` instead, dropped in V2
445
+ *
446
+ * 自定义图片上传方法,方便更好的存储图片
447
+ *
448
+ * 方法执行时会将图片对象传入。
449
+ *
450
+ * Custom image upload callback to manage picture by yourself.
451
+ *
452
+ * We will pass a picture file object when execute it.
453
+ */
454
+ uploadImage?: WalineImageUploader | false;
455
+ /**
456
+ * @deprecated Use `login` instead, dropped in V2
457
+ *
458
+ * 是否允许登录评论
459
+ *
460
+ * 默认情况是两者都支持,设置为 `true` 表示仅支持匿名评论,`false` 表示仅支持登录评论。
461
+ *
462
+ * Whether to allow login comments.
463
+ *
464
+ * Both supported by default, set to `true` means only support anonymous comments, `false` means only support login comments.
465
+ *
466
+ * @default undefined
467
+ */
468
+ anonymous?: boolean;
469
+ /**
470
+ * @deprecated Please use `AVATAR_PROXY` in server, dropped in V2
471
+ *
472
+ * 设置 Gravatar 头像 CDN 地址
473
+ *
474
+ * Gravatar CDN baseURL
475
+ *
476
+ * @default 'https://www.gravatar.com/avatar'
477
+ */
478
+ avatarCDN?: string;
479
+ /**
480
+ * @deprecated Use `texRenderer` instead, dropped in V2
481
+ *
482
+ * 自定义 Tex 处理方法,用于预览。
483
+ *
484
+ * Custom math formula parse callback for preview.
485
+ */
486
+ previewMath?: WalineTexRenderer | false;
487
+ /**
488
+ * @deprecated use `copyright` instead, dropped in V2
489
+ *
490
+ * 是否在页脚展示版权信息
491
+ *
492
+ * 为了支持 Waline,我们强烈建议你开启它
493
+ *
494
+ * Whether show copyright in footer
495
+ *
496
+ * We strongly recommended you to keep it on to support waline
497
+ *
498
+ * @default true
499
+ */
500
+ copyRight?: boolean;
501
+ }
502
+
503
+ declare function legacyWaline(options: WalineInitOptions & DeprecatedValineOptions & DeprecatedWalineOptions): WalineInstance | null;
504
+
505
+ export { WalineInstance, legacyWaline as default };