@waline/client 2.14.9 → 2.15.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 (83) hide show
  1. package/dist/api.cjs.map +1 -1
  2. package/dist/api.d.cts +4 -0
  3. package/dist/api.d.mts +4 -0
  4. package/dist/api.d.ts +4 -0
  5. package/dist/api.mjs.map +1 -1
  6. package/dist/comment.cjs +1 -1
  7. package/dist/comment.cjs.map +1 -1
  8. package/dist/comment.js +1 -1
  9. package/dist/comment.js.map +1 -1
  10. package/dist/comment.mjs +1 -1
  11. package/dist/comment.mjs.map +1 -1
  12. package/dist/component.mjs +1 -1
  13. package/dist/component.mjs.map +1 -1
  14. package/dist/legacy.umd.d.ts +92 -88
  15. package/dist/legacy.umd.js +1 -1
  16. package/dist/legacy.umd.js.map +1 -1
  17. package/dist/pageview.cjs +1 -1
  18. package/dist/pageview.cjs.map +1 -1
  19. package/dist/pageview.js +1 -1
  20. package/dist/pageview.js.map +1 -1
  21. package/dist/pageview.mjs +1 -1
  22. package/dist/pageview.mjs.map +1 -1
  23. package/dist/shim.cjs +1 -1
  24. package/dist/shim.cjs.map +1 -1
  25. package/dist/shim.d.cts +8 -0
  26. package/dist/shim.d.mts +8 -0
  27. package/dist/shim.mjs +1 -1
  28. package/dist/shim.mjs.map +1 -1
  29. package/dist/waline.cjs +1 -1
  30. package/dist/waline.cjs.map +1 -1
  31. package/dist/waline.css.map +1 -1
  32. package/dist/waline.d.cts +8 -0
  33. package/dist/waline.d.mts +8 -0
  34. package/dist/waline.d.ts +8 -0
  35. package/dist/waline.js +1 -1
  36. package/dist/waline.js.map +1 -1
  37. package/dist/waline.mjs +1 -1
  38. package/dist/waline.mjs.map +1 -1
  39. package/package.json +18 -27
  40. package/src/api/articleCounter.ts +1 -2
  41. package/src/api/comment.ts +10 -3
  42. package/src/api/commentCount.ts +1 -1
  43. package/src/api/login.ts +1 -1
  44. package/src/api/pageview.ts +2 -2
  45. package/src/api/recentComment.ts +2 -2
  46. package/src/api/user.ts +6 -3
  47. package/src/comment.ts +3 -3
  48. package/src/compact/convert.ts +6 -7
  49. package/src/compact/v1.ts +5 -5
  50. package/src/compact/valine.ts +6 -6
  51. package/src/components/ArticleReaction.vue +3 -4
  52. package/src/components/CommentBox.vue +56 -43
  53. package/src/components/CommentCard.vue +8 -7
  54. package/src/components/Icons.ts +4 -3
  55. package/src/components/ImageWall.vue +1 -2
  56. package/src/components/WalineComment.vue +8 -7
  57. package/src/composables/inputs.ts +1 -2
  58. package/src/composables/like.ts +1 -2
  59. package/src/composables/reaction.ts +1 -2
  60. package/src/composables/recaptchaV3.ts +1 -3
  61. package/src/composables/turnstile.ts +79 -0
  62. package/src/composables/userInfo.ts +2 -2
  63. package/src/config/default.ts +8 -7
  64. package/src/config/i18n/generate.ts +1 -1
  65. package/src/config/i18n/index.ts +7 -8
  66. package/src/entries/legacy.ts +10 -10
  67. package/src/init.ts +4 -5
  68. package/src/pageview.ts +3 -4
  69. package/src/shims-vue.d.ts +2 -1
  70. package/src/styles/card.scss +3 -3
  71. package/src/styles/emoji.scss +0 -3
  72. package/src/styles/index.scss +0 -5
  73. package/src/typings/comment.ts +5 -0
  74. package/src/typings/options.ts +1 -1
  75. package/src/typings/waline.ts +17 -12
  76. package/src/utils/config.ts +10 -10
  77. package/src/utils/emoji.ts +3 -3
  78. package/src/utils/index.ts +12 -11
  79. package/src/utils/markdown.ts +6 -6
  80. package/src/utils/markedMathExtension.ts +3 -2
  81. package/src/utils/userAgent.ts +1 -1
  82. package/src/utils/wordCount.ts +1 -1
  83. package/src/widgets/recentComments.ts +4 -5
