@waline/client 2.15.0 → 2.15.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/client",
3
- "version": "2.15.0",
3
+ "version": "2.15.2",
4
4
  "description": "client for waline comment system",
5
5
  "keywords": [
6
6
  "valine",
@@ -93,16 +93,6 @@
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
- },
106
96
  "browserslist": {
107
97
  "production": [
108
98
  ">0.5%",
@@ -119,7 +109,7 @@
119
109
  ]
120
110
  },
121
111
  "dependencies": {
122
- "@vueuse/core": "^9.13.0",
112
+ "@vueuse/core": "^10.1.0",
123
113
  "autosize": "^6.0.1",
124
114
  "marked": "^4.3.0",
125
115
  "vue": "^3.2.47"
@@ -133,9 +123,18 @@
133
123
  "@vitejs/plugin-vue": "4.1.0",
134
124
  "recaptcha-v3": "1.10.0",
135
125
  "user-agent-data-types": "0.3.1",
136
- "vite": "4.2.1"
126
+ "vite": "4.3.1"
137
127
  },
138
128
  "engines": {
139
129
  "node": ">=14"
130
+ },
131
+ "scripts": {
132
+ "build": "pnpm rollup && pnpm style",
133
+ "clean": "rimraf ./dist",
134
+ "dev": "vite",
135
+ "rollup": "rollup -c",
136
+ "style": "pnpm style:main && pnpm style:meta",
137
+ "style:main": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed",
138
+ "style:meta": "sass ./src/styles/meta.scss ./dist/waline-meta.css --style=compressed"
140
139
  }
141
- }
140
+ }
@@ -207,6 +207,7 @@
207
207
  />
208
208
 
209
209
  <ImageWall
210
+ v-if="searchResults.list.length"
210
211
  :items="searchResults.list"
211
212
  :column-width="200"
212
213
  :gap="6"
@@ -313,10 +314,10 @@ import { addComment, login, updateComment, UserInfo } from '../api/index.js';
313
314
  import {
314
315
  useEditor,
315
316
  useReCaptcha,
317
+ useTurnstile,
316
318
  useUserInfo,
317
319
  useUserMeta,
318
320
  } from '../composables/index.js';
319
- import { useTurnstile } from '../composables/turnstile';
320
321
  import {
321
322
  type WalineComment,
322
323
  type WalineCommentData,
@@ -563,7 +564,9 @@ const submitComment = async (): Promise<void> => {
563
564
 
564
565
  try {
565
566
  if (recaptchaV3Key)
566
- comment.recaptchaV3 = await useReCaptcha(recaptchaV3Key).execute('social');
567
+ comment.recaptchaV3 = await useReCaptcha(recaptchaV3Key).execute(
568
+ 'social'
569
+ );
567
570
 
568
571
  if (turnstileKey)
569
572
  comment.turnstile = await useTurnstile(turnstileKey).execute('social');
@@ -160,7 +160,7 @@ const darkmodeStyle = computed(() => getDarkStyle(config.value.dark));
160
160
 
161
161
  const i18n = computed(() => config.value.locale);
162
162
 
163
- useStyleTag(darkmodeStyle);
163
+ useStyleTag(darkmodeStyle, { id: 'waline-darkmode' });
164
164
 
165
165
  let abort: () => void;
166
166
 
@@ -2,4 +2,5 @@ export * from './inputs';
2
2
  export * from './like';
3
3
  export * from './reaction';
4
4
  export * from './recaptchaV3';
5
+ export * from './turnstile';
5
6
  export * from './userInfo';
@@ -1,3 +1,5 @@
1
+ import { useScriptTag } from '@vueuse/core';
2
+
1
3
  interface TurnstileOptions {
2
4
  sitekey: string;
3
5
  action?: string;
@@ -19,61 +21,29 @@ interface Turnstile {
19
21
  execute: (action: string) => Promise<string>;
20
22
  }
21
23
 
22
- interface LoadScriptParameters {
23
- src: string;
24
- async?: boolean;
25
- defer?: boolean;
26
- }
27
-
28
- const isBrowser =
29
- typeof window !== 'undefined' && typeof window.document !== 'undefined';
30
-
31
- async function loadScript(
32
- options: LoadScriptParameters
33
- ): Promise<Event | undefined> {
34
- if (!isBrowser) {
35
- return Promise.resolve(undefined);
36
- }
37
-
38
- const el = document.createElement('script');
39
-
40
- el.async = Boolean(options.async);
41
- el.defer = Boolean(options.defer);
42
-
43
- return new Promise((resolve, reject) => {
44
- el.onload = resolve;
45
- el.onerror = reject;
46
- el.src = options.src;
47
-
48
- document.head.appendChild(el);
49
- });
50
- }
51
-
52
- const turnstileScriptPromise = loadScript({
53
- src: 'https://challenges.cloudflare.com/turnstile/v0/api.js',
54
- async: false,
55
- });
56
-
57
24
  export const useTurnstile = (key: string): Turnstile => {
58
- async function execute(action: string): Promise<string> {
59
- await turnstileScriptPromise;
60
- const turnstile = window?.turnstile;
61
-
62
- return new Promise((resolve) => {
63
- const options: TurnstileOptions = {
64
- sitekey: key,
65
- action,
66
- size: 'compact',
67
- callback(token: string): void {
68
- resolve(token);
69
- },
70
- };
71
-
72
- turnstile?.ready(() =>
73
- turnstile?.render('.wl-captcha-container', options)
25
+ const execute = (action: string): Promise<string> =>
26
+ new Promise((resolve) => {
27
+ useScriptTag(
28
+ 'https://challenges.cloudflare.com/turnstile/v0/api.js',
29
+ () => {
30
+ const turnstile = window?.turnstile;
31
+
32
+ const options: TurnstileOptions = {
33
+ sitekey: key,
34
+ action,
35
+ size: 'compact',
36
+ callback(token: string): void {
37
+ resolve(token);
38
+ },
39
+ };
40
+
41
+ turnstile?.ready(() =>
42
+ turnstile?.render('.wl-captcha-container', options)
43
+ );
44
+ }
74
45
  );
75
46
  });
76
- }
77
47
 
78
48
  return { execute };
79
49
  };