@vueuse/nuxt 7.4.0 → 7.5.0
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/index.mjs +37 -29
- package/indexes.json +32 -1
- package/package.json +8 -8
- package/ssr-plugin.mjs +41 -0
package/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { dirname, resolve } from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { isPackageExists } from 'local-pkg';
|
|
5
5
|
|
|
6
|
-
const _dirname =
|
|
6
|
+
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
7
|
const disabledFunctions = [
|
|
8
8
|
"useFetch",
|
|
9
9
|
"toRefs",
|
|
@@ -24,6 +24,7 @@ const packages = [
|
|
|
24
24
|
const fullPackages = packages.map((p) => `@vueuse/${p}`);
|
|
25
25
|
function VueUseModule() {
|
|
26
26
|
const { nuxt } = this;
|
|
27
|
+
const options = nuxt.options.vueuse || {};
|
|
27
28
|
nuxt.hook("vite:extend", ({ config }) => {
|
|
28
29
|
config.optimizeDeps = config.optimizeDeps || {};
|
|
29
30
|
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
@@ -33,36 +34,43 @@ function VueUseModule() {
|
|
|
33
34
|
nuxt.options.build.transpile = nuxt.options.build.transpile || [];
|
|
34
35
|
nuxt.options.build.transpile.push("@vueuse/nuxt", "@vueuse/core", "@vueuse/shared");
|
|
35
36
|
let indexes;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
if (options.ssrHandlers) {
|
|
38
|
+
const pluginPath = resolve(_dirname, "./ssr-plugin.mjs");
|
|
39
|
+
nuxt.options.plugins = nuxt.options.plugins || [];
|
|
40
|
+
nuxt.options.plugins.push(pluginPath);
|
|
41
|
+
}
|
|
42
|
+
if (options.autoImports !== false) {
|
|
43
|
+
nuxt.hook("autoImports:sources", (sources) => {
|
|
44
|
+
if (sources.find((i) => fullPackages.includes(i.from)))
|
|
45
|
+
return;
|
|
46
|
+
if (!indexes) {
|
|
47
|
+
try {
|
|
48
|
+
indexes = JSON.parse(fs.readFileSync(resolve(_dirname, "./indexes.json"), "utf-8"));
|
|
49
|
+
indexes == null ? void 0 : indexes.functions.forEach((i) => {
|
|
50
|
+
if (i.package === "shared")
|
|
51
|
+
i.package = "core";
|
|
52
|
+
});
|
|
53
|
+
} catch (e) {
|
|
54
|
+
throw new Error("[@vueuse/nuxt] Failed to load indexes.json");
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
57
|
+
if (!indexes)
|
|
58
|
+
return;
|
|
59
|
+
for (const pkg of packages) {
|
|
60
|
+
if (pkg === "shared")
|
|
61
|
+
continue;
|
|
62
|
+
if (!isPackageExists(`@vueuse/${pkg}`))
|
|
63
|
+
continue;
|
|
64
|
+
const functions = indexes.functions.filter((i) => (i.package === "core" || i.package === "shared") && !i.internal);
|
|
65
|
+
if (functions.length) {
|
|
66
|
+
sources.push({
|
|
67
|
+
from: `@vueuse/${pkg}`,
|
|
68
|
+
names: indexes.functions.filter((i) => i.package === pkg && !i.internal).map((i) => i.name).filter((i) => i.length >= 4 && !disabledFunctions.includes(i))
|
|
69
|
+
});
|
|
70
|
+
}
|
|
63
71
|
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
export { VueUseModule as default };
|
package/indexes.json
CHANGED
|
@@ -35,7 +35,10 @@
|
|
|
35
35
|
"external": [
|
|
36
36
|
"@vueuse/core",
|
|
37
37
|
"@vueuse/shared",
|
|
38
|
-
"local-pkg"
|
|
38
|
+
"local-pkg",
|
|
39
|
+
"fs",
|
|
40
|
+
"path",
|
|
41
|
+
"url"
|
|
39
42
|
],
|
|
40
43
|
"dir": "packages/nuxt",
|
|
41
44
|
"docs": "https://vueuse.org/nuxt/README.html"
|
|
@@ -607,6 +610,13 @@
|
|
|
607
610
|
"category": "Browser",
|
|
608
611
|
"description": "reactive viewport breakpoints"
|
|
609
612
|
},
|
|
613
|
+
{
|
|
614
|
+
"name": "useBroadcastChannel",
|
|
615
|
+
"package": "core",
|
|
616
|
+
"docs": "https://vueuse.org/core/useBroadcastChannel/",
|
|
617
|
+
"category": "Browser",
|
|
618
|
+
"description": "reactive [BroadcastChannel API](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel)"
|
|
619
|
+
},
|
|
610
620
|
{
|
|
611
621
|
"name": "useBrowserLocation",
|
|
612
622
|
"package": "core",
|
|
@@ -903,6 +913,13 @@
|
|
|
903
913
|
"category": "Browser",
|
|
904
914
|
"description": "reactive [Media Query](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries)"
|
|
905
915
|
},
|
|
916
|
+
{
|
|
917
|
+
"name": "useMemoize",
|
|
918
|
+
"package": "core",
|
|
919
|
+
"docs": "https://vueuse.org/core/useMemoize/",
|
|
920
|
+
"category": "Utilities",
|
|
921
|
+
"description": "cache results of functions depending on arguments and keep it reactive"
|
|
922
|
+
},
|
|
906
923
|
{
|
|
907
924
|
"name": "useMemory",
|
|
908
925
|
"package": "core",
|
|
@@ -1218,6 +1235,13 @@
|
|
|
1218
1235
|
"category": "Component",
|
|
1219
1236
|
"description": "shorthand for props v-model binding"
|
|
1220
1237
|
},
|
|
1238
|
+
{
|
|
1239
|
+
"name": "useVibrate",
|
|
1240
|
+
"package": "core",
|
|
1241
|
+
"docs": "https://vueuse.org/core/useVibrate/",
|
|
1242
|
+
"category": "Browser",
|
|
1243
|
+
"description": "reactive vibration web API"
|
|
1244
|
+
},
|
|
1221
1245
|
{
|
|
1222
1246
|
"name": "useVirtualList",
|
|
1223
1247
|
"package": "core",
|
|
@@ -1233,6 +1257,13 @@
|
|
|
1233
1257
|
"category": "Browser",
|
|
1234
1258
|
"description": "reactive [Screen Wake Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API) provides a way to prevent devices from dimming or locking the screen when an application needs to keep running"
|
|
1235
1259
|
},
|
|
1260
|
+
{
|
|
1261
|
+
"name": "useWebNotification",
|
|
1262
|
+
"package": "core",
|
|
1263
|
+
"docs": "https://vueuse.org/core/useWebNotification/",
|
|
1264
|
+
"category": "Browser",
|
|
1265
|
+
"description": "reactive [Notification](https://developer.mozilla.org/en-US/docs/Web/API/notification)"
|
|
1266
|
+
},
|
|
1236
1267
|
{
|
|
1237
1268
|
"name": "useWebSocket",
|
|
1238
1269
|
"package": "core",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/nuxt",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.0",
|
|
4
4
|
"description": "VueUse Nuxt Module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"nuxt3",
|
|
10
10
|
"nuxt-module"
|
|
11
11
|
],
|
|
12
|
+
"homepage": "https://github.com/vueuse/vueuse/tree/main/packages/nuxt#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/vueuse/vueuse/issues"
|
|
15
|
+
},
|
|
12
16
|
"license": "MIT",
|
|
13
17
|
"repository": {
|
|
14
18
|
"type": "git",
|
|
@@ -17,6 +21,7 @@
|
|
|
17
21
|
},
|
|
18
22
|
"funding": "https://github.com/sponsors/antfu",
|
|
19
23
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
24
|
+
"sideEffects": false,
|
|
20
25
|
"exports": {
|
|
21
26
|
".": {
|
|
22
27
|
"import": "./index.mjs",
|
|
@@ -26,15 +31,10 @@
|
|
|
26
31
|
"./*": "./*"
|
|
27
32
|
},
|
|
28
33
|
"main": "./index.cjs",
|
|
29
|
-
"types": "./index.d.ts",
|
|
30
34
|
"module": "./index.mjs",
|
|
31
|
-
"
|
|
32
|
-
"bugs": {
|
|
33
|
-
"url": "https://github.com/vueuse/vueuse/issues"
|
|
34
|
-
},
|
|
35
|
-
"homepage": "https://github.com/vueuse/vueuse/tree/main/packages/nuxt#readme",
|
|
35
|
+
"types": "./index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@vueuse/core": "7.
|
|
37
|
+
"@vueuse/core": "7.5.0",
|
|
38
38
|
"local-pkg": "^0.4.0",
|
|
39
39
|
"vue-demi": "*"
|
|
40
40
|
}
|
package/ssr-plugin.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { setSSRHandler } from '@vueuse/core'
|
|
2
|
+
import { useMeta } from '#meta'
|
|
3
|
+
import { useCookie } from '#app'
|
|
4
|
+
|
|
5
|
+
setSSRHandler('getDefaultStorage', () => {
|
|
6
|
+
const cookieMap = new Map()
|
|
7
|
+
const get = (key) => {
|
|
8
|
+
if (!cookieMap.get(key))
|
|
9
|
+
cookieMap.set(key, useCookie(key, { maxAge: 2147483646 }))
|
|
10
|
+
return cookieMap.get(key)
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
getItem: (key) => get(key).value,
|
|
14
|
+
setItem: (key, value) => get(key).value = value,
|
|
15
|
+
removeItem: (key) => get(key).value = undefined
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
if (process.server) {
|
|
20
|
+
setSSRHandler('updateHTMLAttrs', (selector, attr, value) => {
|
|
21
|
+
if (selector === 'html') {
|
|
22
|
+
useMeta({
|
|
23
|
+
htmlAttrs: {
|
|
24
|
+
[attr]: value,
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
else if (selector === 'body') {
|
|
29
|
+
useMeta({
|
|
30
|
+
bodyAttrs: {
|
|
31
|
+
[attr]: value,
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw new Error(`Unsupported meta selector "${selector}" in SSR`)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default () => { }
|