@@ -1,12 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import en from './en';
3
- import jp from './jp';
4
- import zhCN from './zh-CN';
5
- import zhTW from './zh-TW';
6
- import ptBR from './pt-BR';
7
- import ru from './ru';
8
-
9
- import type { WalineLocale } from '../../typings';
2
+ import en from './en.js';
3
+ import jp from './jp.js';
4
+ import ptBR from './pt-BR.js';
5
+ import ru from './ru.js';
6
+ import zhCN from './zh-CN.js';
7
+ import zhTW from './zh-TW.js';
8
+ import { type WalineLocale } from '../../typings/index.js';
10
9
 
11
10
  export type Locales = Record<string, WalineLocale>;
12
11
 
@@ -1,13 +1,13 @@
1
- import { covertOptions, warning } from '../compact';
2
- import { init, WalineInstance } from '../init';
3
-
4
- import type {
5
- DeprecatedValineOptions,
6
- DeprecatedWalineOptions,
7
- } from '../compact';
8
- import type { WalineInitOptions } from '../typings';
9
-
10
- export { WalineInstance } from '../init';
1
+ import {
2
+ type DeprecatedValineOptions,
3
+ type DeprecatedWalineOptions,
4
+ covertOptions,
5
+ warning,
6
+ } from '../compact/index.js';
7
+ import { init, WalineInstance } from '../init.js';
8
+ import { type WalineInitOptions } from '../typings/index.js';
9
+
10
+ export { WalineInstance } from '../init.js';
11
11
 
