@waline/client 2.15.5 → 2.15.7

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 +1 -1
  3. package/dist/api.d.mts +1 -1
  4. package/dist/api.d.ts +1 -1
  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.d.cts +1 -1
  9. package/dist/comment.d.mts +1 -1
  10. package/dist/comment.d.ts +1 -1
  11. package/dist/comment.js +1 -1
  12. package/dist/comment.js.map +1 -1
  13. package/dist/comment.mjs +1 -1
  14. package/dist/comment.mjs.map +1 -1
  15. package/dist/component.mjs +1 -1
  16. package/dist/component.mjs.map +1 -1
  17. package/dist/legacy.umd.d.ts +5 -5
  18. package/dist/legacy.umd.js +1 -1
  19. package/dist/legacy.umd.js.map +1 -1
  20. package/dist/pageview.cjs +1 -1
  21. package/dist/pageview.cjs.map +1 -1
  22. package/dist/pageview.d.cts +1 -1
  23. package/dist/pageview.d.mts +1 -1
  24. package/dist/pageview.d.ts +1 -1
  25. package/dist/pageview.js +1 -1
  26. package/dist/pageview.js.map +1 -1
  27. package/dist/pageview.mjs +1 -1
  28. package/dist/pageview.mjs.map +1 -1
  29. package/dist/shim.cjs +1 -1
  30. package/dist/shim.cjs.map +1 -1
  31. package/dist/shim.d.cts +3 -3
  32. package/dist/shim.d.mts +3 -3
  33. package/dist/shim.mjs +1 -1
  34. package/dist/shim.mjs.map +1 -1
  35. package/dist/waline.cjs +1 -1
  36. package/dist/waline.cjs.map +1 -1
  37. package/dist/waline.css.map +1 -1
  38. package/dist/waline.d.cts +3 -3
  39. package/dist/waline.d.mts +3 -3
  40. package/dist/waline.d.ts +3 -3
  41. package/dist/waline.js +1 -1
  42. package/dist/waline.js.map +1 -1
  43. package/dist/waline.mjs +1 -1
  44. package/dist/waline.mjs.map +1 -1
  45. package/package.json +13 -11
  46. package/src/api/articleCounter.ts +2 -2
  47. package/src/api/comment.ts +2 -2
  48. package/src/api/commentCount.ts +2 -2
  49. package/src/api/login.ts +1 -1
  50. package/src/api/pageview.ts +1 -1
  51. package/src/api/utils.ts +1 -1
  52. package/src/comment.ts +1 -1
  53. package/src/compact/convert.ts +9 -8
  54. package/src/compact/logger.ts +1 -1
  55. package/src/compact/v1.ts +3 -3
  56. package/src/compact/valine.ts +1 -1
  57. package/src/components/ArticleReaction.vue +12 -5
  58. package/src/components/CommentBox.vue +10 -11
  59. package/src/components/CommentCard.vue +6 -6
  60. package/src/components/Icons.ts +10 -10
  61. package/src/components/ImageWall.vue +5 -5
  62. package/src/components/WalineComment.vue +8 -8
  63. package/src/composables/turnstile.ts +22 -24
  64. package/src/composables/userInfo.ts +1 -1
  65. package/src/config/default.ts +6 -6
  66. package/src/config/highlighter.ts +1 -1
  67. package/src/config/i18n/generate.ts +1 -1
  68. package/src/entries/legacy.ts +4 -2
  69. package/src/pageview.ts +4 -4
  70. package/src/styles/emoji.scss +3 -1
  71. package/src/styles/gif.scss +3 -1
  72. package/src/typings/base.ts +1 -1
  73. package/src/typings/waline.ts +2 -2
  74. package/src/utils/config.ts +4 -4
  75. package/src/utils/date.ts +1 -1
  76. package/src/utils/emoji.ts +4 -4
  77. package/src/utils/getRoot.ts +1 -1
  78. package/src/utils/image.ts +1 -1
  79. package/src/utils/markdown.ts +6 -6
  80. package/src/utils/markedMathExtension.ts +3 -3
  81. package/src/utils/wordCount.ts +1 -1
  82. package/src/widgets/recentComments.ts +1 -1
  83. package/src/widgets/userList.ts +1 -1
@@ -39,10 +39,10 @@ export const defaultUploadImage = (file: File): Promise<string> =>
39
39
  reader.onerror = reject;
40
40
  });
41
41
 
42
- export const defaultTexRenderer = (blockMode: boolean): string =>
42
+ export const defaultTeXRenderer = (blockMode: boolean): string =>
43
43
  blockMode === true
44
- ? '<p class="wl-tex">Tex is not available in preview</p>'
45
- : '<span class="wl-tex">Tex is not available in preview</span>';
44
+ ? '<p class="wl-tex">TeX is not available in preview</p>'
45
+ : '<span class="wl-tex">TeX is not available in preview</span>';
46
46
 
