@waline/client 2.14.7 → 2.14.9
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/LICENSE +21 -339
- package/dist/comment.cjs +1 -1
- package/dist/comment.cjs.map +1 -1
- package/dist/comment.js +1 -1
- package/dist/comment.js.map +1 -1
- package/dist/comment.mjs +1 -1
- package/dist/comment.mjs.map +1 -1
- package/dist/component.mjs +1 -1
- package/dist/component.mjs.map +1 -1
- package/dist/legacy.umd.js +1 -1
- package/dist/legacy.umd.js.map +1 -1
- package/dist/pageview.cjs +1 -1
- package/dist/pageview.cjs.map +1 -1
- package/dist/pageview.js +1 -1
- package/dist/pageview.js.map +1 -1
- package/dist/pageview.mjs +1 -1
- package/dist/pageview.mjs.map +1 -1
- package/dist/shim.cjs +1 -1
- package/dist/shim.cjs.map +1 -1
- package/dist/shim.d.cts +2 -2
- package/dist/shim.d.mts +2 -2
- package/dist/shim.mjs +1 -1
- package/dist/shim.mjs.map +1 -1
- package/dist/waline.cjs +1 -1
- package/dist/waline.cjs.map +1 -1
- package/dist/waline.css +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.d.cts +2 -2
- package/dist/waline.d.mts +2 -2
- package/dist/waline.d.ts +2 -2
- package/dist/waline.js +1 -1
- package/dist/waline.js.map +1 -1
- package/dist/waline.mjs +1 -1
- package/dist/waline.mjs.map +1 -1
- package/package.json +15 -14
- package/src/components/CommentBox.vue +9 -7
- package/src/config/default.ts +15 -15
- package/src/config/i18n/index.ts +1 -1
- package/src/entries/full.ts +1 -1
- package/src/entries/init.ts +1 -1
- package/src/styles/card.scss +18 -16
- package/src/utils/config.ts +9 -9
- package/src/utils/userAgent.ts +31 -0
- package/src/utils/wordCount.ts +19 -8
- package/src/widgets/userList.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/client",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.9",
|
|
4
4
|
"description": "client for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"valine",
|
|
@@ -109,30 +109,31 @@
|
|
|
109
109
|
]
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@vueuse/core": "^9.
|
|
113
|
-
"autosize": "^
|
|
114
|
-
"marked": "^4.2.
|
|
115
|
-
"vue": "^3.2.
|
|
112
|
+
"@vueuse/core": "^9.13.0",
|
|
113
|
+
"autosize": "^6.0.1",
|
|
114
|
+
"marked": "^4.2.12",
|
|
115
|
+
"vue": "^3.2.47"
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
|
-
"@babel/core": "7.
|
|
118
|
+
"@babel/core": "7.21.3",
|
|
119
119
|
"@babel/preset-env": "7.20.2",
|
|
120
120
|
"@giphy/js-types": "4.4.0",
|
|
121
121
|
"@rollup/plugin-babel": "6.0.3",
|
|
122
|
-
"@rollup/plugin-commonjs": "24.0.
|
|
122
|
+
"@rollup/plugin-commonjs": "24.0.1",
|
|
123
123
|
"@rollup/plugin-node-resolve": "15.0.1",
|
|
124
124
|
"@rollup/plugin-replace": "5.0.2",
|
|
125
|
-
"@rollup/plugin-terser": "0.
|
|
125
|
+
"@rollup/plugin-terser": "0.4.0",
|
|
126
126
|
"@types/autosize": "4.0.1",
|
|
127
127
|
"@types/marked": "4.0.8",
|
|
128
|
-
"@types/node": "18.
|
|
128
|
+
"@types/node": "18.15.3",
|
|
129
129
|
"@vitejs/plugin-vue": "4.0.0",
|
|
130
130
|
"recaptcha-v3": "1.10.0",
|
|
131
|
-
"rollup": "3.
|
|
132
|
-
"rollup-plugin-dts": "5.
|
|
133
|
-
"rollup-plugin-ts": "3.
|
|
134
|
-
"typescript": "4.9.
|
|
135
|
-
"
|
|
131
|
+
"rollup": "3.19.1",
|
|
132
|
+
"rollup-plugin-dts": "5.2.0",
|
|
133
|
+
"rollup-plugin-ts": "3.2.0",
|
|
134
|
+
"typescript": "4.9.5",
|
|
135
|
+
"user-agent-data-types": "^0.3.1",
|
|
136
|
+
"vite": "4.1.4"
|
|
136
137
|
},
|
|
137
138
|
"engines": {
|
|
138
139
|
"node": ">=14"
|
|
@@ -329,6 +329,7 @@ import type {
|
|
|
329
329
|
WalineSearchResult,
|
|
330
330
|
} from '../typings/index.js';
|
|
331
331
|
import type { WalineConfig, WalineEmojiConfig } from '../utils/index.js';
|
|
332
|
+
import { userAgent } from '../utils/userAgent';
|
|
332
333
|
|
|
333
334
|
const props = withDefaults(
|
|
334
335
|
defineProps<{
|
|
@@ -488,14 +489,15 @@ const submitComment = async (): Promise<void> => {
|
|
|
488
489
|
if (config.value.recaptchaV3Key)
|
|
489
490
|
token = await useReCaptcha(config.value.recaptchaV3Key).execute('social');
|
|
490
491
|
|
|
492
|
+
const ua = await userAgent();
|
|
491
493
|
const comment: WalineCommentData = {
|
|
492
494
|
comment: content.value,
|
|
493
495
|
nick: userMeta.value.nick,
|
|
494
496
|
mail: userMeta.value.mail,
|
|
495
497
|
link: userMeta.value.link,
|
|
496
|
-
ua: navigator.userAgent,
|
|
497
498
|
url: config.value.path,
|
|
498
499
|
recaptchaV3: token,
|
|
500
|
+
ua,
|
|
499
501
|
};
|
|
500
502
|
|
|
501
503
|
if (userInfo.value?.token) {
|
|
@@ -525,14 +527,14 @@ const submitComment = async (): Promise<void> => {
|
|
|
525
527
|
return alert(locale.value.mailError);
|
|
526
528
|
}
|
|
527
529
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
editorRef.value?.focus();
|
|
530
|
+
if (!comment.nick) comment.nick = locale.value.anonymous;
|
|
531
|
+
}
|
|
531
532
|
|
|
532
|
-
|
|
533
|
-
|
|
533
|
+
// check comment
|
|
534
|
+
if (!comment.comment) {
|
|
535
|
+
editorRef.value?.focus();
|
|
534
536
|
|
|
535
|
-
|
|
537
|
+
return;
|
|
536
538
|
}
|
|
537
539
|
|
|
538
540
|
if (!isWordNumberLegal.value)
|
package/src/config/default.ts
CHANGED
|
@@ -6,16 +6,25 @@ import type {
|
|
|
6
6
|
WalineSearchResult,
|
|
7
7
|
} from '../typings';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const AVAILABLE_META: WalineMeta[] = ['nick', 'mail', 'link'];
|
|
10
10
|
|
|
11
11
|
export const getMeta = (meta: WalineMeta[]): WalineMeta[] =>
|
|
12
|
-
meta.filter((item) =>
|
|
12
|
+
meta.filter((item) => AVAILABLE_META.includes(item));
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const DEFAULT_EMOJI: WalineEmojiPresets[] = [
|
|
15
15
|
'//unpkg.com/@waline/emojis@1.1.0/weibo',
|
|
16
16
|
];
|
|
17
17
|
|
|
18
|
-
export const
|
|
18
|
+
export const DEFAULT_LANG = 'en-US';
|
|
19
|
+
|
|
20
|
+
export const DEFAULT_REACTION = [
|
|
21
|
+
'//unpkg.com/@waline/emojis/tieba/tieba_agree.png',
|
|
22
|
+
'//unpkg.com/@waline/emojis/tieba/tieba_look_down.png',
|
|
23
|
+
'//unpkg.com/@waline/emojis/tieba/tieba_sunglasses.png',
|
|
24
|
+
'//unpkg.com/@waline/emojis/tieba/tieba_pick_nose.png',
|
|
25
|
+
'//unpkg.com/@waline/emojis/tieba/tieba_awkward.png',
|
|
26
|
+
'//unpkg.com/@waline/emojis/tieba/tieba_sleep.png',
|
|
27
|
+
];
|
|
19
28
|
|
|
20
29
|
export const defaultUploadImage = (file: File): Promise<string> =>
|
|
21
30
|
new Promise((resolve, reject) => {
|
|
@@ -35,7 +44,7 @@ export const defaultTexRenderer = (blockMode: boolean): string =>
|
|
|
35
44
|
: '<span class="wl-tex">Tex is not available in preview</span>';
|
|
36
45
|
|
|
37
46
|
export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
|
|
38
|
-
interface
|
|
47
|
+
interface GifResult {
|
|
39
48
|
data: IGif[];
|
|
40
49
|
meta: {
|
|
41
50
|
msg: string;
|
|
@@ -65,7 +74,7 @@ export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
|
|
|
65
74
|
...params,
|
|
66
75
|
}).toString()}`
|
|
67
76
|
)
|
|
68
|
-
.then((resp) => <Promise<
|
|
77
|
+
.then((resp) => <Promise<GifResult>>resp.json())
|
|
69
78
|
.then(({ data }) =>
|
|
70
79
|
data.map((gif) => ({
|
|
71
80
|
title: gif.title,
|
|
@@ -81,12 +90,3 @@ export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
|
|
|
81
90
|
fetchGiphy('search', { q: word, offset: offset.toString() }),
|
|
82
91
|
};
|
|
83
92
|
};
|
|
84
|
-
|
|
85
|
-
export const defaultReaction = [
|
|
86
|
-
'//unpkg.com/@waline/emojis/tieba/tieba_agree.png',
|
|
87
|
-
'//unpkg.com/@waline/emojis/tieba/tieba_look_down.png',
|
|
88
|
-
'//unpkg.com/@waline/emojis/tieba/tieba_sunglasses.png',
|
|
89
|
-
'//unpkg.com/@waline/emojis/tieba/tieba_pick_nose.png',
|
|
90
|
-
'//unpkg.com/@waline/emojis/tieba/tieba_awkward.png',
|
|
91
|
-
'//unpkg.com/@waline/emojis/tieba/tieba_sleep.png',
|
|
92
|
-
];
|
package/src/config/i18n/index.ts
CHANGED
package/src/entries/full.ts
CHANGED
package/src/entries/init.ts
CHANGED
package/src/styles/card.scss
CHANGED
|
@@ -49,32 +49,34 @@
|
|
|
49
49
|
margin-inline-start: 1em;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.wl-card-item:last-child & {
|
|
52
|
+
.wl-card-item:last-child > & {
|
|
53
53
|
border-bottom: none;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
.wl-nick {
|
|
57
|
+
svg {
|
|
58
|
+
position: relative;
|
|
59
|
+
bottom: -0.125em;
|
|
60
|
+
line-height: 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
56
64
|
.wl-head {
|
|
57
65
|
// bfc to fix https://github.com/walinejs/waline/issues/1415
|
|
58
66
|
overflow: hidden;
|
|
59
67
|
line-height: 1.5;
|
|
60
|
-
}
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
position: relative;
|
|
64
|
-
|
|
65
|
-
display: inline-block;
|
|
66
|
-
|
|
67
|
-
margin-inline-end: 0.5em;
|
|
68
|
-
|
|
69
|
-
font-weight: bold;
|
|
70
|
-
font-size: 0.875em;
|
|
71
|
-
line-height: 1;
|
|
72
|
-
text-decoration: none;
|
|
73
|
-
|
|
74
|
-
svg {
|
|
69
|
+
.wl-nick {
|
|
75
70
|
position: relative;
|
|
76
|
-
|
|
71
|
+
|
|
72
|
+
display: inline-block;
|
|
73
|
+
|
|
74
|
+
margin-inline-end: 0.5em;
|
|
75
|
+
|
|
76
|
+
font-weight: bold;
|
|
77
|
+
font-size: 0.875em;
|
|
77
78
|
line-height: 1;
|
|
79
|
+
text-decoration: none;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
|
package/src/utils/config.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
DEFAULT_EMOJI,
|
|
3
|
+
DEFAULT_LANG,
|
|
4
|
+
DEFAULT_LOCALES,
|
|
5
|
+
DEFAULT_REACTION,
|
|
6
6
|
defaultUploadImage,
|
|
7
7
|
defaultHighlighter,
|
|
8
8
|
defaultTexRenderer,
|
|
@@ -70,7 +70,7 @@ export const getConfig = ({
|
|
|
70
70
|
path = location.pathname,
|
|
71
71
|
lang = typeof navigator === 'undefined' ? 'en-US' : navigator.language,
|
|
72
72
|
locale,
|
|
73
|
-
emoji =
|
|
73
|
+
emoji = DEFAULT_EMOJI,
|
|
74
74
|
meta = ['nick', 'mail', 'link'],
|
|
75
75
|
requiredMeta = [],
|
|
76
76
|
dark = false,
|
|
@@ -90,7 +90,7 @@ export const getConfig = ({
|
|
|
90
90
|
serverURL: getServerURL(serverURL),
|
|
91
91
|
path: decodePath(path),
|
|
92
92
|
locale: {
|
|
93
|
-
...(
|
|
93
|
+
...(DEFAULT_LOCALES[lang] || DEFAULT_LOCALES[DEFAULT_LANG]),
|
|
94
94
|
...(typeof locale === 'object' ? locale : {}),
|
|
95
95
|
} as WalineLocale,
|
|
96
96
|
wordLimit: getWordLimit(wordLimit),
|
|
@@ -99,9 +99,9 @@ export const getConfig = ({
|
|
|
99
99
|
imageUploader: fallback(imageUploader, defaultUploadImage),
|
|
100
100
|
highlighter: fallback(highlighter, defaultHighlighter),
|
|
101
101
|
texRenderer: fallback(texRenderer, defaultTexRenderer),
|
|
102
|
-
lang: Object.keys(
|
|
102
|
+
lang: Object.keys(DEFAULT_LOCALES).includes(lang) ? lang : 'en-US',
|
|
103
103
|
dark,
|
|
104
|
-
emoji: typeof emoji === 'boolean' ? (emoji ?
|
|
104
|
+
emoji: typeof emoji === 'boolean' ? (emoji ? DEFAULT_EMOJI : []) : emoji,
|
|
105
105
|
pageSize,
|
|
106
106
|
login,
|
|
107
107
|
copyright,
|
|
@@ -115,7 +115,7 @@ export const getConfig = ({
|
|
|
115
115
|
reaction: Array.isArray(reaction)
|
|
116
116
|
? reaction
|
|
117
117
|
: reaction === true
|
|
118
|
-
?
|
|
118
|
+
? DEFAULT_REACTION
|
|
119
119
|
: [],
|
|
120
120
|
commentSorting,
|
|
121
121
|
...more,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="user-agent-data-types" />
|
|
2
|
+
|
|
3
|
+
export const userAgent = async () => {
|
|
4
|
+
if (!navigator) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { userAgentData } = navigator;
|
|
9
|
+
let ua = navigator.userAgent;
|
|
10
|
+
|
|
11
|
+
// https://learn.microsoft.com/en-us/microsoft-edge/web-platform/how-to-detect-win11
|
|
12
|
+
if (!userAgentData || userAgentData.platform !== 'Windows') {
|
|
13
|
+
return ua;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { platformVersion } = await userAgentData.getHighEntropyValues([
|
|
17
|
+
'platformVersion',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
if (!platformVersion) {
|
|
21
|
+
return ua;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const isWindows11Later = parseInt(platformVersion.split('.')[0]) >= 13;
|
|
25
|
+
|
|
26
|
+
if (isWindows11Later) {
|
|
27
|
+
ua = ua.replace('Windows NT 10.0', 'Windows NT 11.0');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return ua;
|
|
31
|
+
};
|
package/src/utils/wordCount.ts
CHANGED
|
@@ -3,18 +3,29 @@
|
|
|
3
3
|
*
|
|
4
4
|
* So We just make a simple implement here
|
|
5
5
|
*
|
|
6
|
-
* Forked from https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/main/packages/reading-time2/src/node/
|
|
6
|
+
* Forked from https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/main/packages/reading-time2/src/node/readingTime.ts
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Extract Latin words from content
|
|
11
|
+
*/
|
|
12
|
+
export const getWords = (content: string): RegExpMatchArray | null =>
|
|
13
|
+
// \u00C0-\u024F are Latin Supplement letters, maybe used in language like french
|
|
14
|
+
// \u0400-\u04FF are Cyrillic letters, used in russian
|
|
15
|
+
content.match(/[\w\d\s,.\u00C0-\u024F\u0400-\u04FF]+/giu);
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Extract Chinese Characters from content
|
|
19
|
+
*/
|
|
20
|
+
export const getChinese = (content: string): RegExpMatchArray | null =>
|
|
21
|
+
content.match(/[\u4E00-\u9FD5]/gu);
|
|
14
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Get word number of given string
|
|
25
|
+
*/
|
|
15
26
|
export const getWordNumber = (content: string): number =>
|
|
16
|
-
getWords(content)
|
|
27
|
+
(getWords(content)?.reduce<number>(
|
|
17
28
|
(accumulator, word) =>
|
|
18
|
-
accumulator + (word.trim() ===
|
|
29
|
+
accumulator + (word.trim() === "" ? 0 : word.trim().split(/\s+/u).length),
|
|
19
30
|
0
|
|
20
|
-
) + getChinese(content)
|
|
31
|
+
) || 0) + (getChinese(content)?.length || 0);
|
package/src/widgets/userList.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getUserList, WalineUser } from '../api';
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_LANG, DEFAULT_LOCALES } from '../config';
|
|
3
3
|
import { WalineLocale } from '../typings';
|
|
4
4
|
import { getRoot } from '../utils';
|
|
5
5
|
|
|
@@ -93,7 +93,7 @@ export const UserList = ({
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
locale = {
|
|
96
|
-
...(
|
|
96
|
+
...(DEFAULT_LOCALES[lang] || DEFAULT_LOCALES[DEFAULT_LANG]),
|
|
97
97
|
...(typeof locale === 'object' ? locale : {}),
|
|
98
98
|
} as WalineLocale;
|
|
99
99
|
|