12
12
  warning(
13
13
  ' This is a legacy package compatible with Valine and Waline@v1, please switch to Waline@v2 using https://<CDN.LINK>/@waline/client/dist/waline.js instead!'
package/src/init.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import { createApp, h, reactive, watchEffect } from 'vue';
2
2
 
3
+ import { commentCount } from './comment.js';
3
4
  import Waline from './components/WalineComment.vue';
4
- import { commentCount } from './comment';
5
- import { pageviewCount } from './pageview';
6
- import { getRoot } from './utils';
7
-
8
- import type { WalineInitOptions } from './typings';
5
+ import { pageviewCount } from './pageview.js';
6
+ import { type WalineInitOptions } from './typings/index.js';
7
+ import { getRoot } from './utils/index.js';
9
8
 
10
9
  export interface WalineInstance {
11
10
  /**
package/src/pageview.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { getPageview, updatePageview } from './api';
2
- import { errorHandler, getQuery, getServerURL } from './utils';
3
-
4
- import type { WalineAbort } from './typings';
1
+ import { getPageview, updatePageview } from './api/index.js';
2
+ import { type WalineAbort } from './typings/index.js';
3
+ import { errorHandler, getQuery, getServerURL } from './utils/index.js';
5
4
 
6
5
  export interface WalinePageviewCountOptions {
7
6
  /**
@@ -1,5 +1,6 @@
1
1
  declare module '*.vue' {
2
- import type { DefineComponent } from 'vue';
2
+ import { type DefineComponent } from 'vue';
3
+
3
4
  const component: DefineComponent;
4
5
  export default component;
5
6
  }
@@ -68,11 +68,11 @@
68
68
 
69
69
  .wl-nick {
70
70
  position: relative;
71
-
71
+
72
72
  display: inline-block;
73
-
73
+
74
74
  margin-inline-end: 0.5em;
75
-
75
+
76
76
  font-weight: bold;
77
77
  font-size: 0.875em;
78
78
  line-height: 1;
@@ -79,11 +79,8 @@
79
79
 
80
80
  .wl-tabs {
81
81
  position: relative;
82
-
83
82
  overflow-x: auto;
84
-
85
83
  padding: 0 6px;
86
-
87
84
  white-space: nowrap;
88
85
 
89
86
  &::before {
@@ -1,17 +1,12 @@
1
1
  @use 'config';
2
2
  @use 'normalize';
3
-
4
3
  @use 'base';
5
-
6
4
  @use 'panel';
7
5
  @use 'emoji';
8
6
  @use 'gif';
9
-
10
7
  @use 'card';
11
8
  @use 'layout';
12
9
  @use 'reaction';
13
-
14
10
  @use 'highlight';
15
-
16
11
  @use 'recent';
17
12
  @use 'user-list';
@@ -49,6 +49,11 @@ export interface WalineCommentData {
49
49
  * Recaptcha Token
50
50
  */
51
51
  recaptchaV3?: string;
52
+
53
+ /**
54
+ * Turnstile Token
55
+ */
56
+ turnstile?: string;
52
57
  }
53
58
 
54
59
  export type WalineCommentStatus = 'approved' | 'waiting' | 'spam';
@@ -1,4 +1,4 @@
1
- import type { WalineProps } from './waline';
1
+ import { type WalineProps } from './waline.js';
2
2
 
3
3
  export interface WalineInitOptions extends Omit<WalineProps, 'path'> {
4
4
  /**
@@ -1,15 +1,15 @@
1
- import type {
2
- WalineCommentSorting,
3
- WalineHighlighter,
4
- WalineEmojiInfo,
5
- WalineEmojiPresets,
6
- WalineImageUploader,
7
- WalineLoginStatus,
8
- WalineMeta,
9
- WalineTexRenderer,
10
- WalineSearchOptions,
11
- } from './base';
12
- import type { WalineLocale } from './locale';
1
+ import {
2
+ type WalineCommentSorting,
3
+ type WalineHighlighter,
4
+ type WalineEmojiInfo,
5
+ type WalineEmojiPresets,
6
+ type WalineImageUploader,
7
+ type WalineLoginStatus,
8
+ type WalineMeta,
9
+ type WalineTexRenderer,
10
+ type WalineSearchOptions,
11
+ } from './base.js';
12
+ import { type WalineLocale } from './locale.js';
13
13
 
14
14
  export interface WalineProps {
15
15
  /**
@@ -239,6 +239,11 @@ export interface WalineProps {
239
239
  */
240
240
  recaptchaV3Key?: string;
241
241
 
242
+ /**
243
+ * turnstile client key
244
+ */
245
+ turnstileKey?: string;
246
+
242
247
  /**
243
248
  * reaction
244
249
  */
@@ -1,3 +1,4 @@
1
+ import { decodePath, isLinkHttp, removeEndingSplash } from './path.js';
1
2
  import {
2
3
  DEFAULT_EMOJI,
3
4
  DEFAULT_LANG,
@@ -8,16 +9,13 @@ import {
8
9
  defaultTexRenderer,
9
10
  getDefaultSearchOptions,
10
11
  getMeta,
11
- } from '../config';
12
-
13
- import { decodePath, isLinkHttp, removeEndingSplash } from './path';
14
-
15
- import type {
16
- WalineEmojiInfo,
17
- WalineEmojiMaps,
18
- WalineLocale,
19
- WalineProps,
20
- } from '../typings';
12
+ } from '../config/index.js';
13
+ import {
14
+ type WalineEmojiInfo,
15
+ type WalineEmojiMaps,
16
+ type WalineLocale,
17
+ type WalineProps,
18
+ } from '../typings/index.js';
21
19
 
22
20
  export interface WalineEmojiConfig {
23
21
  tabs: Pick<WalineEmojiInfo, 'name' | 'icon' | 'items'>[];
@@ -84,6 +82,7 @@ export const getConfig = ({
84
82
  search,
85
83
  reaction,
86
84
  recaptchaV3Key = '',
85
+ turnstileKey = '',
87
86
  commentSorting = 'latest',
88
87
  ...more
89
88
  }: WalineProps): WalineConfig => ({
@@ -112,6 +111,7 @@ export const getConfig = ({
112
111
  ? search
113
112
  : getDefaultSearchOptions(lang),
114
113
  recaptchaV3Key,
114
+ turnstileKey,
115
115
  reaction: Array.isArray(reaction)
116
116
  ? reaction
117
117
  : reaction === true
@@ -1,8 +1,8 @@
1
1
  import { useStorage } from '@vueuse/core';
2
- import { removeEndingSplash } from './path';
3
2
 
4
- import type { WalineEmojiConfig } from './config';
5
- import type { WalineEmojiInfo } from '../typings';
3
+ import { type WalineEmojiConfig } from './config.js';
4
+ import { removeEndingSplash } from './path.js';
5
+ import { type WalineEmojiInfo } from '../typings/index.js';
6
6
 
7
7
  const hasVersion = (url: string): boolean =>
8
8
  Boolean(/@[0-9]+\.[0-9]+\.[0-9]+/.test(url));
@@ -1,11 +1,12 @@
1
- export * from './config';
2
- export * from './darkmode';
3
- export * from './date';
4
- export * from './emoji';
5
- export * from './error';
6
- export * from './getRoot';
7
- export * from './image';
8
- export * from './markdown';
9
- export * from './path';
10
- export * from './query';
11
- export * from './wordCount';
1
+ export * from './config.js';
2
+ export * from './darkmode.js';
3
+ export * from './date.js';
4
+ export * from './emoji.js';
5
+ export * from './error.js';
6
+ export * from './getRoot.js';
7
+ export * from './image.js';
8
+ export * from './markdown.js';
9
+ export * from './path.js';
10
+ export * from './query.js';
11
+ export * from './wordCount.js';
12
+ export * from './userAgent.js';
@@ -1,11 +1,11 @@
1
1
  import { marked } from 'marked';
2
- import { markedTexExtensions } from './markedMathExtension';
3
2
 
4
- import type {
5
- WalineEmojiMaps,
6
- WalineHighlighter,
7
- WalineTexRenderer,
8
- } from '../typings';
3
+ import { markedTexExtensions } from './markedMathExtension.js';
4
+ import {
5
+ type WalineEmojiMaps,
6
+ type WalineHighlighter,
7
+ type WalineTexRenderer,
8
+ } from '../typings/index.js';
9
9
 
10
10
  export const parseEmoji = (text = '', emojiMap: WalineEmojiMaps = {}): string =>
11
11
  text.replace(/:(.+?):/g, (placeholder, key: string) =>
@@ -1,5 +1,6 @@
1
- import type { marked } from 'marked';
2
- import type { WalineTexRenderer } from '../typings';
1
+ import { type marked } from 'marked';
2
+
3
+ import { type WalineTexRenderer } from '../typings/index.js';
3
4
 
4
5
  const inlineMathStart = /\$.*?\$/;
5
6
  const inlineMathReg = /^\$(.*?)\$/;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="user-agent-data-types" />
2
2
 
3
- export const userAgent = async () => {
3
+ export const userAgent = async (): Promise<string> => {
4
4
  if (!navigator) {
5
5
  return '';
6
6
  }
@@ -26,6 +26,6 @@ export const getChinese = (content: string): RegExpMatchArray | null =>
26
26
  export const getWordNumber = (content: string): number =>
27
27
  (getWords(content)?.reduce<number>(
28
28
  (accumulator, word) =>
29
- accumulator + (word.trim() === "" ? 0 : word.trim().split(/\s+/u).length),
29
+ accumulator + (word.trim() === '' ? 0 : word.trim().split(/\s+/u).length),
30
30
  0
31
31
  ) || 0) + (getChinese(content)?.length || 0);
@@ -1,8 +1,7 @@
1
- import { getRecentComment } from '../api';
2
- import { useUserInfo } from '../composables';
3
- import { getRoot } from '../utils';
4
-
5
- import type { WalineComment } from '../typings';
1
+ import { getRecentComment } from '../api/index.js';
2
+ import { useUserInfo } from '../composables/index.js';
3
+ import { type WalineComment } from '../typings/index.js';
4
+ import { getRoot } from '../utils/index.js';
6
5
 
7
6
  export interface WalineRecentCommentsOptions {
8
7
  /**