nuxt-visitors 1.1.0 → 1.1.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/README.md +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/app/composables/useVisitors.d.ts +4 -4
- package/dist/runtime/app/composables/useVisitors.js +5 -2
- package/dist/runtime/server/routes/visitors.d.ts +1 -1
- package/dist/runtime/server/routes/visitors.js +1 -0
- package/package.json +9 -9
package/README.md
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
@@ -10,7 +10,7 @@ const module = defineNuxtModule({
|
|
10
10
|
addImportsDir(resolver.resolve("./runtime/app/composables"));
|
11
11
|
addServerHandler({
|
12
12
|
route: "/.nuxt-visitors/ws",
|
13
|
-
handler: resolver.resolve("./runtime/server/routes/visitors
|
13
|
+
handler: resolver.resolve("./runtime/server/routes/visitors")
|
14
14
|
});
|
15
15
|
}
|
16
16
|
});
|
@@ -16,9 +16,9 @@
|
|
16
16
|
* - reconnect: () => void - Function to manually reconnect
|
17
17
|
*/
|
18
18
|
export declare function useVisitors(): {
|
19
|
-
visitors:
|
20
|
-
isLoading:
|
21
|
-
error:
|
22
|
-
isConnected:
|
19
|
+
visitors: import("vue").Ref<number, number>;
|
20
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
21
|
+
error: import("vue").Ref<string | null, string | null>;
|
22
|
+
isConnected: import("vue").Ref<boolean, boolean>;
|
23
23
|
reconnect: () => void;
|
24
24
|
};
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { ref, onMounted, onBeforeUnmount } from "vue";
|
2
|
+
import { useState } from "#imports";
|
1
3
|
export function useVisitors() {
|
2
4
|
const visitors = useState("visitors", () => 0);
|
3
5
|
const isLoading = ref(true);
|
@@ -20,10 +22,11 @@ export function useVisitors() {
|
|
20
22
|
isConnected.value = false;
|
21
23
|
isLoading.value = false;
|
22
24
|
};
|
23
|
-
const handleMessage = (event) => {
|
25
|
+
const handleMessage = async (event) => {
|
24
26
|
if (!isMounted.value) return;
|
25
27
|
try {
|
26
|
-
const
|
28
|
+
const data = typeof event.data === "string" ? event.data : await event.data.text();
|
29
|
+
const visitorCount = parseInt(data, 10);
|
27
30
|
if (!isNaN(visitorCount) && visitorCount >= 0) {
|
28
31
|
visitors.value = visitorCount;
|
29
32
|
} else {
|
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const _default:
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, never>;
|
2
2
|
export default _default;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nuxt-visitors",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.2",
|
4
4
|
"description": "Add real-time visitor tracking to your Nuxt app with one line of code. WebSocket made easy",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"type": "module",
|
@@ -31,6 +31,7 @@
|
|
31
31
|
"dev:build": "nuxi build playground",
|
32
32
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
33
33
|
"release": "npm run lint && npm run test && npm run prepack",
|
34
|
+
"typecheck": "tsc --noEmit",
|
34
35
|
"lint": "eslint .",
|
35
36
|
"lint:fix": "eslint --fix .",
|
36
37
|
"test": "vitest run",
|
@@ -38,23 +39,22 @@
|
|
38
39
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
39
40
|
},
|
40
41
|
"dependencies": {
|
41
|
-
"@nuxt/kit": "
|
42
|
+
"@nuxt/kit": "3.15.2"
|
42
43
|
},
|
43
44
|
"devDependencies": {
|
44
45
|
"@hrcd/eslint-config": "^2.1.1",
|
45
46
|
"@nuxt/devtools": "^1.7.0",
|
46
47
|
"@nuxt/eslint-config": "^0.7.5",
|
47
48
|
"@nuxt/module-builder": "^0.8.4",
|
48
|
-
"@nuxt/schema": "
|
49
|
+
"@nuxt/schema": "3.15.2",
|
49
50
|
"@nuxt/test-utils": "^3.15.4",
|
50
51
|
"@types/node": "latest",
|
51
|
-
"
|
52
|
+
"automd": "^0.3.12",
|
52
53
|
"eslint": "^9.19.0",
|
53
|
-
"nuxt": "3.15.
|
54
|
-
"typescript": "5.
|
54
|
+
"nuxt": "3.15.2",
|
55
|
+
"typescript": "5.6.3",
|
55
56
|
"vitest": "^3.0.4",
|
56
|
-
"vue-tsc": "^2.2.0"
|
57
|
-
"automd": "^0.3.12"
|
57
|
+
"vue-tsc": "^2.2.0"
|
58
58
|
},
|
59
|
-
"packageManager": "pnpm@9.15.4
|
59
|
+
"packageManager": "pnpm@9.15.4"
|
60
60
|
}
|