47
47
  export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
48
48
  interface GifResult {
@@ -63,7 +63,7 @@ export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
63
63
 
64
64
  const fetchGiphy = async (
65
65
  url: string,
66
- params: Record<string, string> = {}
66
+ params: Record<string, string> = {},
67
67
  ): Promise<WalineSearchResult> =>
68
68
  fetch(
69
69
  `https://api.giphy.com/v1/gifs/${url}?${new URLSearchParams({
@@ -73,14 +73,14 @@ export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
73
73
  // eslint-disable-next-line @typescript-eslint/naming-convention
74
74
  api_key: '6CIMLkNMMOhRcXPoMCPkFy4Ybk2XUiMp',
75
75
  ...params,
76
- }).toString()}`
76
+ }).toString()}`,
77
77
  )
78
78
  .then((resp) => <Promise<GifResult>>resp.json())
79
79
  .then(({ data }) =>
80
80
  data.map((gif) => ({
81
81
  title: gif.title,
82
82
  src: gif.images.downsized_medium.url,
83
- }))
83
+ })),
84
84
  );
85
85
 
86
86
  return {
@@ -30,7 +30,7 @@ const LINE_COMMENT_REGEXP = /(?:^|\s)\/\/(.+?)$/gm;
30
30
  const BLOCK_COMMENT_REGEXP = /\/\*([\S\s]*?)\*\//gm;
31
31
  const REGEXP = new RegExp(
32
32
  `(${WORD_REGEXP.source}|${LEFT_ANGLE_REGEXP.source})|((?:${LINE_COMMENT_REGEXP.source})|(?:${BLOCK_COMMENT_REGEXP.source}))`,
33
- 'gmi'
33
+ 'gmi',
34
34
  );
35
35
 
36
36
  const COLORS = [
@@ -54,5 +54,5 @@ const localeKeys = [
54
54
 
55
55
  export const generateLocale = (locale: string[]): WalineLocale =>
56
56
  Object.fromEntries(
57
- locale.map((item, index) => [localeKeys[index], item])
57
+ locale.map((item, index) => [localeKeys[index], item]),
58
58
  ) as unknown as WalineLocale;
@@ -10,7 +10,7 @@ import { type WalineInitOptions } from '../typings/index.js';
10
10
  export { WalineInstance } from '../init.js';
11
11
 
12
12
  warning(
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!'
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!',
14
14
  );
15
15
 
16
16
  // inject css styles
@@ -23,7 +23,9 @@ link.href = '//unpkg.com/@waline/client@v2/dist/waline.css';
23
23
  document.head.appendChild(link);
24
24
 
25
25
  export default function legacyWaline(
26
- options: WalineInitOptions & DeprecatedValineOptions & DeprecatedWalineOptions
26
+ options: WalineInitOptions &
27
+ DeprecatedValineOptions &
28
+ DeprecatedWalineOptions,
27
29
  ): WalineInstance | null {
28
30
  return init(covertOptions(options));
29
31
  }
package/src/pageview.ts CHANGED
@@ -49,7 +49,7 @@ export interface WalinePageviewCountOptions {
49
49
 
50
50
  const renderVisitorCount = (
51
51
  counts: number[],
52
- countElements: HTMLElement[]
52
+ countElements: HTMLElement[],
53
53
  ): void => {
54
54
  countElements.forEach((element, index) => {
55
55
  element.innerText = counts[index].toString();
@@ -67,7 +67,7 @@ export const pageviewCount = ({
67
67
 
68
68
  const elements = Array.from(
69
69
  // pageview selectors
70
- document.querySelectorAll<HTMLElement>(selector)
70
+ document.querySelectorAll<HTMLElement>(selector),
71
71
  );
72
72
 
73
73
  const filter = (element: HTMLElement): boolean => {
@@ -98,8 +98,8 @@ export const pageviewCount = ({
98
98
  }).then((count) =>
99
99
  renderVisitorCount(
100
100
  new Array<number>(normalElements.length).fill(count),
101
- normalElements
102
- )
101
+ normalElements,
102
+ ),
103
103
  );
104
104
 
105
105
  // if we should fetch count of other pages
@@ -14,7 +14,9 @@
14
14
  opacity: 0;
15
15
  visibility: hidden;
16
16
 
17
- transition: transform 0.2s ease-out, opacity 0.2s ease-out;
17
+ transition:
18
+ transform 0.2s ease-out,
19
+ opacity 0.2s ease-out;
18
20
  transform: scale(0.9, 0.9);
19
21
  transform-origin: 0 0;
20
22
 
@@ -15,7 +15,9 @@
15
15
  opacity: 0;
16
16
  visibility: hidden;
17
17
 
18
- transition: transform 0.2s ease-out, opacity 0.2s ease-out;
18
+ transition:
19
+ transform 0.2s ease-out,
20
+ opacity 0.2s ease-out;
19
21
  transform: scale(0.9, 0.9);
20
22
  transform-origin: 0 0;
21
23
 
@@ -120,4 +120,4 @@ export type WalineImageUploader = (image: File) => Promise<string>;
120
120
 
121
121
  export type WalineHighlighter = (code: string, lang: string) => string;
122
122
 
123
- export type WalineTexRenderer = (blockMode: boolean, tex: string) => string;
123
+ export type WalineTeXRenderer = (blockMode: boolean, tex: string) => string;
@@ -6,7 +6,7 @@ import {
6
6
  type WalineImageUploader,
7
7
  type WalineLoginStatus,
8
8
  type WalineMeta,
9
- type WalineTexRenderer,
9
+ type WalineTeXRenderer,
10
10
  type WalineSearchOptions,
11
11
  } from './base.js';
12
12
  import { type WalineLocale } from './locale.js';
@@ -201,7 +201,7 @@ export interface WalineProps {
201
201
  *
202
202
  * @default true
203
203
  */
204
- texRenderer?: WalineTexRenderer | boolean;
204
+ texRenderer?: WalineTeXRenderer | boolean;
205
205
 
206
206
  /**
207
207
  *
@@ -6,7 +6,7 @@ import {
6
6
  DEFAULT_REACTION,
7
7
  defaultUploadImage,
8
8
  defaultHighlighter,
9
- defaultTexRenderer,
9
+ defaultTeXRenderer,
10
10
  getDefaultSearchOptions,
11
11
  getMeta,
12
12
  } from '../config/index.js';
@@ -52,13 +52,13 @@ export const getServerURL = (serverURL: string): string => {
52
52
  };
53
53
 
54
54
  const getWordLimit = (
55
- wordLimit: WalineProps['wordLimit']
55
+ wordLimit: WalineProps['wordLimit'],
56
56
  ): [number, number] | false =>
57
57
  Array.isArray(wordLimit) ? wordLimit : wordLimit ? [0, wordLimit] : false;
58
58
 
59
59
  const fallback = <T = unknown>(
60
60
  value: T | boolean | undefined,
61
- fallback: T
61
+ fallback: T,
62
62
  ): T | false =>
63
63
  typeof value === 'function' ? value : value === false ? false : fallback;
64
64
 
@@ -97,7 +97,7 @@ export const getConfig = ({
97
97
  requiredMeta: getMeta(requiredMeta),
98
98
  imageUploader: fallback(imageUploader, defaultUploadImage),
99
99
  highlighter: fallback(highlighter, defaultHighlighter),
100
- texRenderer: fallback(texRenderer, defaultTexRenderer),
100
+ texRenderer: fallback(texRenderer, defaultTeXRenderer),
101
101
  lang: Object.keys(DEFAULT_LOCALES).includes(lang) ? lang : 'en-US',
102
102
  dark,
103
103
  emoji: typeof emoji === 'boolean' ? (emoji ? DEFAULT_EMOJI : []) : emoji,
package/src/utils/date.ts CHANGED
@@ -21,7 +21,7 @@ export const dateFormat = (date: Date): string => {
21
21
  export const getTimeAgo = (
22
22
  date: Date | string,
23
23
  now: Date,
24
- locale: WalineDateLocale
24
+ locale: WalineDateLocale,
25
25
  ): string => {
26
26
  if (!date) return '';
27
27
 
@@ -10,7 +10,7 @@ const hasVersion = (url: string): boolean =>
10
10
  const fetchEmoji = (link: string): Promise<WalineEmojiInfo> => {
11
11
  const emojiStore = useStorage<Record<string, WalineEmojiInfo>>(
12
12
  'WALINE_EMOJI',
13
- {}
13
+ {},
14
14
  );
15
15
 
16
16
  const result = hasVersion(link);
@@ -39,14 +39,14 @@ const getLink = (name: string, folder = '', prefix = '', type = ''): string =>
39
39
  `${folder ? `${folder}/` : ''}${prefix}${name}${type ? `.${type}` : ''}`;
40
40
 
41
41
  export const getEmojis = (
42
- emojis: (string | WalineEmojiInfo)[]
42
+ emojis: (string | WalineEmojiInfo)[],
43
43
  ): Promise<WalineEmojiConfig> =>
44
44
  Promise.all(
45
45
  emojis.map((emoji) =>
46
46
  typeof emoji === 'string'
47
47
  ? fetchEmoji(removeEndingSplash(emoji))
48
- : Promise.resolve(emoji)
49
- )
48
+ : Promise.resolve(emoji),
49
+ ),
50
50
  ).then((emojiInfos) => {
51
51
  const emojiConfig: WalineEmojiConfig = {
52
52
  tabs: [],
@@ -1,5 +1,5 @@
1
1
  export const getRoot = (
2
- el: string | HTMLElement | undefined
2
+ el: string | HTMLElement | undefined,
3
3
  ): HTMLElement | null =>
4
4
  el instanceof HTMLElement
5
5
  ? el
@@ -2,7 +2,7 @@ const isImage = (item: DataTransferItem): boolean =>
2
2
  item.type.includes('image');
3
3
 
4
4
  export const getImageFromDataTransfer = (
5
- items: DataTransferItemList
5
+ items: DataTransferItemList,
6
6
  ): File | null => {
7
7
  const image = Array.from(items).find(isImage);
8
8
 
@@ -1,28 +1,28 @@
1
1
  import { marked } from 'marked';
2
2
 
3
- import { markedTexExtensions } from './markedMathExtension.js';
3
+ import { markedTeXExtensions } from './markedMathExtension.js';
4
4
  import {
5
5
  type WalineEmojiMaps,
6
6
  type WalineHighlighter,
7
- type WalineTexRenderer,
7
+ type WalineTeXRenderer,
8
8
  } from '../typings/index.js';
9
9
 
10
10
  export const parseEmoji = (text = '', emojiMap: WalineEmojiMaps = {}): string =>
11
11
  text.replace(/:(.+?):/g, (placeholder, key: string) =>
12
12
  emojiMap[key]
13
13
  ? `<img class="wl-emoji" src="${emojiMap[key]}" alt="${key}">`
14
- : placeholder
14
+ : placeholder,
15
15
  );
16
16
 
17
17
  export interface ParseMarkdownOptions {
18
18
  emojiMap: WalineEmojiMaps;
19
19
  highlighter: WalineHighlighter | false;
20
- texRenderer: WalineTexRenderer | false;
20
+ texRenderer: WalineTeXRenderer | false;
21
21
  }
22
22
 
23
23
  export const parseMarkdown = (
24
24
  content: string,
25
- { emojiMap, highlighter, texRenderer }: ParseMarkdownOptions
25
+ { emojiMap, highlighter, texRenderer }: ParseMarkdownOptions,
26
26
  ): string => {
27
27
  marked.setOptions({
28
28
  highlight: highlighter || undefined,
@@ -32,7 +32,7 @@ export const parseMarkdown = (
32
32
  });
33
33
 
34
34
  if (texRenderer) {
35
- const extensions = markedTexExtensions(texRenderer);
35
+ const extensions = markedTeXExtensions(texRenderer);
36
36
 
37
37
  marked.use({ extensions });
38
38
  }
@@ -1,13 +1,13 @@
1
1
  import { type marked } from 'marked';
2
2
 
3
- import { type WalineTexRenderer } from '../typings/index.js';
3
+ import { type WalineTeXRenderer } from '../typings/index.js';
4
4
 
5
5
  const inlineMathStart = /\$.*?\$/;
6
6
  const inlineMathReg = /^\$(.*?)\$/;
7
7
  const blockMathReg = /^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/;
8
8
 
9
- export const markedTexExtensions = (
10
- texRenderer: WalineTexRenderer
9
+ export const markedTeXExtensions = (
10
+ texRenderer: WalineTeXRenderer,
11
11
  ): marked.TokenizerExtension[] => {
12
12
  const blockMathExtension: marked.TokenizerExtension = {
13
13
  name: 'blockMath',
@@ -27,5 +27,5 @@ export const getWordNumber = (content: string): number =>
27
27
  (getWords(content)?.reduce<number>(
28
28
  (accumulator, word) =>
29
29
  accumulator + (word.trim() === '' ? 0 : word.trim().split(/\s+/u).length),
30
- 0
30
+ 0,
31
31
  ) || 0) + (getChinese(content)?.length || 0);
@@ -72,7 +72,7 @@ export const RecentComments = ({
72
72
  root.innerHTML = `<ul class="wl-recent-list">${comments
73
73
  .map(
74
74
  (comment) =>
75
- `<li class="wl-recent-item"><a href="${comment.url}">${comment.nick}</a>:${comment.comment}</li>`
75
+ `<li class="wl-recent-item"><a href="${comment.url}">${comment.nick}</a>:${comment.comment}</li>`,
76
76
  )
77
77
  .join('')}</ul>`;
78
78
 
@@ -121,7 +121,7 @@ export const UserList = ({
121
121
  '</li>',
122
122
  ]
123
123
  .filter((v) => v)
124
- .join('')
124
+ .join(''),
125
125
  )
126
126
  .join('')}</ul>`;
127
127