@waline/client 2.14.7 → 2.14.8
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.js +1 -1
- package/dist/pageview.js.map +1 -1
- package/dist/pageview.mjs +1 -1
- package/dist/shim.cjs +1 -1
- package/dist/shim.cjs.map +1 -1
- 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.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 +26 -24
- package/src/components/CommentBox.vue +3 -1
- package/src/utils/userAgent.ts +31 -0
- package/src/utils/wordCount.ts +19 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/client",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.8",
|
|
4
4
|
"description": "client for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"valine",
|
|
@@ -93,6 +93,16 @@
|
|
|
93
93
|
"dist",
|
|
94
94
|
"src"
|
|
95
95
|
],
|
|
96
|
+
"scripts": {
|
|
97
|
+
"build": "pnpm rollup && pnpm style",
|
|
98
|
+
"clean": "rimraf ./dist",
|
|
99
|
+
"dev": "vite",
|
|
100
|
+
"prepublishOnly": "pnpm clean && pnpm build",
|
|
101
|
+
"rollup": "rollup -c",
|
|
102
|
+
"style": "pnpm style:main && pnpm style:meta",
|
|
103
|
+
"style:main": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed",
|
|
104
|
+
"style:meta": "sass ./src/styles/meta.scss ./dist/waline-meta.css --style=compressed"
|
|
105
|
+
},
|
|
96
106
|
"browserslist": {
|
|
97
107
|
"production": [
|
|
98
108
|
">0.5%",
|
|
@@ -109,41 +119,33 @@
|
|
|
109
119
|
]
|
|
110
120
|
},
|
|
111
121
|
"dependencies": {
|
|
112
|
-
"@vueuse/core": "^9.
|
|
113
|
-
"autosize": "^
|
|
114
|
-
"marked": "^4.2.
|
|
115
|
-
"
|
|
122
|
+
"@vueuse/core": "^9.13.0",
|
|
123
|
+
"autosize": "^6.0.1",
|
|
124
|
+
"marked": "^4.2.12",
|
|
125
|
+
"user-agent-data-types": "^0.3.1",
|
|
126
|
+
"vue": "^3.2.47"
|
|
116
127
|
},
|
|
117
128
|
"devDependencies": {
|
|
118
|
-
"@babel/core": "7.
|
|
129
|
+
"@babel/core": "7.21.0",
|
|
119
130
|
"@babel/preset-env": "7.20.2",
|
|
120
131
|
"@giphy/js-types": "4.4.0",
|
|
121
132
|
"@rollup/plugin-babel": "6.0.3",
|
|
122
|
-
"@rollup/plugin-commonjs": "24.0.
|
|
133
|
+
"@rollup/plugin-commonjs": "24.0.1",
|
|
123
134
|
"@rollup/plugin-node-resolve": "15.0.1",
|
|
124
135
|
"@rollup/plugin-replace": "5.0.2",
|
|
125
|
-
"@rollup/plugin-terser": "0.
|
|
136
|
+
"@rollup/plugin-terser": "0.4.0",
|
|
126
137
|
"@types/autosize": "4.0.1",
|
|
127
138
|
"@types/marked": "4.0.8",
|
|
128
|
-
"@types/node": "18.
|
|
139
|
+
"@types/node": "18.14.2",
|
|
129
140
|
"@vitejs/plugin-vue": "4.0.0",
|
|
130
141
|
"recaptcha-v3": "1.10.0",
|
|
131
|
-
"rollup": "3.
|
|
132
|
-
"rollup-plugin-dts": "5.
|
|
133
|
-
"rollup-plugin-ts": "3.
|
|
134
|
-
"typescript": "4.9.
|
|
135
|
-
"vite": "4.
|
|
142
|
+
"rollup": "3.17.3",
|
|
143
|
+
"rollup-plugin-dts": "5.2.0",
|
|
144
|
+
"rollup-plugin-ts": "3.2.0",
|
|
145
|
+
"typescript": "4.9.5",
|
|
146
|
+
"vite": "4.1.4"
|
|
136
147
|
},
|
|
137
148
|
"engines": {
|
|
138
149
|
"node": ">=14"
|
|
139
|
-
},
|
|
140
|
-
"scripts": {
|
|
141
|
-
"build": "pnpm rollup && pnpm style",
|
|
142
|
-
"clean": "rimraf ./dist",
|
|
143
|
-
"dev": "vite",
|
|
144
|
-
"rollup": "rollup -c",
|
|
145
|
-
"style": "pnpm style:main && pnpm style:meta",
|
|
146
|
-
"style:main": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed",
|
|
147
|
-
"style:meta": "sass ./src/styles/meta.scss ./dist/waline-meta.css --style=compressed"
|
|
148
150
|
}
|
|
149
|
-
}
|
|
151
|
+
}
|
|
@@ -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) {
|
|
@@ -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);
|